Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesBuild a Wi-Fi-capable temperature-and-humidity monitor by wiring a DHT22 (also called AM2302) to an ESP32 and displaying readings in the Arduino IDE Serial Monitor. The sensor measures temperature and relative humidity—not pressure, wind, or rainfall—and can provide a fresh sample no more often than once every two seconds.
What this weather station measures
The DHT22/AM2302 reports temperature and relative humidity. Adafruit lists a temperature range of −40 to 80 °C with ±0.5 °C accuracy, and a humidity range of 0–100% with 2–5% accuracy; the product page does not state a year for those specifications. These are product specifications, not results from testing this particular build. A DHT22 by itself does not measure air pressure, wind, or rain, so describe this project as a temperature-and-humidity station rather than a complete weather station.
As an Amazon Associate I earn from qualifying purchases.
The ESP32 serves as the controller. The ESP32 Series Datasheet v5.3 describes 2.4 GHz Wi-Fi and programmable GPIO, but pins are not interchangeable across every board. This first version prints readings over USB to a computer; Wi-Fi support does not automatically create a remote dashboard or internet-accessible service.
Parts and software
- An ESP32 development board with a USB cable for programming and serial output.
- A DHT22/AM2302 sensor, either a bare sensor or a breakout module.
- Jumper wires and, optionally, a breadboard.
- A 4.7 kΩ–10 kΩ pull-up resistor if the chosen sensor module does not already include one. Adafruit’s DHT22 product documentation gives this range; Espressif’s example calls for a typical 10 kΩ pull-up.
- Arduino IDE with an ESP32 board package and the Adafruit DHT and Adafruit_Sensor libraries.
Check the documentation for the exact sensor module before supplying power: Adafruit describes its bare DHT22 product as accepting 3–5 V power and I/O, but modules can differ. This example uses 3.3 V and 3.3 V logic, following the Espressif component example. Do not add a second pull-up resistor without checking whether one is already fitted to the breakout.
#1 Best Overall
- 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
Wire the DHT22 to the ESP32
Use the labels on the sensor or its documentation to identify VCC, DATA, and GND; pin order can vary by sensor form. Connect VCC to the supply specified for that module, GND to ESP32 GND, and DATA to a suitable ESP32 GPIO. The data line needs a pull-up to the logic supply unless the breakout already contains one.
| Sensor connection | ESP32 connection | Notes |
|---|---|---|
| VCC | 3.3 V for the example wiring | Follow the documentation for the particular module. |
| GND | GND | The sensor and ESP32 must share ground. |
| DATA | GPIO 17 in Espressif’s example | Example only: confirm the pin is available and suitable on your board, then use that GPIO in the sketch. |
If needed, connect the pull-up resistor between DATA and the logic supply. Espressif’s example uses GPIO 17 and 3.3 V, but those example values are not a universal board pinout. Check the ESP32 Series Datasheet and, especially, the pinout documentation for your specific development board before wiring.
Rank #2
- 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
Install the Arduino libraries and configure the board
- In Arduino IDE, install the ESP32 board support package using the Espressif installation instructions for your IDE version, then choose the exact ESP32 board under Tools > Board. The DHT22 sources cited here do not specify a board-package version or IDE version, so use the current compatible package and the board maker’s instructions.
- Open Tools > Manage Libraries…, search for and install DHT sensor library by Adafruit. Install its dependency, Adafruit Unified Sensor (the Adafruit_Sensor library), when prompted or by searching for it separately. Adafruit lists both libraries in its DHT downloads guide.
- Set the sketch’s data-pin constant to the GPIO you wired. The example below uses 17 only if that GPIO is suitable on your board.
- Select the connected board and port under the IDE’s Tools menu, then upload the sketch.
This Arduino route uses Adafruit’s Arduino library. It is distinct from Espressif’s ESP-IDF component route; their setup steps and APIs are not interchangeable. Espressif documents an AM2301/DHT22 component example at achimpieters/esp32-dht v1.0.2, including configurable sensor type and GPIO. Choose that path instead if your project is already built with ESP-IDF.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Upload a sketch that prints readings
Use the GPIO number connected to DATA in DHTPIN. The loop waits two seconds between reads to respect the sensor’s maximum sampling rate.
Rank #3
- 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.
#include <DHT.h>
#define DHTPIN 17 // Change to the GPIO wired to DATA
#define DHTTYPE DHT22 // AM2302 is compatible with DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println("ESP32 DHT22 temperature and humidity");
}
void loop() {
delay(2000); // DHT22: no more than one fresh sample every 2 seconds
float humidity = dht.readHumidity();
float temperatureC = dht.readTemperature();
if (isnan(humidity) || isnan(temperatureC)) {
Serial.println("DHT22 read failed; check wiring, GPIO, and pull-up.");
return;
}
Serial.print("Temperature: ");
Serial.print(temperatureC, 1);
Serial.print(" °C Humidity: ");
Serial.print(humidity, 1);
Serial.println(" %");
}
After upload, open Tools > Serial Monitor and set its baud rate to 115200. A successful read prints temperature in degrees Celsius and relative humidity as a percentage. To print Fahrenheit instead, call dht.readTemperature(true); keep the humidity read and the two-second interval unchanged.
Understand the update interval and troubleshoot failures
Adafruit specifies a maximum DHT22 sampling rate of 0.5 Hz—one sample every two seconds—and notes that library readings can be up to two seconds old. Reading the sensor more frequently does not produce faster fresh measurements. Keep the delay or otherwise ensure that at least two seconds separate actual sensor reads.
Rank #4
- 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
- Read failure or “nan”: Verify the sensor’s pin labels, common ground, selected GPIO, supply voltage, and pull-up. Check whether the breakout already includes a resistor.
- Readings do not appear: Confirm the sketch uploaded to the intended board and port, then set Serial Monitor to 115200 baud.
- Values seem stale: Allow for the sensor’s two-second refresh limit and the library’s possible reading age; do not expect a new measurement on every faster loop cycle.
- Board does not respond on the chosen pin: Consult that development board’s pinout and change both the wiring and
DHTPINto a suitable GPIO.
Extend it to Wi-Fi or outdoor use
The serial-output sketch is a useful working baseline, not a network dashboard. The ESP32 series supports 2.4 GHz Wi-Fi, but remote viewing requires additional firmware and a defined destination—such as a local web endpoint or another service—plus network configuration. No particular dashboard or cloud service is required by the sensor or the cited examples.
For outdoor deployment, protect the electronics and sensor appropriately. The cited documentation does not validate a radiation shield or weatherproof enclosure, so this wiring tutorial should be treated as an indoor or otherwise protected prototype, not a tested outdoor enclosure design. Adafruit’s product page currently marks its own DHT22 listing as “No longer stocked”; that is one seller’s listing status, not evidence that the sensor is unavailable from every supplier. See the DHT22 product documentation for its specifications and module details.
Quick Recap
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.




