Specifications
| Type | DHT11 temperature and humidity sensor on a breakout board |
|---|---|
| Temperature | 0 to 50 °C, ±2 °C, in whole degrees |
| Humidity | 20–80 % RH, ±5 %, in whole per cent |
| Sample rate | One reading per second, though the usual library caches for two |
| Interface | Single-wire, Aosong's own. Not I2C, not Dallas 1-Wire |
| Supply voltage | 3 to 5.5 V. Whatever you feed VCC is what the data line idles at |
| Board | TK38, 22.4 × 33.9 mm, with a 10 kΩ pull-up already fitted |
What it is
The same board as the DHT22 with a cheaper sensor soldered to it. Same three nets, same four pads in the same order, same 10 kΩ pull-up, same single-wire protocol, same library — and meaningfully worse numbers: whole degrees rather than tenths, ±5 % humidity rather than ±2 %, and a range that stops at 0 °C.
That range limit is the one that catches people. Below freezing the DHT11 does not read low and warn you; it reports nothing useful at all, so an outdoor logger built on one goes blind on the night you most wanted the data.
Use it to learn the protocol and to prove the wiring, then move to the TK39 for anything whose numbers you will plot, alarm on, or show to somebody else.
Everything about it is over there
Both sensors are documented together, because almost every question either one raises is really a question about the difference between them. The DHT22's page carries the handbook: twelve short articles with a working figure in each, written for both boards.
- Two numbers, one pin — what is inside the cage.
- DHT11 or DHT22 — which of the two a project should get.
- One board, two sensors — the four pins, and the one connected to nothing.
- The first reading — three wires, one library, a sketch.
- When every reading is nan — the five symptoms and what each narrows to.
Example
The only line that differs from a DHT22 sketch is the type.
#include <DHT.h>
#define DHT_PIN 2 // Uno D2. ESP32: 18. ESP32-S3: 4.
#define DHT_TYPE DHT11 // the only line that differs from a DHT22
DHT dht(DHT_PIN, DHT_TYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
float humidity = dht.readHumidity();
float celsius = dht.readTemperature();
// The library returns nan rather than throwing. One failed read in a
// hundred is normal for this protocol, so checking is not optional.
if (isnan(humidity) || isnan(celsius)) {
Serial.println("read failed");
} else {
Serial.print(celsius); Serial.print(" C ");
Serial.print(humidity); Serial.println(" %");
}
delay(2000); // the library caches for 2 s, DHT11 included
}import dht, machine, time
sensor = dht.DHT11(machine.Pin(2))
while True:
try:
sensor.measure()
print(sensor.temperature(), sensor.humidity())
except OSError:
print("read failed")
time.sleep(2)When it doesn’t work
- Every reading is nan.
- Almost always the data pin, the supply, or the sensor type in the sketch. Count the header from the square pad — GND, VCC, NC, DATA — because the third pin is connected to nothing and being one place out looks exactly like a dead sensor. A DHT11 declared as a DHT22 in the sketch gets a start pulse eighteen times too short and usually never answers at all.
- The temperature only ever changes by whole degrees.
- That is the sensor's resolution, not a bug. If you need tenths, use the DHT22 — it is the same wiring and a one-word change in the sketch.
- It stops working below freezing.
- The DHT11's range starts at 0 °C. Outdoors in winter it is the wrong part, and it does not read low and warn you — it goes quiet or reports something meaningless.