Introduction: Measure Temperature and Humidity Using DHT11 / DHT22 and Arduino

About: Welcome to my Channel "Techtronic Harsh". I am Harsh Shah. This is an education channel and website in the area of Electronic, Electrical and Computer Engineering. Tutorials, Tips, Tricks, How It Wor…

In this Arduino Tutorial we will learn how to use the DHT11 or the DHT22 sensor for measuring temperature and humidity with the Arduino board.


  • Arduino UNO
  • DHT11 or DHT22
  • 16 x 2 LCD Display
  • Breadboard
  • Jumper Cables
  • Arduino Cable

Step 1: Introduction :

These sensors are very popular for electronics hobbyists because there are very cheap but still providing great performance. Here are the main specifications and differences between these two sensors:

The DHT22 is the more expensive version which obviously has better specifications. Its temperature measuring range is from -40 to +125 degrees Celsius with +-0.5 degrees accuracy, while the DHT11 temperature range is from 0 to 50 degrees Celsius with +-2 degrees accuracy. Also the DHT22 sensor has better humidity measuring range, from 0 to 100% with 2-5% accuracy, while the DHT11 humidity range is from 20 to 80% with 5% accuracy.

There are two specification where the DHT11 is better than the DHT22. That’s the sampling rate which for the DHT11 is 1Hz or one reading every second, while the DHT22 sampling rate is 0,5Hz or one reading every two seconds and also the DHT11 has smaller body size. The operating voltage of both sensors is from 3 to 5 volts, while the max current used when measuring is 2.5mA.

Step 2: Schematics :

Step 3: Source Code :

© Techtronic Harsh */

#include "DHT.h" //include the DHT library #include <LiquidCrystal.h> //include the LiquidCrystal library #define DHTPIN 12 //define DHT pin #define DHTTYPE DHT11 //define DHTTYPE DHT11/DHT22

LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //define LCD pins (RS, E, D4, D5, D6, D7)


void setup() { dht.begin(); lcd.begin(16,2); //initializes the LCD and specifies the dimensions } void loop() { float temp = dht.readTemperature(); float humi = dht.readHumidity(); lcd.setCursor(0,0); lcd.print("Temp: "); lcd.print(temp); lcd.print(" C"); lcd.setCursor(0,1); lcd.print("Humi: "); lcd.print(humi); lcd.print(" %"); delay(2000); }


© Techtronic Harsh */

Step 4: Video :