Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

DHT22 with ESP32-S3-DevKitC-1 — wiring and code

Wire a DHT22 to an ESP32-S3-DevKitC-1 on GPIO4 at 3.3 V and read temperature, humidity and heat index — plus which USB-C port shows the output.

Arduino C++Verified — core esp32 3.3.12, DHT sensor library 1.4.7, 3 Nov 2026Compile-only

Community draft — report a mistake

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-1Only the pins used are shown · 3.3 V logicDHT22 (AM2302)10k → 3V33V34 · 4GND1 VCC2 DATA3 NC (not connected)4 GND
Also needed: 10 kΩ resistor (bare 4-pin DHT22 only).
Every connection
ESP32-S3-DevKitC-1DHT22 (AM2302)WireNotes
3V31 VCCred
42 DATAyellow
3V32 DATAredVia 10 kΩ — Pull-up for the bare 4-pin sensor. 3-pin breakouts already have it — skip this wire.
GND4 GNDblack

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 Serial goes 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-esp32s3.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 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

Serial Monitor · 115200Output
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 °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.

↑↓ to move · Enter to open