I'm working on a project that uses a 12v solenoid as well as relays and lights running at 5v. I purchased a 12v power supply to use for my project and I'm running into some issues. If I plug the power supply in while I'm plugged into USB everything works as expected and when I plug the USB cable the Arduino functions correctly as well. My issue is when I try to run solely on the power supply the Arduino stops executing the program and the relays will click on and off every few seconds. If I plug the USB in at this point this behavior stops and it works as it should. I have verified the power supply is putting out 12v consistently.
Do you have a reverse biased diode between Vin and ground. maybe voltage spikes from the relays are causing problems when you are feeding power to arduino that way. If we could see a diagram of your circuit it might help
Check your GNDs are connected and measure the 5V pin of the Arduino when it is acting funny. It could be that on-board regulator is getting pushed too hard and shutting down.
I think its about time you showed us a circuit diagram, it sounds like you have no power to the arduino at all when you disconnect the USB.
Have you checked that the board is being supplied when you have the USB unplugged.
Tom.
Here's my stab at a diagram. First time doing it some I'm not convinced I completely did it correctly. I'm using a 4-channel SanSmart Relay to control 110v Quad box and another stand alone relay to control the 12v solenoid.
I checked the 5v pin with the USB plugged in and it holds right at 4.7v. When I remove the USB the voltage moves to 4.92v and all the weirdness starts.
Four 5V relays taking maybe 70mA each when turned on, that's 280mA, plus about 50mA for the Arduino components is 330mA, times 7V voltage drop in the regulator is well over 2W power dissipation - which is more than the Arduino 5V regulator is designed for. It's probably going into thermal shutdown. If you are using a 12V supply then it makes far more sense to use a 12V relay board than a 5V one.
Where is the solenoid getting its supply, looks like its the arduino board.
This would cause an overload of the arduino regulator plus spikes from the solenoid coil.
Tom.
I wanted to give a quick update. I switched out the 4 port relay board for a 12v version and everything is working and stable now. Thank you for all of the help!