I want to measure temperature and humidity with a DHT22 sensor on an Arduino DUE motherboard, as it is more accurate than the DHT11.
The measurement works well, but rarely unexpectedly measures invalid data: The temperature and humidity are exactly 25.5.
Until now, I operated from 3.3V, but I have already tried it with a 3.3V-5.5 level converter and the measurement did not become more stable.
I use DHT.h and the commands are:
"humdity = dht1.readHumidity();
temperature = dht1.readTemperature();"
Post complete code. One possibility for such values may be if you read the sensor too often (more than once every other second).
A DHT22 isn't made for high frequency measurements.
No no... I read the DHT22 every 2 minutes.
The reading part:
void MEASUREMENT() {
if (millis() - last_measurement_time > 120000) {
"humdity = dht1.readHumidity();
temperature = dht1.readTemperature();"
last_measurement_time = millis();
}
The last_measurement_time is long type.
It is very interesting that 25.5 is very similar to 255, which is the maximum value of 8 bits. Therefore, I would think that the program is not faulty (since it usually works well), but that some data is damaged when reading it.
Should I try DELAY when reading out?
That's right, it seems that in these cases the second and fourth byte of the transfer have only 1 bits while all other bits are 0. I first thought that the sensor might flag a problem with this but I couldn't find any documentation that would prove that. Maybe it's an undocumented feature, don't forget these sensors are quite cheap Chinese stuff, so don't expect everything to be documented.