User Tools

Site Tools


en:pfw:dht22tmpformat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:pfw:dht22tmpformat [2025-04-26 17:32] – [The reality] mkaen:pfw:dht22tmpformat [2025-04-27 13:39] (current) – [A Strange DHT22 Module] mka
Line 1: Line 1:
 {{pfw:full-banner.png?500 }} {{pfw:full-banner.png?500 }}
  
-====== The Document ======+====== The DHT22 Document ======
  
  
 [[https://wiki.forth-ev.de/lib/exe/fetch.php/pfw:am2302-en-aosong.pdf|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. [[https://wiki.forth-ev.de/lib/exe/fetch.php/pfw:am2302-en-aosong.pdf|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.+//Example 1// first shows the interpretation of temperatures above 0 °C and then, as a "special case" the representation of temperatures below 0 °C.((Looks like Sign and Magnitude: The most significant bit (MSB) is used to represent the sign of the number (0 for positive, 1 for negative). The remaining bits indicate the magnitude of the number.)) 
 + Check it out there.
  
 ====== The Reality ====== ====== The Reality ======
 +But then I was confused because the sensor I was using delivered something different. 
  
-===== A strange DHT22 module =====+===== 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. +Near the freezing point of water, a value of around 4095 decimal was output. 
  
 <code> <code>
Line 31: Line 33:
      
 You can see that the MSB in the upper byte is 0, but all other bits are set. 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 12-bit two's complement.+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 some 12-bit format.
  
 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. 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.
Line 37: Line 39:
 {{:en:pfw:dht22-0-unternull.png|Example of data output of the bad module below zero degrees}} {{:en:pfw:dht22-0-unternull.png|Example of data output of the bad module below zero degrees}}
  
 +There have been numerous questions online about the problem of a DHT22 module malfunctioning in sub-zero temperatures. But ultimately, there was no conclusive explanation as to what exactly is going wrong. I don't know what has to happen in the module itself for this error to occur. But it seems to me that you can program around it. However, that would mean rewriting the driver from a library. But now that we see what's causing it, it could also be done in C, right? Such a routine could also check whether this strange 12-bit representation is present and then display the temperature accordingly. These modules are supposed to be calibrated. Let's see...
 +:) 
  
-===== The good modules =====+ 
 +===== 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. 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.
Line 61: Line 66:
 </code> </code>
 In the source code, the Forth word ''.tmp'' prepares the temperature measurement value.\\ 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.+When printed formatted, it shows -17.0 °C.
  
 {{:en:pfw:dht22-2-frost1.png|Example of data output of a good module in the freezer}} {{:en:pfw:dht22-2-frost1.png|Example of data output of a good module in the freezer}}
en/pfw/dht22tmpformat.1745681545.txt.gz · Last modified: 2025-04-26 17:32 by mka