Measure Temperature and Humidity Using DHT11 / DHT22 and Arduino

by techtronicharsh in Circuits > Arduino

765 Views, 3 Favorites, 0 Comments

Measure Temperature and Humidity Using DHT11 / DHT22 and Arduino

How to Measure Temperature and Humidity using DHT11 / DHT22 and Arduino | Arduino | Techtronic Harsh

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.

Supplies

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

Introduction :

intro-to-dht22.jpg
Add a heading - Copy.png
DHT11-vs-DHT22-specifications-parameters.png

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.

Schematics :

Untitled Sketch_bb.jpg

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)

DHT dht(DHTPIN, DHTTYPE);

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 */

Video :

How to Measure Temperature and Humidity using DHT11 / DHT22 and Arduino | Arduino | Techtronic Harsh