DHT22 (AM2302)
Digital temperature and humidity sensor. It talks to the ESP32 over a single data wire, with the dht module of MicroPython. Read it at most every 2 seconds.
Pinout
| Pin | Connect to | Note |
|---|---|---|
| VCC (1) | 3V3 | |
| DATA (2) | GPIO (e.g. 4) with a ~10 kΩ pull-up | modules with a board already have the resistor |
| NC (3) | leave unconnected | |
| GND (4) | GND |
FastTeacherFor teachers
From the syllabus to a planned semester
- Teaching plan and calendar built automatically
- Class diary ready to paste into SIGA
- Slides and exercise lists with answer keys
Free Community edition · Windows
MicroPython example
import dht
from machine import Pin
import time
sensor = dht.DHT22(Pin(4))
while True:
sensor.measure()
print(sensor.temperature(), "°C", sensor.humidity(), "%")
time.sleep(2)
Specifications
| Item | Value | Source |
|---|---|---|
| Power supply | 3.3–6 V | Datasheet AM2302/DHT22 (Aosong), cdn.sparkfun.com/assets/f/7/d/9/c/DHT22.pdf |
| Temperature | −40 to 80 °C, ± 0.5 °C, resolution 0.1 °C | Datasheet AM2302/DHT22 (Aosong), cdn.sparkfun.com/assets/f/7/d/9/c/DHT22.pdf |
| Humidity | 0–100 % RH, ± 2 % (max. ± 5 %), resolution 0.1 % | Datasheet AM2302/DHT22 (Aosong), cdn.sparkfun.com/assets/f/7/d/9/c/DHT22.pdf |
| Interval between readings | ≥ 2 s | Datasheet AM2302/DHT22 (Aosong), cdn.sparkfun.com/assets/f/7/d/9/c/DHT22.pdf |
| Pin order | VDD, DATA, NC, GND | Datasheet AM2302/DHT22 (Aosong), cdn.sparkfun.com/assets/f/7/d/9/c/DHT22.pdf |
Values marked "Under review" will still be checked against the parts in the lab.