← All parts
Adafruit DHT11/DHT22 Temp/Humidity
AdafruitTrinket M0
Simple wiring for DHT sensors with power, data, and ground connections.
In stock
Specifications
2- Operating Voltage
- 3 to 5V (recommended: 5V) for DHT11, sometimes 3.3V is not enough for DHT22 and AM2302 with 3.3V logic.
- Logic Level
- 3.3V or 5V (depending on sensor type)
Pinout
4| Pin | Name | Functions | Notes |
|---|---|---|---|
| 1 | POWER | POWER | 5V recommended |
| 2 | DATA | GPIOPWM | Pullup resistor required for DHT11 |
| 3 | GND | GND | |
| 4 | GND | GND |
Interactive pinout
Highlight:
Trinket M0
Click a pin to copy its name · tap a tag above to spotlight a bus.
Starter code
Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.
Arduino (C++)
Arduino library: DHT sensor library (Adafruit) (+ Adafruit Unified Sensor)
arduino
// DHT11/DHT22 temperature + humidity — community starter example
#include <DHT.h>
#if defined(ESP32)
#define DHTPIN 4 // ESP32: GPIO4
#else
#define DHTPIN 2 // Uno: D2
#endif
#define DHTTYPE DHT22 // use DHT11 for the blue 3-pin module
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
float t = dht.readTemperature();
float h = dht.readHumidity();
if (isnan(t) || isnan(h)) {
Serial.println("DHT read failed");
} else {
Serial.print("T="); Serial.print(t); Serial.print(" C RH="); Serial.print(h); Serial.println(" %");
}
delay(2000); // DHT22 sampling is ~0.5 Hz
}MicroPython
python
# DHT22 (ESP32) — community starter example
# uses the built-in `dht` module (no install needed)
from machine import Pin
import dht, time
sensor = dht.DHT22(Pin(4)) # DHT11 -> dht.DHT11; data on GPIO4
while True:
sensor.measure()
print(sensor.temperature(), "C", sensor.humidity(), "%")
time.sleep(2)Wiring
| Pin | Arduino Uno R3 | ESP32 DevKitC (WROOM-32) | Notes |
|---|---|---|---|
| Pin 1 (VCC) | +5V | 5V | DHT22 is most reliable at 5 V |
| Pin 2 (DATA) | D2 | GPIO4 | Add a 10 kohm pull-up from DATA to VCC |
| Pin 4 (GND) | GND | GND |
Typical uses
- Room temperature + humidity monitoring
- Greenhouse, HVAC, and weather logging