ESP32 based Azure IoT devices with DHT22 or DHT11

This project is to use two ESP32 based boards with the DHT22 temperature/humidity sensor added. The first board is the ESP32 dev kit v1 and the second one is the Adafruit ESP32 Feather board version with 2 x 15 pin headers. The main difference is the Li-Po battery charger of the Adafruit board. The Arduino sketch and libraries used in the project are identical. The Arduino sketch for this project is a modified version of the example SimpleMQTT for ESP32, that includes a client to use the MQTT protocol for Device-to-Cloud (D2C) and Cloud-to-Device (C2D) communication. This project uses D2C to publish sensor data at a fixed time interval.

The DHT22 temperature/humidity sensor is connected to the boards 3.3 V supply and sensor output to GPIO14. In the Azure portal you will need to create an IOThub with an associated IOTdevice. When an IOTdevice is defined in Azure, a “Connection string” is generated that holds the server hostname and the encryption key for the MQTT communication. The generated connection string is unique for each IOT device and is copied to the IOT device to encrypt/decrypt messages between the device and Azure. The Arduino sketch holds the connection string and for each device the sketch has to be compiled. For the Arduino sketch the library need to be installed separately, see the library dependency description in the sketch.

Leave a Reply

Your email address will not be published.