Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Build a simple temperature-and-relative-humidity monitor by wiring a DHT22/AM2302 to an ESP32 and reading it over Wi-Fi or the serial monitor. The DHT22 does not measure air pressure, wind, or rain, so this is a limited weather monitor—not a complete weather station. Its measurement rate is also limited to one new sample every two seconds.

What this ESP32 weather monitor measures

The ESP32 provides processing and Wi-Fi connectivity; the DHT22/AM2302 supplies temperature and relative-humidity readings. Adafruit lists a temperature range of −40 to 80 °C with ±0.5 °C accuracy, and humidity readings from 0 to 100% with 2–5% accuracy. Those are product specifications, not accuracy results from this particular build. The sensor does not provide pressure, wind speed, or rainfall.

The ESP32 Series Datasheet describes 2.4 GHz Wi-Fi and programmable GPIO, but GPIO pins are not interchangeable across every board. Check the pinout and restrictions for your exact development board before choosing a data pin. Espressif ESP32 Series Datasheet

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Parts and wiring

Gather the essentials

  • An ESP32 development board with a known pinout.
  • A DHT22/AM2302 sensor or breakout module.
  • Jumper wires; a breadboard is optional.
  • A pull-up resistor if the sensor module does not already include one. Adafruit documents 4.7 kΩ–10 kΩ for its DHT22 product, while Espressif’s example uses a typical 10 kΩ resistor.

A display or network dashboard is optional: choose one only if you intend to add and configure that output. Adafruit’s product page currently marks its listing as no longer stocked; that describes that seller’s listing, not availability everywhere. Adafruit DHT22 product specifications

#1 Best Overall
MTDELE 3Pcs DHT22 AM2302 Digital Temperature and Humidity Sensor Module
  • DHT22 Temperature and humidity sensor:Compatible with for Arduino
  • Size:28.2*13.1*5.5mm;Line length:155mm
  • Voltage:3-5.5V
  • Operating temperature:-40℃ - -80℃
  • Commodities include:3Pcs Temperature and humidity sensor;9Pcs Connect Jumpers

Connect the sensor

  1. Connect sensor VCC to a supply supported by the specific module. Adafruit describes its bare product as accepting 3–5 V power and I/O; follow the documentation for your actual breakout and ESP32 board.
  2. Connect sensor GND to ESP32 GND so both share a common ground.
  3. Connect DATA to a suitable ESP32 GPIO and configure the same GPIO in firmware. Espressif’s example uses 3.3 V and GPIO 17 as sample wiring only; verify that GPIO 17 is available and appropriate on your board.
  4. Ensure the data line has a pull-up to the logic supply, unless the breakout already includes one. Check the module rather than adding a second resistor blindly.

Choose one firmware route

Use either Arduino or ESP-IDF for this build. Their installation and code paths differ, so follow the matching library or component example rather than mixing APIs.

Arduino: use the DHT library example

Install the Arduino DHT library and its required Adafruit_Sensor library using the instructions in Adafruit’s guide. Open the guide’s DHT example, select the DHT22 sensor type, and set its data pin to the GPIO you wired. Choose the ESP32 board and port in the Arduino IDE, upload the sketch, then open Serial Monitor at the baud rate configured by that example. Adafruit DHT sensor downloads and setup guide

Rank #2
HiLetgo 2pcs DHT22/AM2302 Digital Temperature and Humidity Sensor Module Temperature Humidity Monitor Sensor Replace SHT11 SHT15 for Arduino Electronic Practice DIY
  • Main Chip: AOSONG AM2302 High Sensitive Temperature Humidity Sensor
  • Single-bus digital signal output, bidirectional serial data
  • With fixing screw hole, convenient to install and fixed
  • Temperature range: -40 to 80 degree celsius, Temperature measurement accuracy: +/- 0.5℃ degree celsius
  • Humidity measuring range: 0~100%RH, Humidity measurement accuracy: ±2%RH

ESP-IDF: use the Espressif component example

The Espressif Component Registry’s achimpieters/esp32-dht v1.0.2 example supports AM2301/DHT22. Follow that version’s component instructions, configure the sensor type and GPIO to match your wiring, then build and flash the example using ESP-IDF. Its documented read interval is two seconds. ESP-IDF DHT component v1.0.2

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Readings, timing, and Wi-Fi output

Start with the serial output so you can confirm that the sensor is wired and configured correctly. Once readings appear there, you can add a screen or send values over Wi-Fi, but the ESP32’s Wi-Fi capability alone does not create a dashboard or remote endpoint; those require their own implementation.

Rank #3
DHT22 Temperature and Humidity Sensor Module for Arduino ESP32 Raspberry Pi, 5 Pieces
  • DHT22 Temperature and Humidity sensor module for Arduino, Raspberry Pi, ESP32, ESP8266
  • Easy to connect: With a built-in resistor, No need to solder or breadboard
  • Working voltage: DC 3.3V-5V
  • Tutorials for Arduino, ESP32, ESP8266, Raspberry Pi Pico, and MicroPython are provided => Search for: DIYables DHT22
  • DHT22 temperature and humidity sensor works with Arduino, ESP32, ESP8266, Raspberry Pi, or any 5V or 3.3V microcontroller.

The DHT22’s maximum sampling rate is 0.5 Hz: one new sample every two seconds. Repeatedly calling a read function faster does not produce faster fresh measurements; library output may be up to two seconds old. Keep the acquisition interval at least two seconds and avoid presenting faster polling as a higher-rate sensor feed. Adafruit DHT22 sampling specifications

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Deployment limits

This wiring plan is suitable for a basic indoor or otherwise protected monitor. The cited documentation does not validate an outdoor radiation shield or weatherproof enclosure, so the build should not be treated as an outdoor-ready installation without a separately designed and validated protective housing.

Quick Recap

Bestseller No. 1
MTDELE 3Pcs DHT22 AM2302 Digital Temperature and Humidity Sensor Module
MTDELE 3Pcs DHT22 AM2302 Digital Temperature and Humidity Sensor Module
DHT22 Temperature and humidity sensor:Compatible with for Arduino; Size:28.2*13.1*5.5mm;Line length:155mm
$8.99
Bestseller No. 2
HiLetgo 2pcs DHT22/AM2302 Digital Temperature and Humidity Sensor Module Temperature Humidity Monitor Sensor Replace SHT11 SHT15 for Arduino Electronic Practice DIY
HiLetgo 2pcs DHT22/AM2302 Digital Temperature and Humidity Sensor Module Temperature Humidity Monitor Sensor Replace SHT11 SHT15 for Arduino Electronic Practice DIY
Main Chip: AOSONG AM2302 High Sensitive Temperature Humidity Sensor; Single-bus digital signal output, bidirectional serial data
$13.99
Bestseller No. 3
DHT22 Temperature and Humidity Sensor Module for Arduino ESP32 Raspberry Pi, 5 Pieces
DHT22 Temperature and Humidity Sensor Module for Arduino ESP32 Raspberry Pi, 5 Pieces
DHT22 Temperature and Humidity sensor module for Arduino, Raspberry Pi, ESP32, ESP8266; Easy to connect: With a built-in resistor, No need to solder or breadboard
$13.99
Rank #4
DHT22 Temperature and Humidity Sensor Module for Arduino ESP32 Raspberry Pi, 3 Pieces
  • BUILT-IN MODULE DESIGN: Unlike bare DHT22 sensors, this module includes a filtering capacitor and pull-up resistor on the PCB, ensuring stable readings without any additional external components
  • HIGH ACCURACY MEASUREMENTS: Measures temperature from -40 to +80 degrees C (plus or minus 0.5 degree accuracy) and humidity from 0 to 100% RH (plus or minus 2-5%) using the proven AM2302 element
  • COMES WITH CONNECTING CABLE: Includes a pre-wired cable for direct connection to your microcontroller; simply plug in and start reading sensor data without soldering or breadboard wiring
  • 3-PIN SIMPLE INTERFACE: Connects via VCC, DATA, and GND; works with Arduino, ESP32, ESP8266, and Raspberry Pi using any standard digital I/O pin and a single data line protocol
  • 3 PACK VALUE SET: Includes 3 DHT22 sensor modules each with a connecting cable; perfect for multi-zone monitoring, classroom projects, or having spares on hand for your builds

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.