ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Controlling Solenoid valve with Raspberry Pi 3

Sat Jan 11, 2020 4:52 am

I am trying to control a Solenoid valve with A Raspberry Pi 3 B+ Can anyone link sites that can show how to do this or include diagrams of where to connect the GPiO pins and what to solder onto the Protoboard. Thanks.
Thanks.

drgeoff
Posts: 10230
Joined: Wed Jan 25, 2012 6:39 pm

Re: Controlling Solenoid valve with Raspberry Pi 3

Sat Jan 11, 2020 12:55 pm

Without details of the solenoid valve and protoboard you cannot expect specific advice. Possibly the solenoid will require more power (volts and/or current) than can be provided by a GPIO and will require additional circuitry.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sat Jan 11, 2020 2:28 pm

You may also need a separate power supply for the solenoid valve depending on what voltage it operates at , even if its 5V you might not be able to power it from the pi due to the current required.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

askDrAlex
Posts: 11
Joined: Sat Dec 21, 2019 12:23 am

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 12:42 am

In case your solenoid valve runs on line voltage (230V AC 50 Hz or 110V AC 60 Hz), you might think about the following circuit:

Image

A smaller value for C1 might be necessary, since otherwise, the valve might be permanently open.
With that circuit (even without C1 and R4), my Pi can meanwhile control the water inlet solenoid valve of a washing machine. For details, see my thread on the WashbearyPi project.

LTolledo
Posts: 2603
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 6:07 am

[GPIO --- transistor --- relay---solenoid] is my preferred method.

for the transistor ---relay circuit, there are lots of samples here....

get relay contact rating that is at least twice the amperage required by the solenoid.
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"


ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 11:41 am

drgeoff wrote:
Sat Jan 11, 2020 12:55 pm
Without details of the solenoid valve and protoboard, you cannot expect specific advice. Possibly the solenoid will require more power (volts and/or current) than can be provided by a GPIO and will require additional circuitry.
24V Solenoid valve and I have an external power supply.- https://www.hrproducts.com.au/products/ ... alve-mv75/
50x70mm prototype board.
Essentially I am trying to make this - https://www.circuito.io/app?components= ... 456,200000

Sorry for not being Specific, first time posting on the forums.
Thanks.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 12:10 pm

So the link valve is AC driven
Electrical Specifications:• Solenoid: 24volt AC, 50Hz• Inrush current: 0.5amp• Holding current: 0.33amp
Is this the exact valve you have ?
If so is your power supply also 24vAC output ?

If so the simplest option would be to use a relay to switch the AC volts for the solenoid valve.

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 1:17 pm

Can I follow this tutorial to control the solenoid valve?
https://www.instructables.com/id/Raspbe ... on-System/

I'm also trying to integrate a soil moisture sensor. Could I follow this to create the Protoboard?:
https://www.circuito.io/app?components= ... 322,200000

Thanks.
Thanks.

ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 1:21 pm

pcmanbob wrote:
Sun Jan 12, 2020 12:10 pm
So the link valve is AC driven
Electrical Specifications:• Solenoid: 24volt AC, 50Hz• Inrush current: 0.5amp• Holding current: 0.33amp
Is this the exact valve you have ?
If so is your power supply also 24vAC output ?

If so the simplest option would be to use a relay to switch the AC volts for the solenoid valve.

Image
Thanks for the reply.

Would I need a MOSFET?

Also, How could I integrate a Soil Moisture sensor?
Thanks.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 1:40 pm

No the 2n2222 is capable of switching a small relay with a 5V coil.

for example one of these

Image

Adding a Soil Moisture sensor to the pi depends upon the version you have, you would add it to the gpio and use software to link it to the relay operation.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 2:06 pm

pcmanbob wrote:
Sun Jan 12, 2020 1:40 pm
No the 2n2222 is capable of switching a small relay with a 5V coil.

for example one of these

Image

Adding a Soil Moisture sensor to the pi depends upon the version you have, you would add it to the gpio and use software to link it to the relay operation.
Could I just add the soil moisture sensore to my current configuration? Like does it overlap other GPIO headers?

I am getting this sensor: https://www.sparkfun.com/products/13637

Also what is the R470 on your diagram?
Thanks.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 2:23 pm

Resistor R470 is a 470 ohm 1/8w resistor.

I have no Idea how to connect that to a pi gpio as its designed to work with the Arduino, it looks to be some sort of serial device.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

emma1997
Posts: 511
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 7:51 pm

ThePiPeArtist wrote:
Sun Jan 12, 2020 1:21 pm
Would I need a MOSFET?
Strangely not that unusual to see a beginner bring up a better solution than the experts. :)

You don't 'need' a MOSFET as those classic BJT relay circuits do work (sort of). It's just old fashioned transistor is not the best solution for a variety of reasons (cost, component count, heat, EMF, EMI ). I just finished some tests this morning for another relay thread comparing NPN with FET and the latter demonstrated superiority in each area. Some significantly.

For DC applications I suspect a MOSFET may actually be the only component required unless extraordinary high voltages or other isolation issues are involved. For directly driving AC a triac (similar to back-to-back FETs) is best. I did manage to drive a 150a motor starter solenoid with just this:

Code: Select all

        d---solenoid---12v
GPIO---g
        s--gnd
Of course, as mentioned, the old method does work. For hobby sometimes busywork is desirable and cost/performance not always a factor for one-up. More than one way to skin a cat.

drgeoff
Posts: 10230
Joined: Wed Jan 25, 2012 6:39 pm

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 9:53 pm

If a FET is up to it, FET and bridge rectifier. No relay. Solenoid in AC side of bridge. FET and RPi "inside" bridge.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 10:00 pm

drgeoff wrote:
Sun Jan 12, 2020 9:53 pm
If a FET is up to it, FET and bridge rectifier. No relay. Solenoid in AC side of bridge. FET and RPi "inside" bridge.
How will that drive a solenoid valve that states it has an AC driven coil , from an AC power supply
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

emma1997
Posts: 511
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 10:12 pm

In most cases an AC coil does work fine off DC. Versa vice not so much.

drgeoff
Posts: 10230
Joined: Wed Jan 25, 2012 6:39 pm

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 10:18 pm

pcmanbob wrote:
Sun Jan 12, 2020 10:00 pm
drgeoff wrote:
Sun Jan 12, 2020 9:53 pm
If a FET is up to it, FET and bridge rectifier. No relay. Solenoid in AC side of bridge. FET and RPi "inside" bridge.
How will that drive a solenoid valve that states it has an AC driven coil , from an AC power supply
@pcmanbob
Don't you understand a bridge rectifier? AC current in, DC current out. The solenoid is between the transformer and the bridge rectifier.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 10:25 pm

We don't want any DC coil is AC 50 Hz 24v and power supply is 24V AC 50 Hz.

were does the DC come in to it ?

how are you going to switch AC voltage using a bridge rectifier ?

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

drgeoff
Posts: 10230
Joined: Wed Jan 25, 2012 6:39 pm

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 10:34 pm

@pcmanbob

I now see that your understanding is much less than I previously gave you credit for.

Do you know what a bridge rectifier is?

Think of a power supply with mains transformer, fuse on the secondary. Bridge rectifier. Smoothing capacitor between + and - outputs of the bridge.

Replace the fuse with the solenoid. Replace the smoothing capacitor with the FET. Alternating current through the solenoid. Unidirectional current through the FET when it is switched on.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Controlling Solenoid valve with Raspberry Pi 3

Sun Jan 12, 2020 11:05 pm

Yes see what you are proposing now .

my excuse is its late and I have had several pints of cider :oops: :lol:
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Re: Controlling Solenoid valve with Raspberry Pi 3

Mon Jan 13, 2020 12:13 am

drgeoff wrote:
Sun Jan 12, 2020 9:53 pm
If a FET is up to it, FET and bridge rectifier. No relay. Solenoid in AC side of bridge. FET and RPi "inside" bridge.
Sorry for my primitive understanding, can you please include a diagram or something like a fritzing, also where could I integrate a soil moisture sensor?
Thanks for all the help.
Thanks.

drgeoff
Posts: 10230
Joined: Wed Jan 25, 2012 6:39 pm

Re: Controlling Solenoid valve with Raspberry Pi 3

Mon Jan 13, 2020 12:47 am

FET symbol probably non standard.
Attachments
CCI_000010.png
CCI_000010.png (11.32 KiB) Viewed 819 times

LTolledo
Posts: 2603
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Controlling Solenoid valve with Raspberry Pi 3

Mon Jan 13, 2020 2:27 am

the thought of the FET malfunctioning and inadvertently connecting the AC line to the RPi's GPIO line is quite horrifying.....
... and might produce some "spectacular results" ( most of us know what that means ) :mrgreen:
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

ThePiPeArtist
Posts: 18
Joined: Sun Jan 05, 2020 12:32 pm
Location: Australia

Re: Controlling Solenoid valve with Raspberry Pi 3

Mon Jan 13, 2020 3:42 am

drgeoff wrote:
Mon Jan 13, 2020 12:47 am
FET symbol probably non standard.
Could you include names of the resistors, diodes etc.
Also an explanation would be nice.

To my understanding the FET is the centre tapped transformer right?
Last edited by ThePiPeArtist on Mon Jan 13, 2020 9:35 am, edited 1 time in total.
Thanks.

Return to “Automation, sensing and robotics”