Skip to content

DHT22 Temperature & Humidity Sensor

Overview

DHT22 is a digital temperature and humidity sensor. Accuracy: ±0.5°C for temperature, ±2-5% for humidity.

Wiring

DHT22 Pin ESP32 ESP8266 Pico W
VCC (pin 1) 3.3V 3.3V 3.3V
DATA (pin 2) GPIO4 GPIO2 (D4) GP15
GND (pin 4) GND GND GND

Important: Add a 4.7k-10kΩ pull-up resistor between DATA and 3.3V.

Enable in Dashboard

  1. Go to Device Configuration
  2. Sensor Type: Select DHT22
  3. Enter DATA pin number
  4. Save and regenerate firmware
  5. Flash to your device

Reading Values

After flashing, dashboard will show: - 🌡️ Temperature in °C (with offset calibration) - 💧 Humidity in %

Automation Examples

Temperature > 30°C → Turn ON Fan

Setting Value
Sensor Temperature
Condition Above
Threshold 30
Action Turn ON
Target Relay Fan (Relay 2)
Return Value 26

Humidity < 40% → Turn ON Humidifier

Setting Value
Sensor Humidity
Condition Below
Threshold 40
Action Turn ON
Target Relay Humidifier (Relay 3)
Return Value 50

Calibration

Use temperature offset in dashboard: - If reading 22°C, actual 23°C → Set offset +1.0 - If reading 25°C, actual 24°C → Set offset -1.0

Troubleshooting

Problem Solution
No reading Check wiring, add pull-up resistor
Reading 0°C DATA pin wrong, check connection
Reading -999 Sensor not detected, power cycle
Humidity stuck Replace sensor (DHT22 degrades over time)

Code Example (Arduino)

Best For

  • Home temperature monitoring
  • Greenhouse automation
  • HVAC control
  • Weather stations

Next Steps