Technical Comparison Beginner 10 دقائق

DHT11 vs DHT22: Temperature & Humidity Sensor Comparison for Arduino & ESP32

In-depth comparison between DHT11 and DHT22 (AM2302) temperature and humidity sensors: accuracy, range, sampling rate, and Arduino wiring.

Verified by MOKWN Hardware Engineering Team
DHT11 vs DHT22: Temperature & Humidity Sensor Comparison for Arduino & ESP32
Required Components (BOM)

Project Components Available in Egypt

All components tested and genuine with fast nationwide delivery in Egypt

Add All to Cart
Temperature  Humidity Sensor Module(DHT11)
Qty: 1
Temperature Humidity Sensor Module(DHT11)
الحساس الاقتصادي للتجارب المعملية والمشاريع البسيطة
Precision Digital Temperature & Humidity Sensor Module (DHT22)
Qty: 1
Precision Digital Temperature & Humidity Sensor Module (DHT22)
الحساس عالي الدقة لمشاريع التخرج وأنظمة التكييف والزراعة الذكية
Arduino UNO R3 SMD Development Board with cable
Qty: 1
Arduino UNO R3 SMD Development Board with cable
لوحة التحكم لقراءة البيانات وعرضها على السيريال

Introduction: Choosing the Right Climate Sensor

Whether you are designing an environmental monitor, smart thermostat, greenhouse automation node, or weather station, measuring ambient temperature and relative humidity is essential.

The two undisputed leaders in the maker realm are the DHT11 (blue housing) and the DHT22 / AM2302 (white housing). Here is how they compare technically.

---

Side-by-Side Technical Comparison

| Specification | DHT11 (Blue) | DHT22 / AM2302 (White) | | :--- | :--- | :--- | | Temperature Range | 0°C to 50°C | -40°C to 80°C | | Temperature Accuracy | ±2.0°C | ±0.5°C (4x more accurate) | | Humidity Range | 20% to 80% RH | 0% to 100% RH | | Humidity Accuracy | ±5% RH | ±2% to ±5% RH | | Sampling Rate | 1 Hz (once per second) | 0.5 Hz (once every 2 seconds) | | Operating Voltage | 3.3V to 5.5V | 3.3V to 6.0V | | Price Point | Budget / Entry | Moderate |

---

Wiring Diagram to Arduino Uno

  • VCC: Connect to 5V (or 3.3V on ESP32).
  • DATA: Connect to digital pin D2.
  • GND: Connect to GND.
  • (If using the bare 4-pin version, insert a 10kΩ pull-up resistor between VCC and DATA).

---

Arduino Code Example

#include "DHT.h"

#define DHTPIN 2

// Uncomment the sensor model you are using:
//#define DHTTYPE DHT11
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHT Sensor Initializing...");
  dht.begin();
}

void loop() {
  // Allow at least 2 seconds between readings for DHT22 stability
  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print("%  |  Temperature: ");
  Serial.print(t);
  Serial.println("°C");
}

---

Verdict

  • Buy the DHT11 for rapid introductory prototyping where sub-degree accuracy is unnecessary.
  • Invest in the DHT22 for HVAC controllers, egg incubators, greenhouse monitors, and engineering graduation projects where verified scientific accuracy is required.

Frequently Asked Questions

Why do I get "Failed to read from DHT sensor" error?

The most common cause is polling faster than the sensor sampling rate (DHT22 needs 2000ms intervals, DHT11 needs 1000ms), or a missing 10k pull-up resistor between the DATA line and VCC.

Which sensor is better for greenhouses and weather stations in Egypt?

DHT22 (AM2302) is far superior. DHT11 cannot measure sub-zero temperatures and has poor humidity accuracy (±5%), while DHT22 measures -40°C to 80°C at ±0.5°C accuracy.

Can both sensors be controlled with the same Arduino library?

Yes, the popular Adafruit "DHT sensor library" supports both models natively. You simply change `#define DHTTYPE DHT11` to `#define DHTTYPE DHT22`.

Ask Volt AI Hardware Assistant

Need help debugging your circuit wiring or verifying your code? Chat with Volt directly.

Start Chat with Volt