TK38ONEWIREbeginner

DHT11

The DHT22's cheaper sibling on the same board design: whole degrees, five per cent humidity, and a range that stops at 0 °C. Right for learning, wrong for anything you will act on.

Comes in this kit — not sold separately

Specifications

TypeDHT11 temperature and humidity sensor on a breakout board
Temperature0 to 50 °C, ±2 °C, in whole degrees
Humidity20–80 % RH, ±5 %, in whole per cent
Sample rateOne reading per second, though the usual library caches for two
InterfaceSingle-wire, Aosong's own. Not I2C, not Dallas 1-Wire
Supply voltage3 to 5.5 V. Whatever you feed VCC is what the data line idles at
BoardTK38, 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.

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
}

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.

Lessons using TK38

Each one is a working build, not a snippet.

Edit this page — content/modules/dht11.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

DHT11

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum