Code for an sht31-d sensor running on an esp-32 as an aws iot device. Publishes readings via device shadow.
This sensor is meant to integrate with a Greengrass core device. The sensor publishes to its local device shadow and the Greengrass core can interact with it and decides how frequently to publish the data to the cloud.
When you first boot the device, it will setup an access point. Enter in your wifi ssid and password along with a unique
identifier for the device. This device ID will be stored via LittleFS and published to the device shadow. The thingName for the device is expected to be sensor-<device id>
.
Copy secrets.h.example
to secrets.h
and update with variables created from your AWS account. See
their blog post
for more details.
The following libraries must be installed in Arduino IDE:
- NTPClient by Fabrice Weinberg
- Adafruit BusIO by Adafruit
- Adafruit SHT31 Library by Adafruit
- ArduinoJson by Benoit Blanchon
- Cooperative Multitasking by Andreas Motzek
- MQTT by Joel Gaehwiler
- Time by Michael Margolis
- WiFiManager by tzapu
This sensor will publish data in the following format to its named device shadow, "readings". Temperature is in celsius.
{
"state": {
"reported": {
"time": "2024-02-29T20:02:53Z",
"temperature": 22.63999939,
"relativeHumidity": 45.81999969,
"sensorId": "your-sensor-id"
}
}
}