Adafruit_CircuitPython_DHT: DHT22 reports wrong negative temperatures

First off: it sounds like the bug which has been reported here: https://github.com/adafruit/Adafruit_CircuitPython_DHT/issues/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.

sudo pip3 install adafruit-circuitpython-dht
sudo apt-get install libgpiod2

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.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 21

Most upvoted comments

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:

import time
import board
import adafruit_dht

dhtDevice = adafruit_dht.DHT22(board.D6)
dhtDevice._trig_wait = 1500

temperature_c = dhtDevice.temperature
humidity = dhtDevice.humidity

try:
    if temperature_c < -1:
        temperature_c = round((temperature_c+3276.6)*(-1), 2)
    if (humidity != None) and (temperature_c != None) and (100 > temperature_c > -100):
        # do something with the correct temperature
        print(temperature_c, humidity)
    else:
        print("None value")
        
except RuntimeError as error:
            # Errors happen fairly often, DHT's are hard to read, just keep going
            print(error.args[0])
except Exception as error:
            dhtDevice.exit()
            raise error

This gives the correct output: -0.1 99.9 Yes, there is fog outside 😃