Connecting a relay to a solenoid valve through a 12v transformer

Sorry if the title doesn't describe much the question in here.

I have been reading about relays and I'm trying to understand how to connect a 12V power to a solenoid valve that will be activated through a relay (stay open if x happens stay close if y happens).

|404x500 Above is my diagram. I'm sorry not making it pretty but I couldn't make a better image since I'm not at a desktop.

I'm not sure if this diagram is correct.

Pretty much I have a transformer converting 220V to 12V that will connect the positive side of it to pin 4 of the Relay. The negative side of it will connect to the solenoid valve. At the relay the pin 6 will connect to the Solenoid Valve. Pin 1 will connect to digital pin 1 of the Arduino. Pin 2 will connect to ground of Arduino. Is this diagram correct to use? Did I learn well how does a relay works?

PS: Transformer at the image is not the actual transformer I'm using.

You indeed learned how a relay worked. Only thing you missed is you can't connect it directly to a Arduino. You need a transistor and a diode (and a resistor). Just google for "arduino relay" and you'll find it. A relay [u]module[/u] already has that on the board.

But, if the "transformer" is actually a DC power supply (like in the image) you could also take a beefier transistor (mosfet is preferred) and switch it direcly by replacing the relay by the solenoid. Google "arduino motor" and image the motor is a solenoid ;)

Thank your for your time septillion :)

Two questions: 1) I have the transformer and it says: AC Adapter. My Solenoid valve says "DC 12V". Is there any problem using this transformer to power up the valve?

2) The resistor value is always the same or do we have to calculate it? If we do how do we calculate the value of the resistor?

1) I don't have more details then what you tell me (I don't know which solenoid or transformer) so that would indeed mean you have a problem.

2) It's roughly the same. But it does depends on the type of transistor (BJT, MOSFET or darlington) what a suitable range is. And what a suitable type would be depends on the solenoid (if you want to connect the solenoid without relay) but a mosfet is the safest bet. And if you take a small, but of source big enough for the load, (logic level) mosfet you can do without a resistor.

And for a normal relay with a BJT a 1k resistor will do :)

This is the solenoid valve: https://www.boxelectronica.com/pt/electro-valvulas-valvulas/911-electrovalvula-12v-12-normalmente-fechada.html

The transformer says: AC ADAPTER Input 100 - 240 V / 50 - 60 hz / 0.5 MAX OUTPUT 12 v / 1.5A

Is there any problem? If there is why is there a problem? Sorry for all the questions but I'm trying to assemble this and for what I understood I will get have to buy a new transformer.

Does the AC adapter have a positive and negative wire out or are they unmarked? I would have expected to see it say OUTPUT 12 v DC / 1.5A or OUTPUT 12 v AC / 1.5A

If the transformer is AC and the spec of the solenoid say you need DC you have a problem :)

Although I'm still not sure the transformer is AC. And the solenoid is Chinese and is probably fine with AC but you need to test that (at the risk of killing the solenoid).

If its a DC power supply, it is not a transformer. Transformer is strictly ac-ac device.

But anyway if its a DC supply, whether you switch with a relay or MOSFET, you'll need a free-wheel diode across the solenoid valve to stop inductive spikes.

For AC a snubber network is used instead of a diode.

Grumpy_Mike: Does the AC adapter have a positive and negative wire out or are they unmarked? I would have expected to see it say OUTPUT 12 v DC / 1.5A or OUTPUT 12 v AC / 1.5A

Actually they are marked :o One of the wires has a dashed pattern and the other doesnt. I searched the internet trying to find something about hat and I came across this http://electronics.stackexchange.com/questions/39450/what-do-solid-striped-lines-on-a-wire-indicate which basically says that the dashed one is the positive. I would like to point out that it says "usually".

If it's not the correct transformer what you guys recommend me to buy to provide power to the solenoid valve? I'm a student so I'm always short on cash. The cheapest one would be great.

Thank you all for the answers and bearing with me :)

Only if there was a simple solution to test it....

Ow damn, there is! :o Stick a multimeter in it and see what you get in AC and in DC mode.

And for the cheapest "new" power supply, Macklemore sang about it, "Go thriftshopping!" ;)

septillion: Only if there was a simple solution to test it....

Ow damn, there is! :o Stick a multimeter in it and see what you get in AC and in DC mode.

And for the cheapest "new" power supply, Macklemore sang about it, "Go thriftshopping!" ;)

You are damn sure there is. The only problem is that I'll have to wait until school starts since I don't have a multimeter at home. In two weeks school starts and I'll be able to grab my hands at one to test it out. Until there the only thing that I can say is that I can't thank you guys enough for the help.

See ya guys. Stay out of the danger zone, party like there is no tomorrow and work hard :)

One of the wires has a dashed pattern and the other doesnt.

OK that is a DC output.

What you have is not called a transformer, although a transformer used to be a major component these days it is not in there at all.

which basically says that the dashed one is the positive

Yes but it doesn't do any harm to check. If you haven't got a meter to check it with then get one. They are less than $10 at a thrift shop.

Mm, I've had devices with a AC supply with dashed lines as well... And devices where the red wire was GND... So I don't believe hint like that anymore.

@brunofrancisco11, if you want to do more Arduino projects just buy a $5,- multi-meter. They may not be the best, not super accurate and not really suited for mains but in Arduino projects they give a damn good indication :)