I want to read sensor values from 4x AM2302 to an Arduino UNO, and then pass those values for data logging to Raspberry Pi via Serial communication over USB cable. The sensors are installed at 4x locations in an indoor plant growing system at difficult to access locations. In the same script is a program that runs HVAC fans and a water pump using timers and relays. The problem I encounter is that after working for several readings, eventually the AM2302 fails to read and continuously sends NaN value. If I intervene and power down/repower up, and also reupload the script, then the AM2302 begin reading again, but only for a few readings then fail again.
In the sample read-out table below, the 4x AM2302 sensor read-outs are sensor 1 : (HA01 - humidity, TA01 - temp) sensor 2 : (HA02, TA02) etc.. There is another read-out CT01 which is a DS18B20, which also fails after some-time and reports a value "no more address" which is reported as -127C by the Dallas Library.
I setup a breadboard and ran the same script with 2x AM2302 and no DS18B20 attached and was unable to replicate the problem.
I have chosen to use json string as a way to pass the readings from Arduino to Raspberry Pi, and notice that sometimes the string gets corrupted - in particular the date timestamp.
I would appreciate any help / tips on diagnostics ideas to pinpoint the issue.
Code for Arduino and Raspberry Pi is available on GitHub. https://github.com/footprintzero/plantlab
Updated info 2019/05/21 18:42 I re-ran the program with a modified script and so far the sensors are continuously sending a reading (AM2302).This modified script version has the HVAC control timers with the relays commented out in HVAC.ino at line 97. So its only reading the sensors and not controlling the relays.