Robo India presents tutorial on how to read temperature and humidity data through DHT11 sensor using ESP8266 wifi module on NODEMCU LUA platform.
1. Introduction:
The DHT11 is chosen because it is lab calibrated, accurate and stable and its signal output is digital. Most important of all, it is relatively inexpensive for the given performance. Below is the pinout of the sensor.
2. Understanding DHT11 sensor
DHT11 sensor gives humidity and temperature data. It has got following pin interface.
3. Circuit
Make the following connections –
4. Library File
Following two libraries will be required to run this code. Download the zip file extract the same and copy this to your Arduino library folder.
This library file should be placed at the install folder of Arduino. I have a 64 bit Win7 OS and my arduino library folder address is located at
C:\Program Files (x86)\Arduino\libraries
Library 1 : You may download library file from here.
Library 2: You may download library file from here.
5. Programming
You may download this Arduino Sketch from here.
#include "DHT.h" // including the library of DHT11 temperature and humidity sensor #define DHTTYPE DHT11 // DHT 11 #define dht_dpin 0 DHT dht(dht_dpin, DHTTYPE); void setup(void) { dht.begin(); Serial.begin(9600); Serial.println("Humidity and temperature\n\n"); delay(700); } void loop() { float h = dht.readHumidity(); float t = dht.readTemperature(); Serial.print("Current humidity = "); Serial.print(h); Serial.print("% "); Serial.print("temperature = "); Serial.print(t); Serial.println("C "); delay(800); }
6. Output
Upload the above code to the NodeMCU and open serial monitor. Following output should be shown on the serial monitor.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com