Page 1 of 1

high value reading DHT22 temperature

Posted: Sun Nov 22, 2020 12:01 pm
by dlnl
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,

Re: high value reading DHT22 temperature

Posted: Sun Nov 22, 2020 12:38 pm
by Roberthh
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?

Re: high value reading DHT22 temperature

Posted: Sun Nov 22, 2020 1:04 pm
by dlnl
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,

Re: high value reading DHT22 temperature

Posted: Sun Nov 22, 2020 4:04 pm
by kevinkk525
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.

Re: high value reading DHT22 temperature

Posted: Thu Dec 03, 2020 5:11 pm
by dlnl
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.