Closed JordyVlassembrouck closed 4 years ago
This is likely, for some reason, the sensor is being read more than once per every two seconds, therefore it returns that "cached" value. It could be some issue in the library internals maybe.
I've validated the issue is present in both libraries, the old one and the new one. Old: https://github.com/adafruit/Adafruit_Python_DHT New: https://github.com/adafruit/Adafruit_CircuitPython_DHT
A good workaround is to perform a "warm up" call and then sleep for 2 or 3 seconds and call the sensor again to store the real data.
@JordyVlassembrouck The datasheet specifies that this sensor takes 2 seconds to collect a new reading or something along those lines, their wording wasn't very specific as to what exactly takes 2 seconds, but they were clear that you need to wait 2 seconds to get a new reading from the sensor.
Board Raspberry Pi 3 Model B v1.2
Sensor DHT22
Context I run a Python script which reads the temperature and humidity from my DHT22 sensor and stores it in a .csv file. The script is scheduled as a cronjob to run every 5 minutes.
Problem I noticed that the value returned by the DHT22 is the value it actually acquired when it took his previous reading. I know the DHT22 has a sampling rate of 0.5 Hz, which means it can only take a new reading every 2 seconds. I trigger the script myself and wait more than 2 seconds between runs, so this is not the issue.
My proof for this issue is the following scenario:
I suspect "reading" a value actually:
I also found a topic of 2 people with the same issue: http://forum.freetronics.com.au/viewtopic.php?f=15&t=6078&sid=a09aaf19f3fd51f2e25896949365c5d8