To read a DHT11 sensor connected on GPIO5 of an Amica NodeMCU v2 ESP8266 based board, use the following code:
Dht.read( Dht.TypeEL.DHT11, 5);
It returns a JSON object with the following format:
Dht.TypeEL enumeration contains the following literals:
DHT22. Make sure that you are using the right one for your sensor, otherwise you'll get wrong readings.
The last parameter of the
read method represents the GPIO pin number and NOT the pin number marked on the board. In our example,
5 means that we use the
GPIO5 pin of an Amica NodeMCU v2 board, as shown in the image below.
Adding the DHTxx Code to Mongoose-IoT Firmware
src folder contains the needed files. Each file contains notes and comments about where should be copied or where its content must be added to an already existing Mongoose-IoT Firmware source file.