ONEWIREbeginner

DHT11 Temperature and Humidity Sensor

A DHT11 on a TinkerBlock board, the TK38: temperature from 0 to 50 °C to ±2 °C and humidity from 20 to 80 % to ±5 %, in whole numbers, on one data wire. The 10 kΩ pull-up is fitted, so it is three wires and one library. Feed VCC what your board's pins run at: the pull-up ties DATA to it.

Comes in this kit — not sold separately

Specifications

TypeAosong DHT11 temperature and humidity sensor on a TinkerBlock board, with its pull-up fitted
Temperature0 to 50 °C, ±2 °C, in steps of 1 °C
Humidity20 to 80 % RH, ±5 %, in steps of 1 %. The datasheet allows 20 to 90 % at 25 °C, narrowing to 20 to 80 % at 50 °C
Supply voltage3 to 5.5 V. Whatever you feed VCC is what the data line idles at
Sample rateOne reading a second at most (datasheet); one every 2 s through Adafruit's library, which answers from memory in between
Response time6 to 30 s for temperature to get two thirds of the way after a change; 6 to 15 s for humidity (datasheet)
Current0.5 to 2.5 mA while measuring, 100 to 150 µA on standby
InterfaceAosong's single-wire protocol: an 18 ms start pulse, then forty bits. No addresses, so not I2C and not Dallas 1-Wire; one pin per sensor
Pull-up resistor10 kΩ from VCC to DATA, fitted
Pins to wire3 of the 4: GND, VCC and DATA. NC is connected to nothing on the board
Header4-pin right-angle male, 2.54 mm pitch: GND, VCC, NC, DATA, with GND on the square pad. A second row of 2.0 mm holes carries the same nets
Board22.4 × 30.4 mm, two 4.8 mm mounting holes 16 mm apart. The DHT11 lies flat, grille up. The back prints TK38 DHT11 and 0-50°C AND 20-80% RH
In the box1 × TK38 block. It also ships in the DHT sensor kit and the TinkerBlock kits

What it does

Two numbers on one wire. The blue DHT11 holds a humidity element, a thermistor and a small microcontroller that reads both, applies its factory calibration and sends the result as forty bits when your board asks. There is nothing analog to wire and nothing to calibrate.

Drag to turn it
The TK38. The sensor lies flat, grille up; the header points off the bottom edge. Turn it over for the back.

It reports whole degrees from 0 to 50 °C, to ±2 °C, and whole per cent from 20 to 80 % RH, to ±5 %. That suits a room, a greenhouse bench or a first project on the protocol. For tenths of a degree or anything below freezing, the TK39's DHT22 takes the same wiring.

The board

The TK38 from the sensor side: the blue DHT11 across the top with its four leads soldered in a column at the right, DHT11 in a gold box, two mounting holes, a small resistor at the left, a row of four open holes labelled GND, VCC, NC and DATA with GND on a square pad, and a right-angle header whose pins point down past the bottom edge. SINGLE WIRE runs up the right edge.
The sensor side. GND is the square pad, at the left.
The back of the TK38: lonely binary across the top, TK38 DHT11 in a gold box, a water-drop and thermometer drawing between the mounting holes, then TEMPERATURE AND HUMIDITY SENSOR and 0-50°C AND 20-80% RH above the header's four solder joints, with the square pad now at the right.
The back: part number and range.

Three nets. GND and VCC go to the sensor; DATA goes to the sensor and to R1, a 10 kΩ pull-up from VCC that is already fitted. NC is in no net. The row of 2.0 mm holes above the header carries the same nets for a cable.

Wiring, in four lines

  1. GND to your board's GND.
  2. VCC to 3V3 on an ESP32, ESP32-S3 or Pico; to 5V on an Uno.
  3. DATA to D2 on an Uno, GPIO 18 on an ESP32, GPIO 4 on an ESP32-S3, GP2 on a Pico.
  4. NC to nothing: it is connected to nothing on the board.

Example

Install DHT sensor library by Adafruit from the Library Manager, and accept Adafruit Unified Sensor with it. MicroPython has a DHT11 driver built in.

dht11.ino
#include <DHT.h>

// Uno: 2. ESP32: 18. ESP32-S3: 4. Pico: 2.
#define DHT_PIN  2
#define DHT_TYPE DHT11   // the TK38 is a DHT11

DHT dht(DHT_PIN, DHT_TYPE);

void setup() {
  Serial.begin(115200);
  dht.begin();
  delay(1000);   // nothing for 1 s after power-up
}

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

  if (isnan(humidity) || isnan(celsius)) {
    Serial.println("read failed");
  } else {
    Serial.print(celsius, 0);
    Serial.print(" C  ");
    Serial.print(humidity, 0);
    Serial.println(" %");
  }

  delay(2000);   // the library answers from memory inside 2 s
}
View on GitHub · blocks/tk38-dht11/arduino/dht11/dht11.ino @ v1.13

Where to start

The handbook below is nine short articles, each with a working figure. The first reading is the whole build, and the four pins is the one page about the header.

For how it works, read the start and the answer and forty bits and a checksum. Before wiring VCC beside a 3.3 V board, 3.3 V or 5 V. If it prints nothing useful, when every reading is nan.

When it doesn’t work

Every reading is nan.
Nothing answered. Count the header from the square pad, GND, VCC, NC, DATA: the third pin is connected to nothing, and one place out looks exactly like a dead sensor. Then check the sketch says DHT11. Declared as a DHT22, the DHT11 gets a start pulse about eighteen times too short and usually never wakes.
It prints numbers in the hundreds.
The wiring is right and the sketch says DHT22. The DHT11's bytes pass their checksum and are decoded as a DHT22's, so 23 °C prints as 588.8. Change DHT_TYPE to DHT11.
Should VCC go to 3V3 or 5V?
To whatever your board's pins run at: 3V3 on an ESP32, ESP32-S3 or Pico, 5V on an Uno. The board's 10 kΩ pull-up ties DATA to VCC, so from 5 V the data line idles at 5 V against a 3.3 V pin. The DHT11 runs anywhere from 3 to 5.5 V.
The temperature only changes in whole degrees.
That is the DHT11's resolution, 1 °C and 1 %. For tenths, and for readings below 0 °C, the TK39 carries a DHT22 on the same header.
The reading never changes.
Either you read faster than every two seconds, and Adafruit's library hands back its stored value, or the room has not moved a whole degree. Read on a millis() timer, and breathe on the sensor to check: the humidity climbs within ten seconds or so.
It reads two degrees higher than my thermometer.
The sensor is measuring what it is plugged into. Move the block away from regulators and USB sockets on three long wires and give it a few minutes. The DHT11 is also only good to ±2 °C.

The DHT11 handbook

9 articles · about 40 minutes

This page is the reference: what the part is, what it is made of, and the questions people arrive already asking. The handbook is the walk — the same part in the order somebody actually meets it.

What it is

2 articles

A blue DHT11 lying flat on a small board, a 10 kΩ pull-up already fitted, and four pins of which three are wired.

The first reading

2 articles

Three wires, one library and a dozen lines, then the one wire that can cost you a board: VCC.

How the one wire works

2 articles

An 18 ms tap on the shoulder, an 80 µs answer, and forty bits whose value is how long each one stays high.

Limits and a check

3 articles

How often you may ask, how slowly it catches up with the room, and what nan narrows the fault down to.

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 Temperature and Humidity Sensor

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 →