The Hardware Setup

The DHT22 has three pins that matter: power, ground, and a single data line. Most breakout boards already include the required pull-up resistor built in — if you're using a bare DHT22 sensor (not a breakout module), add a 10kΩ resistor between the data pin and 3.3V.

DHT22 VCC: 3.3V
DHT22 GND: Ground
DHT22 Data: GPIO 4
Pull-up Resistor: 10kΩ (data pin to 3.3V, if not built into your module)

The Arduino Source Code

Install Adafruit's DHT sensor library via the Library Manager (it will prompt you to also install Adafruit Unified Sensor — accept that too).

// ESP32-S3 DHT22 Temperature & Humidity Tutorial - CircuitHub.pro
#include <DHT.h>

#define DHTPIN 4
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);
  dht.begin();
}

void loop() {
  float humidity = dht.readHumidity();
  float tempC = dht.readTemperature();

  if (isnan(humidity) || isnan(tempC)) {
    Serial.println("Failed to read from DHT sensor!");
    delay(2000);
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print("%   Temperature: ");
  Serial.print(tempC);
  Serial.println("°C");

  delay(2000); // DHT22 can only be read reliably about once every 2 seconds
}

Required Components

A classic beginner sensor project:

ESP32-S3 DevKitC-1 Buy Board
DHT22 Sensor Module Buy Sensor
10kΩ Resistor (if needed) Buy Resistor

🚀 Take It Further

Pair this with the Temperature Converter calculator on the Calculators page — feed your live Celsius reading into that same C + 273.15 formula to display Kelvin, or push readings to the OLED from the Hello World tutorial for a standalone weather station.