Dht22 NaN after some time

Hello guys,

my project aims to control a misting system in a terrarium. It should turn a relay on when humidity goes below 75%. The relay is connected to a pump. There is a display to show the current temperature and humidity values. The board is an original Leonardo.

My problem is that the DHT22 sensors shows NaN values. This problem does not occur always. The project sometimes runs for a couple of days before incurring in this issues. Sometimes it happens after few hours after I have fixed it.

Resetting the board does not fix the problem. I need to remove and reconnect the 3 wires connecting to DHT22 and the breadboard to have it working again.

Why do you think it happens? I was thinking that there is some condensation forming in the sensor giving it to fail, becase when I connect and disconnect the sensor it tells me humidity 99%. I have another sensor on the same board, but outiside the terrarium, and it does not give issues.

I tried already to replace the DHT22 with another one. It did not help.

Could you suggest an alternative sensor to measure humidity in a very humid environment? I placed the sensor quite far from the actual spraying noozles.

Thank you very much.

Francesco

P.S.: let me know if you like to give a look to the code, but since the other sensor is working and this issue does not happen from the beginning or with a recurrent timing, I do not think it is a code issue.

francescor:
My problem is that the DHT22 sensors shows NaN values. This problem does not occur always. The project sometimes runs for a couple of days before incurring in this issues. Sometimes it happens after few hours after I have fixed it.

Resetting the board does not fix the problem. I need to remove and reconnect the 3 wires connecting to DHT22 and the breadboard to have it working again.

Breadboard could be the problem. Try using soldered connections.

What do you mean with soldered connection? I need to attach the wires to the pins in the Arduino, how can I solder it directly to Arduino?. I can try to attach the pins directly to Arduino to skip the breadboards.

Thank you for your time.

Some Uno versions come with a separate row of holes which allow you to solder your wires on. The Nano and Pro Mini form factors are designed to have wires soldered on, easiest done when everything is mounted on some perfboard.

Or get a better humidity sensor. Most non-DHT sensors are better than the DHT sensors.

can you suggest a better humidity sensor?

BME280
SHT71

Thank you!