I've created a sketch which waits for an HTTP GET request, and using the info in that request to toggle 4 relays on/off. I'm using an ATMega328 with the arduino bootloader on it, on a custom perfboard that is basically a boardduino. Connected to this is an official Ethernet shield. The Arduino is powered by an external 5vdc power supply, which is connected directly to the Arduino's VCC and gnd pins. There is also a 10uF cap between the power supply and Arduino (again, just like a boardduino setup). The analog pins on the arduino are used to control a 4 relay board from SainSmart (http://www.amazon.com/SainSmart-4-Channel-Relay-Module-Arduino/dp/B0057OC5O8).
On startup (in the setup() part) my code switches all the relays on/off 3 times. It then goes on to the loop() where it waits for a GET request and switches relays accordingly. For testing, I simply use a web browser to make requests to the Arduino. This works fine for anywhere from 2-10 calls, but at some point, the Arduino always resets. When it does, it will either a) go through the full setup() successfully and then start working again or b) get part way through the setup() (flash all relays 1-2 times) then reset again several times before finally making it through the full setup().
I thought this may be a power supply issue, so I have tried powering the Arduino with 5v from a benchtop power supply. Same results. I also tried using a scope to watch the voltage levels. I connected the probe to the positive leg of the capacitor on the board and the negative to gnd. This didn't show any power fluctuations either.
I've also include some debugging code in my Sketch to see if the arduino was running out of RAM, but this doesn't seem to be the case. Additionally, the Arduino will reset even if making the same GET request to it repeatedly, which means it is running through exactly the same code as when it is working.
My next steps is to recreate the setup on a breadboard (though, this is how the project started and it worked fine before) and see if it still resets. Any other ideas or troubleshooting ideas?
PS: My current sketch code is attached.
splunklight_working.ino (7.36 KB)