What is a DHT22 sensor ?
The DHT22 (or AM2302) is a combined digital temperature and humidity sensor, of better quality than the DHT11.
It integrates:
- a high-precision capacitive humidity sensor,
- a calibrated thermistor,
- and an internal microcontroller that ensures conversion and digital transmission.
It maintains the same simplified 1-wire interface, making it software-compatible with the DHT11 while offering greater accuracy and stability.
Operating principle
The sensor sends a 40-bit digital frame (identical to the DHT11):
8 bits for the whole humidity, 8 bits for the decimal humidity,
8 bits for the whole temperature, 8 bits for the decimal temperature,
and 8 bits for the checksum.
Decoding formula:
Humidity = [(data[0] × 256) + data[1]] / 10
Temperature = [(data[2] × 256) + data[3]] / 10
Example of digital conversion (Arduino)
#include "DHT.h" #define DHTPIN 2 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); } void loop() { float h = dht.readHumidity(); float t = dht.readTemperature(); Serial.print("Temp: "); Serial.print(t, 1); Serial.print(" °C | Hum: "); Serial.print(h, 1); Serial.println(" %"); delay(2000); }
✅ Example output:
Temp: 23.7 °C | Hum: 47.8 %
Principle diagram
+5V │ [DHT22] │ DATA ───────┐ │ GND │ └── MCU (Arduino, ESP32, STM32…)
💡 Recommended pull-up resistance of 4.7–10 kΩ between DATA and VCC.
Application areas
🌦️ Home weather stations and IoT
🧠 HVAC home automation systems
🌿 Environmental monitoring (greenhouses, cellars, laboratories)
🏠 Indoor comfort control
🧪 Advanced educational projects (Arduino, ESP32, Raspberry Pi)