-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DHT22 reports wrong negative temperatures #60
Comments
@brlnr23 Hello,
|
I'm a bit confused by this discussion -- Adafruit_DHT is a deprecated library https://github.com/adafruit/Adafruit_Python_DHT and is not the same as Adafruit_CircuitPython_DHT https://github.com/adafruit/Adafruit_CircuitPython_DHT Adafruit_CircuitPython_DHT "should" handle negative temperatures properly for a DHT22. The DHT11 cannot measure negative temperatures. |
I am confused now as well .oO I would be happy to test and help, but I would need some more details how I could make use of the non-deprecated library. @jposada202020 , thanks for this snippet. It runs but unfortunately the current temp is - believe it or not - above 0 ;) Nevertheless I will closely monitor this and post updates if any. |
Hello, just to clarify:
Sorry for the confusion. And you are lucky @brlnr23 regarding the temp here today is -14 ;) |
@jposada202020, now I can confirm that the snippet does not work. As soon as it's below 0°C the values are way off :/ If the new library fixes this, I would be happy if someone could highlight how I can use the new library (ideally besides the old one which is used in separate other scripts) |
@brlnr23. You should try the simple test in the examples. https://github.com/adafruit/Adafruit_CircuitPython_DHT/blob/master/examples/dht_simpletest.py. This example use the new library. And as jerryneedell mentioned before it should be working for below 0 temperatures.. |
If you are using a Raspberry Pi, then you will have to also install the "Blinka" compatibility system as descried here https://learn.adafruit.com/circuitpython-on-raspberrypi-linux |
not sure what I am doing wrong, but I can't manage to get negative values :/ This is the script I used after installing blinka.
called from CLI via and this is the output I got just out of curiosity I ran the blinkatest.py which gave the following output
|
Do you still have the old adafruit_DHT library installed? Possibly some confusion... |
do you see at glance which are old and which are new modules? Possibly capital/lower
|
uninstall adafruit-DHT -- it is the deprecated library |
I just uninstalled it - now waiting for negative values ;) Thanks anyways so far for your support! I really appreciate it. |
Just FYI, I am doing some test on my side also with interesting results. I just do not want to spam this issue. if you want to further we can discuss the in the Adafruit Discord channel. Anyway, all this and reading through the current and past issues made me order some DHT22 :) to test. |
@brlnr23 I did my tests with the DHT22: This was with a RP4 running Buster with the Adafruit_Circuit_Python library. It is not perfect but this sensor will never be :)
|
@jposada202020 thanks for testing this on behalf! Two questions I have atm:
Two reasons I could imagine which might cause the fail is probably the missing resistor, or something got messed up with the old/new lib installation (which would require a clean Buster setup) |
FYI - This is typical of what I have seen with DHT22 sensors on RPi 4 as well. Errors are common. |
I did indeed use a new SD card. I just did not want to make my same mistake again :). Then I installed Buster, Installed Blinka, Installed the Adafruit-Circuitpython-dht, download the code. So fresh from the box installation. |
Good morning, long time listener, first time caller: I am also experiencing this issue with a DHT22. As soon as the temperature crosses 0C it becomes -3276.7C (-5866.1 F)
I am using import adafruit_dht module path: I really can't explain why this is happening. I have tried with and without 10k pullup resistor. Can anyone with a freezer check and see if it's just me? |
Hi everyone! I had this issue too. I just did some try&error testing and found out that with my python script I can add the wrong value at the actual -0.1˚C to the wrong number (ex: temperature_c+3276.6) and then multiply that with -1 to get the actual negative temperature. For this you have to get your reported value at -0.1˚C and write it down. Then go into your code and add it there as the correction value. I don't have an other DHT22 for testing but I'm not sure if every one has the same reported value at -0.1˚C. So be aware of that. Tested it for a week and compared it the an actual thermometer and it worked for me. There is my code:
This gives the correct output: |
It seems some DHT22 sensors act different at negative temperatures; my ones returns a twos compliment value. here's my patch for the actual 3.7.8
|
I solve the problem using this code in DHT.cpp file at the switch clause for DHT21 and DHT22 cases : case DHT22: if (data[2] & 0x08) { if (S) { As you can see, the data sended by the hardware has a length of 12 bits, not 16. Therefore, the negative value must be extended up to the remaining 4 bits. This worked for me. |
First off: it sounds like the bug which has been reported here: #9 but it happend to me with the latest version as well.
I have recently migrated from the old Adafruit lib to this one, because I hoped that the bug which occurred in the old lib as well has been fixed in the new one. Unfortunately it seems as if there is an issue with the new lib in my setup as well.
Unfortunately I am not really familiar which informtation I might need to provide for this bug report nor I have no clue what I could try next.
Therefore: any help is appreciated :)
Side note: the sensor I have in use does not require a pull up resistor - and I assume that this is correct - as said: all values except negative temperatures are pretty much accurate.
The text was updated successfully, but these errors were encountered: