The DHT is a popular, low-cost digital sensor that measures both temperature and humidity. DHT22 offers higher accuracy than its predecessor, the DHT11. It is suitable for a wide range of applications, including weather stations and smart home systems.
| Type of measurement | Model | Power voltage | Measurement, range, accuracy | Communication | Note |
|---|---|---|---|---|---|
![]() Temperature Humidity | DHT11 ![]() | 3.3 / 5 V (3.3 .. 5.5V) | Temperature measurement range: 0 .. +50 °C Temperature measurement accuracy: ±2°C Humidity measurement range: 20..90% RH Humidity measurement accuracy: ±5% | 1-Wire | 8 bit resolution, response time 10 sec |
![]() Temperature Humidity | DHT20 ![]() | 3.3 / 5 V (2.2 .. 5.5V) | Temperature measurement range: -40 .. +80 °C Temperature measurement accuracy: ±0.5°C (-40..80) Humidity measurement range: 0..100% RH Humidity measurement accuracy: ±3% | I²C default addr.: 0x38 | - |
![]() Temperature Humidity | DHT22 AM2302 ![]() | 3.3 / 5 V (2.2 .. 5.5V) | Temperature measurement range: -40 .. +80 °C Temperature measurement accuracy: ±0.5°C (-40..80) Humidity measurement range: 0..100% RH Humidity measurement accuracy: ±2% | single-bus | - |
Operation and Usage
The DHTs use a single bus for communication, which requires careful timing; this is typically handled by libraries in microcontroller environments. A 4.7kΩ to 10kΩ pull-up resistor is needed between the data line and VCC for proper communication.
The sensors are available in two main forms: a 4-pin bare sensor and a 3-pin module with the pull-up resistor integrated.
The BME/BMP sensors can be integrated with the Tasmota system. For more details, see here:
If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.
Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.
To read a DHT22 sensor with an Arduino, you typically use the Adafruit DHT Sensor Library along with the Adafruit Unified Sensor Library.
Wiring Details
The wiring depends on whether you have a bare sensor or a module:
Arduino Example Code
This sketch reads temperature (in Celsius) and humidity every 2 seconds.
#include "DHT.h" #define DHTPIN 2 // Digital pin connected to the DHT sensor #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 // Initialize DHT sensor. DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println(F("DHT22 test!")); dht.begin(); } void loop() { delay(2000); // Wait 2 seconds between measurements // Read humidity and temperature float h = dht.readHumidity(); float t = dht.readTemperature(); float f = dht.readTemperature(true); // Temperature in Fahrenheit // Check for read failures if (isnan(h) || isnan(t) || isnan(f)) { Serial.println(F("Failed to read from DHT sensor!")); return; } // Print results Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F("% Temperature: ")); Serial.print(t); Serial.print(F("°C ")); Serial.print(f); Serial.println(F("°F")); }
This page has been accessed for: Today: 2, Until now: 4