Once again, you have discovered the difficulty in "finding the needle in the haystack" problems that happen when code is written in this monolithic style.
All I can ask is, have you checked the hardware with a simple DHT library example?
aarg:
Once again, you have discovered the difficulty in "finding the needle in the haystack" problems that happen when code is written in this monolithic style.
All I can ask is, have you checked the hardware with a simple DHT library example?
Yes I have uploaded and checked the sensor using the tester example in the dht library and it reads fine with it and continues to do so for over an hour. where as with the code I uploaded it wont read humidity at all and if it does it goes nan for both temp and humidity randomly after a while.
Another thing to try, is to run the sketch with only the relay(s) disconnected, and see what happens. Sometimes a power glitch from that can cause weird problems.
How far from the control board is the DHT22 sensor? Try using screened cable, I use twin screened flex similar to stereo screened audio cable. Use the screen as ground (common -ve) and say red for +5v and white for DHT22 output signal. Could use a small decoupling capacitor, say 10uF across the supply to the sensor.
aarg:
Another thing to try, is to run the sketch with only the relay(s) disconnected, and see what happens. Sometimes a power glitch from that can cause weird problems.
I have a 12 volt to 5 volt converter and that plugs into the arduino through usb. Is it possible thats not giving the system enough juice? Between the sensor and the 8 channel relay board and 20 X 4 lcd screen? Maybe I should power those devices directly from the power supply vs the 5 volt pin on the board.
aarg:
Any results from the experiment in reply #3?
Are you talking about the decoupling capacitor idea? I will have to see if i have a capacitor to try. Is he saying between the 5v and ground near the dht22?
Okay so I now have an si7021 temp and humidity sensor hooked up and it uses I2C to communicate just like the lcd and the real time clock module does. It seems to work now but after an hour or so some times not always the lcd screen goes gibberish and a power cycle clears it up. What would cause that?
The arduino is powered through usb from the power supply and the lcd, relay board, temp and humidity sensor, and RTC is all powered from the power supply directly to keep it from robbing power from the arduino 5v pin. which would be hard on it.
What is the power supply? The 5V power on the Arduino comes from the USB port. So it sounds like you do have everything running from the same power source.
If I push the button that should turn the light on and off when the LCD screen is gibberish and frozen it wont turn the light on or off so that tells me the arduino is what it hanging up... meaning the code must be buggy or the power supply is crappy?
I get a random number beside the year when the humidity relay kicks on.