This project is to use two ESP32 based boards with the DHT22 temperature/humidity sensor added. One board is the Adafruit ESP32 Feather and the second one is the ESP32 devkitv1 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 IOTdevice associated. 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 NTPClient-master.zip library need to be installed separately, see the library dependency description in the sketch.