Arduino DHT11 Temperature and Humidity Monitor

Author : Dinesh Kumar Wickramasinghe

Introduction

Previously we did a temperature monitor project using LM35 Temperature sensor. This time we are going to implement a Temperature and Humidity monitor project using Arduino and DHT11 sensor. DHT11 measures temperature and the relative humidity values. Relative Humidity (RH) is the ratio of the partial pressure of water vapor to the equilibrium vapor pressure of water at a given temperature (Wikipedia). We will use a console window and also a LCD screen in this project to display the temperature and Humidity values coming from the sensor.

Before we begin, here are some images of the completed project.

DHT11 Sensor
DHT11 Sensor

DHT11 supports 20-80% humidity readings with 5% accuracy and 0-50°C temperature readings ±2°C accuracy.

The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The humidity sensing component is a moisture holding substrate with electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate which increases the conductivity between the electrodes. 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. The DHT11 measures temperature with a surface mounted NTC temperature sensor (thermistor) built into the unit.

There are two types of DHT11 sensors. One type has four pins, and the other type has three pins. Three pins version is normally mounted on a PCB and also included a pull-up resistor and easy to connect. I recommend this version. Four pins version normally comes with the plastic package and you need to use a pull-up resistor from outside. Please note that different manufacturers make different designs. Some sensors has the first pin as the data pin. So, please read the manufacturer’s instructions first. Below images shows you the schematics for both versions.


Schematics

You can do this experiment without using the LCD screen. In that case you can view the temperature readings using the Arduino IDE Serial monitor. I will give two versions of source codes for LCD version and Serial monitor version. So if you are planning to view the sensor readings using the serial monitor, then no need to connect the LCD. Only connect the DHT11 sensor.

Schematic for Three Pins Version

Arduino DHT11 Schematic

Schematic for Four Pins Version

Arduino DHT11 Schematic
Source Code

Below source codes will work with both the versions of the sensors which mentioned on the above section.

First download and install the DHT-Library. This library includes all the hard things for you. So you can see the output by minimum lines of codes.

Schematic Without the LCD

#include <dht.h>

dht DHT;
#define DHT11_PIN 3

void setup()
{ 
  Serial.begin(9600);
}
void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  Serial.println(" Humidity " );
  Serial.println(DHT.humidity, 1);
  Serial.println(" Temparature ");
  Serial.println(DHT.temperature, 1);
  delay(2000);
}

                        

Schematic With the LCD

#include <LiquidCrystal.h>
#include <dht.h>

dht DHT;
#define DHT11_PIN 3

LiquidCrystal lcd (7, 8, 9, 10, 11, 12);

//Setup the ports
void setup()
{ 
  lcd.begin(16, 2);
}
void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0, 0);
  lcd.print("Humidity:"); 
  lcd.print(DHT.humidity);
  lcd.print(" %");
  lcd.setCursor(0, 1);
  lcd.print("Temper  :"); 
  lcd.print(DHT.temperature); 
  lcd.print((char)223);
  lcd.print("C");
  delay(2000);
}

                        
References and Conclusion

I believe you could get the correct output from this project. And also the next step is to send these data to a cloud platform and build an IoT (Internet of Things) application. I will create a new tutorial for this soon. If you faced any issues or errors while executing this project, please mention them as a comment. I will try my best to answer. Below links I referred to create this tutorial for you.

Comments Area
Add your questions and comments here. Comments will be published after the admin approval
Published By : Edwin Tan
Added Date :4/16/2021 11:06:38 AM
Hi, is there a code for the same project but for LCD1602 with I2C module?
Published By : Rashim
Added Date :11/28/2017 5:53:14 AM
Hi, This is a good tutorial. Can I use the same library and code for DHT22 as well?

 

Similar Projects

Go Top