Comparison · Beginner · 3 min read
DHT11 vs DHT22
Which Temperature and Humidity Sensor?
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
Choose the DHT22 (also sold as AM2302) for most projects: it measures -40 to 80 °C to ±0.5 °C and 0 to 100% humidity to about ±2 to 5%. The cheaper DHT11 covers only 0 to 50 °C at ±2 °C and 20 to 80% humidity, so it suits classroom demos. Both use one data pin with a 10 kΩ pull-up and run on 3.3 or 5 V.
Key specs at a glance
- Interface
- Single-wire digital (proprietary), one data pin
- Supply
- DHT11: 3 to 5.5 V; DHT22: 3.3 to 6 V
- Pull-up
- 4.7 to 10 kΩ on DATA (included on most modules)
- Read rate
- DHT11: once per second; DHT22: once every 2 seconds
- Library
- DHT sensor library (Adafruit) for Arduino and ESP32; dht module in MicroPython
DHT11 vs DHT22 comparison table
| DHT11 | DHT22 / AM2302 | |
|---|---|---|
| Temperature range | 0 to 50 °C | -40 to 80 °C |
| Temperature accuracy | ±2 °C | ±0.5 °C |
| Humidity range | 20 to 80% RH (some datasheets 20 to 90%) | 0 to 100% RH |
| Humidity accuracy | ±5% RH | ±2% RH typical, ±5% max |
| Resolution | 1 °C, 1% RH | 0.1 °C, 0.1% RH |
| Sampling | 1 Hz | 0.5 Hz |
| Case colour | Blue | White |
| Best for | Learning, rough indoor readings | Weather stations, greenhouses, incubators |
- Temperature range
- DHT11:
- 0 to 50 °C
- DHT22 / AM2302:
- -40 to 80 °C
- Temperature accuracy
- DHT11:
- ±2 °C
- DHT22 / AM2302:
- ±0.5 °C
- Humidity range
- DHT11:
- 20 to 80% RH (some datasheets 20 to 90%)
- DHT22 / AM2302:
- 0 to 100% RH
- Humidity accuracy
- DHT11:
- ±5% RH
- DHT22 / AM2302:
- ±2% RH typical, ±5% max
- Resolution
- DHT11:
- 1 °C, 1% RH
- DHT22 / AM2302:
- 0.1 °C, 0.1% RH
- Sampling
- DHT11:
- 1 Hz
- DHT22 / AM2302:
- 0.5 Hz
- Case colour
- DHT11:
- Blue
- DHT22 / AM2302:
- White
- Best for
- DHT11:
- Learning, rough indoor readings
- DHT22 / AM2302:
- Weather stations, greenhouses, incubators
How to wire a DHT11 or DHT22
Bare sensors have four pins; modules have three.
3.3 V or 5 V. Use 5 V on long cables for a stronger signal.
any digital pin, with a 10 kΩ pull-up to VCC (already fitted on three-pin modules).
pin 3 on the bare sensor, not connected.
ground.
On an ESP32 or Pico, power the sensor from 3.3 V so the data line never exceeds 3.3 V.
Read a DHT22 with Arduino or ESP32
Install DHT sensor library by Adafruit (it also installs Adafruit Unified Sensor), then:
#include <DHT.h>
#define DHTPIN 4 // data pin
#define DHTTYPE DHT22 // change to DHT11 if needed
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
delay(2000); // DHT22 needs 2 s between reads
float h = dht.readHumidity();
float t = dht.readTemperature(); // Celsius
if (isnan(h) || isnan(t)) {
Serial.println("Read failed, check wiring");
return;
}
Serial.printf("%.1f C %.1f %%RH\n", t, h); // ESP32; use print() on an Uno
}When to choose a BME280, SHT31 or AHT20 instead
DHT sensors are cheap and simple, but their timing-sensitive protocol can fail on busy Wi-Fi boards, and they drift in very humid places. I2C sensors avoid both problems:
| Sensor | Measures | Accuracy | Interface |
|---|---|---|---|
| AHT20 | Temperature, humidity | ±0.3 °C, ±2% RH | I2C |
| SHT31 | Temperature, humidity | ±0.3 °C, ±2% RH | I2C |
| BME280 | Temperature, humidity, pressure | ±1 °C, ±3% RH, ±1 hPa | I2C or SPI |
| DS18B20 | Temperature only (waterproof probes) | ±0.5 °C | 1-Wire |
- AHT20
- Measures:
- Temperature, humidity
- Accuracy:
- ±0.3 °C, ±2% RH
- Interface:
- I2C
- SHT31
- Measures:
- Temperature, humidity
- Accuracy:
- ±0.3 °C, ±2% RH
- Interface:
- I2C
- BME280
- Measures:
- Temperature, humidity, pressure
- Accuracy:
- ±1 °C, ±3% RH, ±1 hPa
- Interface:
- I2C or SPI
- DS18B20
- Measures:
- Temperature only (waterproof probes)
- Accuracy:
- ±0.5 °C
- Interface:
- 1-Wire
Common mistakes to avoid
- Reading a DHT22 more often than every 2 seconds; it returns stale values or NaN.
- Choosing DHT22 in the code for a DHT11 (or the reverse); readings look plausible but wrong.
- Mounting the sensor next to the microcontroller or regulator, which warms it by 1 to 3 °C.
- Running long thin cables without a stronger pull-up or 5 V supply.
- Leaving it in direct sun or rain; it needs a ventilated radiation shield outdoors.
Frequently asked questions
Is DHT22 better than DHT11?
Yes, for accuracy and range. The DHT22 is about four times more accurate for temperature, covers sub-zero and full humidity ranges, and gives decimal readings. The DHT11 is cheaper and reads slightly faster.
Is AM2302 the same as DHT22?
Yes. AM2302 is the wired version of the same sensor from Aosong, usually supplied with leads and a built-in pull-up.
Does the DHT22 need a resistor?
Yes, a 4.7 to 10 kΩ pull-up between DATA and VCC. Three-pin modules already include it.
Can I use a DHT22 with an ESP32 at 3.3 V?
Yes. It is rated from 3.3 V. Keep the cable short, and power it from 3.3 V so the data line stays within the ESP32's limits.
How accurate is the DHT11 for humidity?
About ±5% RH between 20% and 80%, and it reads in 1% steps. It is fine for showing comfortable versus damp, not for lab-grade logging.
Parts for this guide
- ₹33View
Terms in this guide
Projects that use it
Put this into practice: 167 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- DHT11 humidity and temperature sensor datasheet (Aosong / Mouser)
- AM2302 / DHT22 datasheet (Aosong)
- BME280 datasheet (Bosch Sensortec)
- SHT3x datasheet (Sensirion)
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

