hi at all, I have 6 DHT22 sensors connected to 6 digital pins on my Arduino and I'm facing a strange problem: after a while the sensors stops responding me, and they return null temperature and humidity.
I'm using the 'DHT sensor library' by AdaFruit v1.4.3. The sensors are charged with 5V and they don't need the resistor or capacitor because it's already inside the sensor "board".
The code that I'm using for accessing to the data is in the end of the question. The problem, as said, is that after a while, the sensors stop to return the temperature and the humidity. In the example above I'm using an interval of 5 seconds between each consecutive read, but the problem persist even with slower time intervals.
Any suggestion about how to understand what is the problem? There is any way using the library to see what is the error?
Tx is and output, the DAT pin of the DHT is an output. It is never good to have 2 outputs connected together. What happens if one is LOW and the other is HIGH? It is called a short circuit. So yes, I think that it could be a problem. Maybe not the problem, but a problem.
After moving that sensor from pin 1, I think that the next thing that I would do is to reduce the wire length and use 10K pullups just to test.
Are you sure that the Pi is capable of supplying sufficient current for the Uno and sensors. The Uno alone needs about 50mA the sensors 1K pullups about 5 mA each + 2mA when each is measuring.
After moving that sensor from pin 1, I think that the next thing that I would do is to reduce the wire length and use 10K pullups just to test.
Ok, I will try this.
Are you sure that the Pi is capable of supplying sufficient current for the Uno and sensors. The Uno alone needs about 50mA the sensors 1K pullups about 5 mA each + 2mA when each is measuring.
Maybe I should try also to power supply the Arduino with an external charger.
I had problems too with DHT22 sensors failing randomly after hours or sometimes days. A workaround was to power the sensor from a digital output, and simply turn on the sensor for one reading, then off until next reading..
Then, I analyzed the data sent by the sensor, and there is a ~13 microseconds delay after every 8 data bits sent by the sensor. I verified it with multiple sensors that I had, all acting the same.
No DHT library - that I know of - take care of this delay (not mentioned in the datasheet). And, all these libraries wait ~1ms for the start signal, but the datasheet says "1-10ms", so IMO it's more 10ms than 1ms...
So I made my own DHT library, mainly changing this 1ms to something like 15ms, and added a delayMicroseconds(13) after every 8 bits of data received, and as far as I remember, it solved the problems...Until I replaced these crappy sensors with Bosch BME280..!
I was able to solve the problem by enabling and disabling the current to the sensors using a relè only when I needed to read the data. In this way the behaviour of the sensors remains stable through time.