high value reading DHT22 temperature

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
dlnl
Posts: 4
Joined: Thu Oct 10, 2019 3:48 pm

high value reading DHT22 temperature

Post by dlnl » Sun Nov 22, 2020 12:01 pm

Hi,

I'm trying to read my DHT22 sensor (I think it's a DHT22) on my nodemcu ESP8266 board with micropython 1.13.

I use the following example code for DHT22:

Code: Select all

    import dht
    import machine
    d = dht.DHT22(machine.Pin(4))
    d.measure()
    print(d.temperature()) # eg. 23.6 (°C)
    print(d.humidity())    # eg. 41.3 (% RH)
I seem to get a response for the temperature in the range of 500-600.

However, when I use the DHT11 like this:

Code: Select all

d = dht.DHT11(machine.Pin(4))
I get a more sensible response like 22 (degrees C).

Does this mean I'm probably working with a DHT11 sensor, or do I need to apply some more formatting on the DHT22 value received to make more sense of the output?

Thank you in advance!

Best regards,

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: high value reading DHT22 temperature

Post by Roberthh » Sun Nov 22, 2020 12:38 pm

The code should work as it is. So if using the DHT11 code returns proper values, you probably have a DHT11 sensor (clone).
What about the humidity?

dlnl
Posts: 4
Joined: Thu Oct 10, 2019 3:48 pm

Re: high value reading DHT22 temperature

Post by dlnl » Sun Nov 22, 2020 1:04 pm

Yes, with Humidity it's the same. High values when printing d.humidity() for the DHT22, but (seemingly) correct values for DHT11.

So if it should work like the example code, then I will most likely have the dht11 sensor and not the dht22 sensor.

Thanks for the fast reply!

Best regards,

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: high value reading DHT22 temperature

Post by kevinkk525 » Sun Nov 22, 2020 4:04 pm

It might help to put a sleep of 1 second between measure() and temperature/humidity() because those sensor can take a while. But haven't used one of those in years, they are not very reliable and accurate.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

dlnl
Posts: 4
Joined: Thu Oct 10, 2019 3:48 pm

Re: high value reading DHT22 temperature

Post by dlnl » Thu Dec 03, 2020 5:11 pm

just for feedback and anyone else running into the same problem. I bought a new DHT22 sensor and ran the script again. This time I got the correct values. So I (unknowingly) was using a DHT11 before and therefore the DHT22 module did not work.

Post Reply