DHT11 Humidity & Temperature Sensor Arduino Tutorial

DHT11 module is a digital sensor for measuring the temperature & humidity. There is a number of applications like HVACdehumidifier, weather stations, data loggers and indoor agriculture industry where we need to measure the humidity and temperature.

What is Humidity

Humidity is the amount of water vapour in the air. Water vapour is the gaseous state of water.

What is Relative Humidity

The amount of water vapour in the air expressed as a percentage of the maximum amount that the air could hold at the given temperature; the ratio of the actual water vapour pressure to the saturation vapour pressure.

DHT11 Pinout

The sensor includes a resistive sense of wet components and an NTC temperature measurement devices and connected with a high-performance 8-bit microcontroller. It has digital-signal-collecting-technique and humidity sensing technology that gives reliability and stability.
Datasheet DH11 for more details…

DHT11 Pin Description

  1. The VDD power supply 3.5~5.5V DC
  2. DATA serial data, a single bus
  3. NC, empty pin
  4. GND ground, the negative power

How to Read Humidity and Temperature

For this, we will learn how to connect dht11 with arduino and understanding arduino dht11 library. By using this arduino library we read the DHT module and display the temperature and humidity to the serial monitor of arduino.

DHT Library

Using arduino library makes the dht11 project easy. Link for the arduino dht11 library
At the given link the dht.c and dht.h are given in the website page. Copy and paste the library code in notepad with the name as dht.c and dht.h and place it in a folder name DHT then into arduino library folder so it can appear like this …Documents/Arduino/libraries/DHT.

DHT11 Technical Specification

Model DHT11
Power supply 3.3-5.5V DC
Output signal digital signal via Aosong 1-wire bus
Sensing element Polymer humidity resistor
Operating range humidity 20-90%RH; temperature 0~50Celsius
Accuracy humidity +-5%RH; temperature +-2Celsius
Resolution or sensitivity humidity 1%RH; temperature 1Celsius
Humidity hysteresis +-1%RH
Long-term Stability +-1%RH/year
Interchangeability fully interchangeable

Hardware Required

  • Arduino Uno
  • DHT11 Module
  • Breadboard

DHT11 Arduino Connections – How to Wire DHT11

The humidity sensor circuit diagram shows the basic interfacing with the arduino. The sensor module connected with the 4.7kohm pull up resistor to the digital pin 2 of the arduino. Because from the datasheet it says when the connecting cable is shorter than 20 metres, a 5K pull-up resistor is recommended so we added 4.7kohm.

After reading the sensor data we are sending it to the PC using Arduino Serial Monitor. If you want to display on the 16×2 LCD then view this tutorial.

DHT11 Temperature and Humidity Data on Serial Monitor

DHT11 Arduino Circuit

 

DHT11 Arduino Code

For reading the dht data we use the statement.DHT.read11(DHTpin);
And for humidity and temperature, we have
Serial.print(DHT.humidity); and
Serial.print(DHT.temperature); 
respectively

/* In this program we are reading the DHT11 temperature and humidiy sensor value
from digital pin and display it to the Serial Monitor.
DHT11 Connection:
 Pin 1 : Vcc/+5V
 Pin 2 : Arduino Digital Pin 2
 Pin 3 : NC (Not Connected)
 Pin 4 : GND
*/
#include <dht.h>  
dht DHT;
int DHTpin = 2;
void setup(){  
  // initialize serial communication at 9600 baud rate 
  Serial.begin(9600);      
}
 
void loop(){
  //Read the sensor value
  DHT.read11(DHTpin);
    
  Serial.println("DHT11 tutorial by www.maxphi.com"); 
  Serial.print("Humidity = ");
  Serial.print(DHT.humidity);
  Serial.print("%  ");
  Serial.print("Temperature = ");
  Serial.print(DHT.temperature); 
  Serial.println("C 
");
      
  delay(3000); 
}                

Leave a Reply

Your email address will not be published. Required fields are marked *