DHT11 sensor interface with Node MCU. Temperature and Humidity Sensor detection project on esp8266 node mcu with code.

 Components Required


  • ESP8266 Node MCU
  • DHT11 Humidity and Temperature sensor
  • Breadboard
  •  Wires for connecting
  • Micro USB Cable


Software 


  • Arduino IDE


More about DTH11 Humidity and Temperature Sensor uses and Pinout- check


What is a DHT11 sensor?

The DHT11 is an ultra-low-cost digital temperature and humidity sensor. The sensor uses a capacitive humidity sensor and a thermistor to measure the surrounding air and spits out a digital signal on the data pin.


How does the DHT11 sensor work?

DHT11 sensor calculates relative humidity by measuring the electrical resistance between two electrodes. The humidness sensing component of the DHT11 is a moisture-holding substrate with the electrodes applied to the surface. The change in resistance between the two electrodes is proportional to the relative humidity.


How accurate is the DHT11 sensor?

The DHT11 humidity range is from 20 to 80% with 5% accuracy.


How many pins are in the DHT11 sensor?

DHT11 Humidity Sensor consists of 3 or 4 pins: VCC, Data Out, Not Connected (NC), and GND.


Where is the DHT11 sensor used?

Offices, cars, museums, greenhouses, and industries use this sensor for measuring humidity values and as a safety measure. Its compact size and sampling rate made this sensor popular among hobbyists.


What is the limitation of the DHT11 sensor?

It is simple to use but requires careful timing to detect data. The limitation of this sensor is you can only get new data from it once every 2 seconds.


How does DHT11 send data?

Communication between Microcontroller and sensor

DHT11 uses only one wire for communication through a data pin.

The communication takes place, first is to send a request to the DHT11 sensor then the sensor will send a response pulse and then it starts sending data of a total of 40 bits to the microcontroller.


What is the operating voltage of the DHT11 sensor?

The DHT11 temperature and humidity sensor are small in size with an operating voltage from 3 to 5 volts. The maximum current of the sensor used while measuring is 2.5mA. DHT11 sensor has 4 pins- VCC, GND, Data Pin, and a not connected pin. DHT11 Sensor also has a pull-up resistor of 5k to 10k ohms is provided for communication between sensor and micro-controller.


What is the difference between DHT11 & DHT22 sensors?

The DHT11 temperature and humidity sensor is less precise, works in a smaller range of temperature/humidity, and is slightly slower, but also features a lower price point. If the accuracy is important for the project you working on, and you don't mind the high price for the sensor, then go for the DHT22. Otherwise, the DHT11 should be good enough for your projects.


Is the DHT11 sensor waterproof?

It provides temperature measurements in Celsius and communicates with the microcontroller via the 1wire bus protocol. It is covered with plastic housing so it can be immersed in the water.


What kind of sensor is DHT11?

Digital temperature and humidity sensor.


Circuit diagram


Circuit Diagram


Pinout for ESP8266 NODE MCU

ESP8266 Node MCU






Code for circuit


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "DHT.h"        // include  library of DHT11 sensor

#define DHTTYPE DHT11   // DHT 11



#define dht_dpin 14

DHT dht(dht_dpin, DHTTYPE); 

void setup(void)

{ 

  dht.begin();

  Serial.begin(9600);

  Serial.println("Humidity and Temperature\n");

  delay(800);


}

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);

}



From Tools

  • Select your board as Node MCU
  • Select your port 
  • Upload code on NODE MCU

After Successful uploading code see your output on Serial Monitor in Arduino IDE





If you still have any questions related to this article, then you can message me on my social media accounts.



!!THANKS FOR VISITING!!
!!HAPPY LEARNING!!
!!HAVE A GREAT DAY!!