I am currently using a DHT11 sensor with the Adafruit library ( GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors ) and when I upload the example code for DHT11 to my ESP8266, I see in the serial monitor that the temperature contains decimals. However, I see everywhere on the internet, especially on some websites, on forums and in other libraries that DHT11 has a temperature resolution of 1°C and no 0.1°C, and with an accuracy of ±2°C (I agree on this last point). So I asked myself, if there was no error in the code.
So I took the DHT11 datasheet to find out if it could return a temperature with decimals. ( https://akizukidenshi.com/download/ds/aosong/DHT11.pdf )
There is no mention on any decimals except on the last byte (the checksum byte): (PDF page 5)
Parity bit data definition
“8bit humidity integer data + 8bit humidity decimal data +8 bit temperature integer data + 8bit temperature fractional data”8bit checksum is equal to the results of the last eight.
The datasheet also specifies that the temperature resolution is 16 bits (2 bytes). (PDF page 3).
So, I wanted to check myself if the DHT11 returns decimals. I took my oscilloscope and analyzed a DHT11 packet according to the datasheet:
Which verifies the serial data (last line):
So... The 4th byte returns data, interpreted by the library and basically showed by the datasheet as the first temperature decimal. Even if the accuracy is ±2°C, having a decimal makes it possible to better delimit the value of the actual temperature.
To wrap it up with this experience, can we say that DHT11 returns one decimal contrary to what everyone is saying? Do you have any information to add to these remarks?
Thanks in advance.