The Arduino Nano ESP32 brings Wi-Fi and Bluetooth to the Nano footprint. A DHT22 wires up just like on a classic Nano — DATA to D2 — with one change: power it from 3V3, because this Nano is a 3.3 V board.
The sketch uses the Nano pin name D2, which the core translates to the right ESP32-S3 GPIO for you.
Wiring
| Arduino Nano ESP32 | DHT22 (AM2302) | Wire | Notes |
|---|---|---|---|
| 3V3 | 1 VCC | red | 3.3 V, not VBUS: the data line is pulled up to VCC. |
| D2 | 2 DATA | yellow | |
| 3V3 | 2 DATA | red | Via 10 kΩ — Bare 4-pin sensor only. |
| GND | 4 GND | black |
3.3–6 V part, 3.3 V board. Works at 3.3 V and 5 V. Power it from the same voltage as your board (3.3 V on ESP32 and Pico, 5 V on Uno), so the data line never exceeds the GPIO limit.
Board quirks
- The Nano ESP32 looks like a classic Nano but its pins are 3.3 V. Power the DHT22 from 3V3 so its pulled-up DATA line never reaches 5 V.
- Tools → Pin Numbering defaults to “By Arduino pin”: the core maps D2 to the S3’s GPIO5. Writing
D2in code works in both modes; a bare2means D2 only in the default mode and GPIO2 (pin A1) in “By GPIO number” mode. - Serial is the S3’s native USB. The sketch waits up to 3 s for the Serial Monitor to connect.
Code
// DHT22 / AM2302 on an Arduino Nano ESP32.
// VCC → 3V3, DATA → D2, GND → GND. 10 kΩ pull-up DATA→3V3 for the bare 4-pin sensor.
// Write D2, not 2: with Tools → Pin Numbering "By Arduino pin" (default) both mean D2, but with
// "By GPIO number" a bare 2 is GPIO2 = pin A1. The D2 name is right in both modes.
#include <DHT.h>
DHT dht(D2, DHT22);
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {} // wait up to 3 s for the USB port
dht.begin();
Serial.println("DHT22 on D2 - first reading in 2 s");
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor - check wiring and pull-up");
return;
}
Serial.printf("Temp %.1f C Humidity %.1f %%\n", t, h);
}// DHT22 / AM2302 on an Arduino Nano ESP32.
// VCC → 3V3, DATA → D2, GND → GND. 10 kΩ pull-up DATA→3V3 for the bare 4-pin sensor.
// Write D2, not 2: with Tools → Pin Numbering "By Arduino pin" (default) both mean D2, but with
// "By GPIO number" a bare 2 is GPIO2 = pin A1. The D2 name is right in both modes.
#include <DHT.h>
DHT dht(D2, DHT22);
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {} // wait up to 3 s for the USB port
dht.begin();
Serial.println("DHT22 on D2 - first reading in 2 s");
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor - check wiring and pull-up");
return;
}
Serial.printf("Temp %.1f C Humidity %.1f %%\n", t, h);
}Library: DHT sensor library (Adafruit (also install Adafruit Unified Sensor)) — compiled with DHT sensor library 1.4.7.
Expected serial output
DHT22 on D2 - first reading in 2 s
Temp 29.1 C Humidity 58.2 %
Temp 29.1 C Humidity 58.3 %DHT22 on D2 - first reading in 2 s Temp 29.1 C Humidity 58.2 % Temp 29.1 C Humidity 58.3 %