Arduino Resets when relay turns off

Hey guys.

I have a program that uses a digital pin to turn on a transistor, to ground a relay, to ground a solenoid, to turn water on to my plants. All of that works swimmingly except when the solenoid turns off.... It immediately restarts the program.

Here is the schematic: http://imgur.com/oV5FidB

Focusing on this part: http://imgur.com/NOlG0YR

Ignore the fan connection, I don't have that hooked up.

As for the rest of the board, I have 12v coming in that goes directly to the solenoid to power it when the ground is shorted. I have a 5v regulator that takes the power from the 12v port and powers and LCD screen, RTC (real time clock), arduino and SD card.

What I've tried doing.

Adding in a larger flyback diode (1N4004) thinking maybe the SMD one didn't get a good connection or I fried it trying to solder it on. No dice.

Adding in another capacitor (100uF) between 12V and GND. Maybe the solenoid turning off and the relay turning off draws too much power (IDK it was just a random thought) and its shutting the 5v regulator off? No dice.

Adding in another (100uF) capacitor between 5v and ground, trying to keep that 5v high so it stops resetting! No dice.

What am I doing wrong? Did I solder something wrong? The rest of the project works flawlessly (with the exception of my shitty power LED I fried the crap out of trying to solder on.

Extra Links:

Solenoid: 12V Solenoid Valve - 3/4" - ROB-10456 - SparkFun Electronics

Thank you for any help you can provide!

Is there a flyback diode across the solenoid? Schematic does not show one.

Due_unto:
Is there a flyback diode across the solenoid? Schematic does not show one.

D3 is a flyback Diode…

magruder13:
Adding in a larger flyback diode (1N4004) thinking maybe the SMD one didn’t get a good connection or I fried it trying to solder it on. No dice.

Did you read this part of my post?..

D3 is across the relay coil, where is the diode for the solenoid?

Due_unto:
D3 is across the relay coil, where is the diode for the solenoid?

oooohhhhhh I got you. Dont have one, brb gonna try it!

Due_unto:
D3 is across the relay coil, where is the diode for the solenoid?

Awww man you so smart. I could kiss you right now.

It works!

Why does it work though...

Looking at this image: https://upload.wikimedia.org/wikipedia/commons/7/76/FlybackExample.GIF

Keep in mind my circuit has the switch on the other side of the solenoid.

So I get that there is a large voltage gap once the circuit is disconnected, but the large negative voltage is connected to the open part of my circuit, so why would I care that there is a large negative charge somewhere that isn't connected to anything?

Please, NO! I hardly know you!
See in figure 2 how the open contacts now form a small gap that is jumped by the kickback? That is throwing all kinds of trash onto the 12 volt line as well as EMI interference. When that magnetic field collapses in the solenoid that energy has to go somewhere. If you don't recirculate it with a diode to dissipate it, it will go and look to make trouble for everything else in the neighborhood. :wink: