I am a bit frustrated since I cannot understand why my relatively simple project does not work as I would like to.
The setup is an arduino uno rev 3 with an i2c rtc and i2c LCD display. Further I use a 8-relay (srd 05vdc slc)to switch some hci /hid electrical ballast.
The setup always works if the electrical ballast is not connected or if the arduino is powered by a laptop over USB.
However, if I power the arduino with the 9v DC power the arduino freezes very often when the electrical ballast is switched on. Most of the times it works for the first relay but freezes for the second. Sometimes only the LCD freezes and the arduino still switches on the second electrical ballast.
If I leave the USB cable plugged-in but not connected to the computer and have the 9v plugged-in as well, the arduino resets as soon as it switches the first relay. Removing the USB cable before switching solves that.
Since it works without load, I assume my sketch is ok.
I read about the relay's coil creating some current/voltage peak. Although the relay does already feature a diode to prevent this coming to the arduino I added another in different positions but this did not help. I also power the relay by a separate 6V DC power source to decouple the arduino and the relay.
I also bought a power socket from APC which should protect the DC power adapter powering the arduino from voltage peaks. Since it always works when powered via USB by a laptop I thought this might help.
Well, apparently it does not.
I will attach a drawing of my circuit diagram. If anybody has a suggestion, please let me know.
I understand you are using an 8-channel relay board (shield) to do your relay (and Ballast) switching. These relay boards are setup with diode protection on the relay coils so you should not need additional protection.
If I am reading your diagram correctly, you do not have a common ground between your breadboard/uno and the 8-channel relay board. You show 9V & 5V supplies separate, but they could be isolated supplies and therefore it could be that your relay board has NO GROUND REFERENCE for the digital drive signal coming in from the breadbaord. I see Vcc from the breadboard to the relay board connected but no ground. If this is the case, the ground is floating between the two boards. It may be close enough to work without your ballast load, BUT, ballasts are electrically very NOISY, and with a floating ground could cause issues and noise on that floating ground and could mess with your relay switching and even your aduino board itself.
I would suggest making sure you have good ground connections between all of your boards.
Also, if you have it working without a load, and then problems with your ballast load (heavy and noisy load), try an intermediate instead... like just an incandescent light for instance. Ballasts can raise hell with things. They are high voltage, and can develop high frequencies and all kinds of noise.