The simplest method to control 12V Solenoid N/C Valve ?

Is the below method (using a relay to control a NC Solenoid valve) is the simplest one to control the solenoid Valve ?

Sorry I missed the code :

digitalWrite(4, HIGH);

There are three changes I would make.

The relay should not be connected directly to the Arduino. Use a drive transistor to switch the relay.

A diode should be reverse connected across the relay coil. (cathode to +ve).

I would connect the relay contacts as NO and use the Arduino to turn the solenoid on rather than turning the solenoid off.

Weedpharma

You could make it easy for yourself and safe for your Arduino by using one of these. - Scotty

Solid state relay- easy to connect and mount, looks tidy and can be driven straight from Arduino with no external components.

Simple? Loose the relay

All you are doing is energizing acoil. Why not use only one?

Yes the solid state opto-isolated relay is the way to go. If you need more current you can use it to drive another relay or solenoid. I've been using a bunch of them.

I am curious why people are strong on the idea of the arduino charging one coil. and using that coil to control a second coil ?

is there some logic that I am missing ?

I know that it cannot be a power issue as the OP never listed data sheets for the solenoid and relay.

I accepted the OP design by default. The solenoid cannot be run direct from the output pin so needs some for of drive.

Weedpharma

weedpharma:
I accepted the OP design by default. The solenoid cannot be run direct from the output pin so needs some for of drive.

Weedpharma

gotcha.....
I think the OP was asking to make is simple..... not to 'fix' his schematic.
obviously, the fix is to add a FET/transistor to handle the power and not try to run the coil power from the pin.
but once you have added the FET/transistor, it appears that the relay is redundant.
IMHO, post #2 is spot-on. get the power off the pin, use an FET or some such and please ADD the diode !

weedpharma:
There are three changes I would make.

The relay should not be connected directly to the Arduino. Use a drive transistor to switch the relay.

A diode should be reverse connected across the relay coil. (cathode to +ve).

I would connect the relay contacts as NO and use the Arduino to turn the solenoid on rather than turning the solenoid off.

Weedpharma

Why the relay should not be connected directly to the Arduino, it is just to power the coil.

Dasaradh:
Why the relay should not be connected directly to the Arduino, it is just to power the coil.

Arduino pins can switch 20mA, and the absolute maximum is 40mA for a very short time.

A small 5volt relay needs 75mA. Four times the current a pin can provide.

A small transistor can switch 75mA, and only takes 4mA drive current from the Arduino pin.

You need a small NPN transistor, a 1k resistor and a 1N4004 diode.
Google "relay driver" for examples.
Leo..

Don't forget the reverse connected diode across the solenoid! Leave it out and you may damage your Arduino.

Weedpharma

the theory/logic is that when you charge a coil, it holds energy in a magnetic field. when you allow the coil to discharge, the magnetic field uses the coil to convert that field into an electrical pulse. this is then sent on the power lines as a voltage spike. we call this back EMF.

although the pulse is often very small, usually less than 20% of the voltage, every time there is a back EMF pulse you can loose part of the PN junction of the transistor that is driving it.

it is your choice if you want that to be a 10 cent transistor, or your Arduino.
that 10 cent transistor has about a million times the capacity of your Arduino, so may last forever.

the clamping diode will all but eliminate that problem and will stretch eons into millenia (or vice versa) on a cheap transistor.

=================

second reason is that today, you are using a coil (relay/solenoid) that you believe meets the design specifications that you found on the net, that were converted from Chinese that were probably copied from a Russian or US data sheet that was 20 year old.

and you find it works perfectly. then for any reason, you decide to change out the solenoid for a new one, or duplicate the project on another board, or some such, that second coil may not be made exactly like the first and may use more power.

with the transistor and diode, your current project has less risk and your future project also has less risk.