The DHT22 is the classic temperature and humidity sensor, and on the S3-DevKitC-1 it needs just three wires — 3V3, GND and DATA to GPIO4.
What trips people up on this board is not the sensor but the two USB-C ports. With the default settings this sketch prints on the UART port; pick that one in the Arduino IDE and open the Serial Monitor at 115200.
Wiring
| ESP32-S3-DevKitC-1 | DHT22 (AM2302) | Wire | Notes |
|---|---|---|---|
| 3V3 | 1 VCC | red | |
| 4 | 2 DATA | yellow | |
| 3V3 | 2 DATA | red | Via 10 kΩ — Pull-up for the bare 4-pin sensor. 3-pin breakouts already have it — skip this wire. |
| 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
- GPIO4 is a plain ADC1/touch pin. Avoid the S3’s strapping pins (0, 3, 45, 46), the USB pins (19, 20) and, on N8R8/N16R8 boards, GPIO35–37, which belong to the octal PSRAM.
- This sketch uses the core’s default settings, so
Serialgoes to the port labelled UART. Plugged into the USB port you see nothing unless you enable Tools → USB CDC On Boot. - The heat index (“feels like”) is what matters in Indian summers: at 35 °C and 60 % humidity it is already above 45 °C.
Code
// DHT22 / AM2302 on an ESP32-S3-DevKitC-1.
// VCC → 3V3, DATA → GPIO4 (10 kΩ pull-up to 3V3 for the bare 4-pin sensor), GND → GND.
// GPIO4 is a plain ADC1/touch pin — no strapping role (0/3/45/46), not USB (19/20), not PSRAM.
// Serial goes to the "UART" USB-C port at 115200 baud.
#include <DHT.h>
constexpr uint8_t DHT_PIN = 4;
DHT dht(DHT_PIN, DHT22);
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println("DHT22 on GPIO4 — first reading in 2 s");
}
void loop() {
delay(2000); // the DHT22 can't be read faster than once every 2 s
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 %% Heat index %.1f °C\n", t, h, dht.computeHeatIndex(t, h, false));
}// DHT22 / AM2302 on an ESP32-S3-DevKitC-1.
// VCC → 3V3, DATA → GPIO4 (10 kΩ pull-up to 3V3 for the bare 4-pin sensor), GND → GND.
// GPIO4 is a plain ADC1/touch pin — no strapping role (0/3/45/46), not USB (19/20), not PSRAM.
// Serial goes to the "UART" USB-C port at 115200 baud.
#include <DHT.h>
constexpr uint8_t DHT_PIN = 4;
DHT dht(DHT_PIN, DHT22);
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println("DHT22 on GPIO4 — first reading in 2 s");
}
void loop() {
delay(2000); // the DHT22 can't be read faster than once every 2 s
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 %% Heat index %.1f °C\n", t, h, dht.computeHeatIndex(t, h, false));
}Library: DHT sensor library (Adafruit (also install Adafruit Unified Sensor)) — compiled with DHT sensor library 1.4.7.
Expected serial output
DHT22 on GPIO4 — first reading in 2 s
Temp 31.2 °C Humidity 58.4 % Heat index 36.1 °C
Temp 31.2 °C Humidity 58.6 % Heat index 36.1 °CDHT22 on GPIO4 — first reading in 2 s Temp 31.2 °C Humidity 58.4 % Heat index 36.1 °C Temp 31.2 °C Humidity 58.6 % Heat index 36.1 °C
Common errors
“Failed to read from DHT sensor”
Check the pull-up and that DATA is on GPIO4. Full fix.
Upload works but the Serial Monitor is empty
You are on the USB port with CDC On Boot disabled. Use the UART port, or enable CDC. More on the two ports.