DHT11/DHT22 Temperature and humidity Sensor

The DHTxx series is a commonly used Temperature and humidity sensor. The sensor comes with a dedicated NTC to measure temperature and an 8-bit microcontroller to output the values of temperature and humidity as serial data. The sensor is also factory calibrated and hence easy to interface with other MCU.
DHT11/DHT22 sensors are popular among the Arduino projects. The DHT sensors are inexpensive sensors for measuring temperature and humidity.
These sensors contain a chip that does analog to digital conversion and spits out a digital signal with the temperature and humidity.
These signals are easy to read with (MCU).

There two types

1. DHT11 (AM2302)
a. Range: 20 – 90%
b. Absolute accuracy:±5%
c. Repeatability:±1%
d. Stability:1% per year.
e. Operating Voltage: 3.5V to 5.5V
f. Operating current: 0.3mA (measuring) 60uA (standby)
g. Output: Serial data
h. Resolution: Temperature and Humidity both are 16-bit
2. DHT22
a. Range: 20 – 100%
b. Absolute accuracy:±2%
c. Repeatability:±1%
d. Stability: 0.5% per year
e. Operating Voltage: 3.5V to 5.5V
f. Operating current: 0.3mA (measuring) 60uA (standby)
g. Output: Serial data
h. Resolution: Temperature and Humidity both are 16-bit

PIN DETAILS Arduino Wiring
Pin-1 VCC 5V
Pin-2 Data out Digital Oin out
Pin-3 (NC) No Connection
Pin-4 Ground Gnd

1. Full range temperature compensated.
2. Relative humidity and temperature measurement.
3. Calibrated digital signal.
4. Outstanding long-term stability.
5. Extra components not needed.
6. Long transmission distance.
7. Low power consumption.
8. 4 pins packaged and fully interchangeable.
a. Measure temperature and humidity.
b. Local Weather station.
c. Automatic climate control.
d. Environment monitoring.

Open Arduino IDE installed Computer and you want to add or install the DNT Library.
Follow the below given steps
1. Download the DHT11 library.
2. Install the DHT11 in your Arduino IDE: go to Sketch >>Include Library >>Add.
3. Restart your Arduino IDE
4. Go to File >>Examples >>DHT sensor library >>DHTtester
5. Upload the code
For example : Copy and Paste below given code with your Arduino IDE Sketch, compile and upload, test with serial monitor.
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include “DHT.h”
#define DHTPIN 2 // what digital pin we’re connected to
// Uncomment whatever type you’re using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
void setup() {
Serial.println(“DHTxx test!”);
void loop() {
// Wait a few seconds between measurements.
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(“Failed to read from DHT sensor!”);
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(“Humidity: “);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(” *C “);
Serial.print(” *F\t”);
Serial.print(“Heat index: “);
Serial.print(” *C “);
Serial.println(” *F”);
For Arduino IDE Software: Download Here.       Download DHT library: Here 

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.