Read temperature and humidity with ESP32 and DHT22
2026-08-20 · 4 min read
Connect the DHT22 VCC to 3.3 V, GND to GND and the data pin to GPIO 4 with a 10 k pull-up resistor if your module does not include one.
Install the DHT sensor library in Arduino IDE, create a DHT object on pin 4, and read temperature and humidity every two seconds.
Print the values to the Serial Monitor at 115200 baud. From here you can show them on an OLED or send them to a dashboard.