When the number is wrong
A DHT22 has four ways to print a number that is not the room's: nan, which means nothing answered; a steady, plausible wrong number, which is the sketch saying DHT11; the same line again and again, which is the library's two-second cache; and a reading a little warm and a little dry, which is where the sensor is. Each looks different on the Serial Monitor.
Four symptoms
Pick what your Serial Monitor shows.
The first three are the sketch or the wiring, and each has one fix. The fourth is physics, and the fix is where you put the board.
nan: nothing answered
nan is the only error this library reports. It means no forty bits with a
good checksum came back: nothing on the wire, the wrong pin, or a sensor
that did not wake. The TK39 is the TK38's circuit, so when every reading is
nan in the DHT11 book
is the checklist, in order.
Two causes are particular to this board. On 3V3 the DHT22 is at the bottom
of its 3.3 to 6 V range, so a long thin supply wire has nothing to spare.
And a sketch that says DHT22 on a TK38 sends a start pulse the DHT11
usually ignores.
A steady wrong number: the type
0.00 C 2.00 % in a warm room, every time, with no nan: the sketch says
DHT11. The wrong type shows
why the checksum passes. Change one word.
The same line again: the cache
Asked more often than every 2000 ms, Adafruit's library hands back its
previous reading without touching the wire. The numbers are real and old;
they hold, then jump. A failure is cached the same way, so a retry inside
two seconds gets the same nan. Every two
seconds times the loop so it
cannot happen.
Warm and dry: the placement
A sensor warmer than the room reads warm, and it also reads dry. The water in the air is the same; at the sensor's higher temperature it is a smaller fraction of what the air could hold. At 23.4 °C and 51.2 %, two degrees warm costs about 6 % of humidity, three times the DHT22's ±2 %.
The DHT22 itself draws 1 to 1.5 mA while measuring (§7), for about 5 ms every few seconds, so it does little to warm itself. What warms it is its neighbours: a regulator, a processor, a USB socket, a breadboard next to them. The datasheet's §8 asks for it to be mounted as far as possible from parts that change its temperature. How much a given board warms it has not been measured for this book; move it away on longer wires and compare.
Wet: the element
Water on the humidity element reads as saturated air, so a sensor that has had dew on it, or has come in from the cold, can read at or near 100 % until it dries. The datasheet asks you to avoid using it where dew forms, says it recovers from conditions outside its range at the cost of faster ageing, and gives a reconditioning procedure: two hours at 50 to 60 °C under 10 % humidity, then five hours at 20 to 30 °C over 70 %.
When it does not work
Nothing answered on the wire, or nothing answered with a good checksum. The board and the wiring are the TK38's, so the DHT11 book's checklist applies: GND, VCC on a powered pin, DATA on the pin the sketch names, counted from the square pad.
A read that fails once is normal for this protocol now and then. Failing often points at the wire: a long or thin one, a loose breadboard contact, or VCC at the bottom of the DHT22's 3.3 V floor. Shorten the wires first, and remember a failure is cached for two seconds too.
Water on the element reads as saturated air. The datasheet says to avoid using it where dew forms, that it recovers from conditions outside its range but ages faster, and gives a procedure: 2 h at 50 to 60 °C under 10 % RH, then 5 h at 20 to 30 °C over 70 % RH.
Check where it is before anything else. The datasheet asks for the sensor to be mounted as far as possible from parts that change its temperature. Move it off the breadboard on longer wires, clear of the regulator and the processor, and compare again after a few minutes.
A live page you can open from your phone, off an ESP32, with no backend and no port forwarding.
Put the readings on a dashboard →Edit this page — content/books/dht22/when-the-number-is-wrong.mdx
Questions about this product
See what other owners have asked, and read their solutions.
This page covers several products. Choose yours to see the right 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.