Contents
Introduction
Temperature and Humidity monitoring play a vital role in our day to day life. Temperature and Humidity monitoring and control is very important part in home automation ,automatic drier incubator and so on. In this blog we are going to learn about measuring temperature and humidity using DHT11 sensor.
Components Required
- NodeMCU
- DHT11 Humidity and Temperature sensor
- Breadboard
- Jumper Wires
- Micro USB Cable
DHT11 Humidity and Temperature sensor
DHT11 is cheap and easily available sensor which is used to measure both the Temperature and Humidity. DHT11 uses single wire serial communication protocol to communicate with the controller. It can measure temperature in degree Celsius in the range of 0 to 50°C and relative humidity in percentage (20 to 90% RH)
Hardware Overview
DHT11 WORKING
How DHT11 Measures Temperature?
DHT11 consists of NTC Temperature sensor / Thermistor to measure temperature. NTC means Negative Temperature coefficient thermistor, which causes a decrease in its resistance value with increase in temperature.
To get larger resistance value even for the smallest change in temperature, this sensor is usually made up of semiconductor ceramics or polymers.
How DHT11 Measures Humidity?
Humidity sensing device is used in DHT11 to measure the humidity. A humidity sensing device consists of two which has two electrodes with moisture holding substrate in between them.
So as the humidity changes, the conductivity of the substrate changes or the resistance between these electrodes changes.The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes.
Pin Layout
- VCC: power supply to sensor. We can give voltage range from (3.3 – 5 volt) to dht11.
- DATA OUT: It is connected to any digital pin of micro controller to read the reading from the sensor.
- NC: not connected.
- GND: connect it to gnd of micro controller.
Connection Diagram
DHT11 Library
To install the library go to the Sketch > Include Library > Manage Libraries.
type ‘DHT sensor’ in the search bar. There should be a couple entries. Look for DHT sensor library by Adafruit. Click on that entry, and then select Install.
Coding
#include <ESP8266WiFi.h>
#include <DHT.h>
DHT dht(D5, DHT11);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Temperature: ");
Serial.println(t);
Serial.print("Humidity: " );
Serial.println(h );
delay(2000);
}
Output
YOUTUBE LINK: