How slowly it catches up
The elements have to warm up and take on water before the reading moves. Aosong gives the DHT11 between 6 and 30 seconds to get two thirds of the way after a change in temperature. And a DHT11 sitting beside something warm does not settle late, it settles wrong.
It is a sponge, not a needle
Change the temperature and watch the reading follow it.
The humidity element is a film that has to take up or give back water before its resistance means anything, and the thermistor has to reach the temperature it reports. Both take time, and by a sketch's standards a lot of it.
Aosong's datasheet (§2) gives the DHT11's temperature response, to 63 % of a step, as 6 seconds at best and 30 at worst, with no typical figure. For humidity it gives 6, 10 typical and 15 seconds, at 25 °C in air moving at one metre per second. Still air is slower. The curve above is a model of that behaviour, not a measurement.
What follows from it
Reading every two seconds gains nothing. The sensor cannot follow that fast. Ten seconds for a display, a minute for a log, and the graph looks the same.
The first readings after a move describe the last room. Carry the TK38 from a warm hallway into a cold garage and it reports the hallway for half a minute or more. Anything that decides on the first reading after power-up is deciding on old air.
Breathing on it is a fair test, but the humidity takes minutes, not seconds, to come back down.
Where you put it
The delay is a nuisance. The offset is worse, because it never goes away.
A TK38 plugged straight into a breadboard beside a voltage regulator, or into a board next to a USB socket, is sitting on something that turns power into heat. It settles perfectly well, to the wrong number, and waiting longer does not help. The datasheet (§7) says the same: mount the DHT11 as far as possible from parts that generate heat, and keep it out of strong sunlight.
The fix is three long jumper wires and the block hanging in free air, away from the board and not inside a box with anything warm in it. That usually does more for the reading than any change to the sketch. When a well-placed DHT11 is still not precise enough, the DHT22 on the TK39 is the next step: DHT11 or DHT22.
When it does not work
Usually self-heating: the sensor is measuring what it is plugged into, not the room. A breadboard beside a voltage regulator or a USB socket runs warm. Move the TK38 away on three long jumper wires and give it a few minutes. Remember the DHT11's own ±2 °C before blaming anything else.
Same cause. Relative humidity is measured against what the air could hold at its temperature, so a sensor that is two degrees warmer than the room also reads the air several per cent drier than it is. Fix the temperature and the humidity follows.
That is the response time, and it is real. The datasheet gives 6 to 15 seconds for humidity to get two thirds of the way, in air moving at 1 m/s, and 6 to 30 seconds for temperature. In still air it is slower. Nothing in software speeds it up.
Check they are placed the same way first. If both hang in free air, ±2 °C each means up to four degrees of honest disagreement, and ±5 % RH each means up to ten per cent. That is the DHT11 working to its specification.
Five symptoms, and what each one narrows the fault down to.
When every reading is nan →Edit this page — content/books/dht11/how-slowly-it-catches-up.mdx
Questions about this product
See what other owners have asked, and read their solutions.
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.