**This is an old revision of the document!**
Table of Contents
The document
am2302-en-aosong.pdf Although this information is factually correct, I found some of it difficult to understand due to the cumbersome translation into English. Page 5 provides an example of how to handle the data. Example 1 first shows the interpretation of temperatures above 0 °C and then, as a “special case” the representation of temperatures below 0 °C. Check it out there.
The reality
A strange DHT22 module
But then I was confused because the sensor I was using delivered something different. Near the freezing point of water, a value of around 4095 decimal was output.
chk 409,5 °C 99 %rel chk 409,5 °C 99 %rel chk 0,0 °C 99 %rel chk 0,0 °C 99 %rel chk 409,5 °C 99 %rel chk 409,5 °C 99 %rel chk 409,5 °C 99 %rel chk 409,5 °C 99 %rel ...
So, one-tenth of a degree below zero was represented as $FFF. And at lower temperatures, the result was something like 32626 °C, which is $7F72. In binary terms:
\ 7654321076543210 dm 32626 bn u. 111111101110010 OK.1
You can see that the MSB in the upper byte is 0, but all other bits are set. If you only take the lower byte, it's $72, which is &114. So, -11.4°C should be displayed here. However, this format didn't correspond to the specification in the datasheet. Instead, it resembled a 12-bit two's complement.
Using the logic analyzer, it was possible to verify that this was not a read error during the SDA bitbang, but that the read routine was actually working correctly.
The good modules
After purchasing additional DHT22 modules (am2302), it became clear that only one sensor was delivering these strange temperature values. Three others behaved as specified in the datasheet.
chk -3267,4 °C 56 %rel
The corresponding 40 bits read with PulsView were:
00000010 00100000 10000000 10101010 01001100
And this is then interpreted as follows:
\ 7654321076543210 0000001000100000 1000000010101010 01001100 0000001000100000 \ hum --> bn 0000001000100000 dm . 544 ok 1000000010101010 \ tmp --> bn 1000000010101010 dm . -32598 OK.1
So, what is meant is this:
bn 10101010 dm . 170 OK.1
In the source code, the Forth word .tmp
prepares the temperature measurement value.
When printed in formatted format, it will appear as -17,0 °C.