Pi 3: Need Help Wiring & Coding Basic Double Inter-Lock Solenoid Valve System

Thread Starter


Joined Mar 27, 2017
I'm new here and also brand new to the Pi computer itself. I'm a very "tech-savvy" guy but when it comes to specifics about this guy I know nothing. Here is what I need to have in the end, any suggestions and or corrections are accepted!

Double inter-lock system- two solenoid valves, in line, v1 is 2ft before v2 in the system (vertically) and v2 is the end of the system, the last "device" in the system. {*The equals signs represent piping* (==<pressurized air system>==[V1]======[V2]=<discharge/ drain>)} v1 is normally open while v2 is normally closed, allowing a small qty of water to collect/ build (from condensation) on top of v2. So in order to drain off that water I need a code/ script/ program that will do the following (I understand that these will be "commands" to "fire" the solenoids but I'm just not sure how they'd be written):

close v1 until it's told to be opened, no duration (apply power as this valve is normally open (N/O))
open v2 until it's told to be closed (again apply power as this valve is normally closed (N/C))
close v2 after 15 seconds
re-open v1 and system is back as it began

I would really like to make this so that it was one execution that completed all those commands and then "finished" and closed itself. The ideal application would be being able to schedule when in time that execution would be told to run (ie. weekly, or "every sunday night at 9:00pm)

I need a power supply for the 12V valves but I have yet to look for one, maybe there is a well known one or maybe virtually any one could be spliced in for use, regardless I'm a bit lost on how to wire that in while keeping the pi safe. I understand that the Pi will send commands to the relay's telling them to (either open or close but I'm just going to say close for this instance) close thus closing the circuit on the open leg and supplying power to the valve so it can "complete the correct task" but any help on how to wire it safely will be great. I read somewhere to just splice the line size of the power going to the valve but I wasn't sure that that'd be the best bet.

My thoughts from my own experience with other electronics, logic, and a whole lot of Pi reading:
My idea behind using N/O and N/C solenoid valves respectively was to eliminate the Pi from having to (potentially, not sure if it'd even have to but reading made me think it could) supply constant power to the relay that's controlling that valve, so if it was closed normally I don't want to have to power it constantly just to keep it open.
I'm not certain if I will need a 4 or 2 relay setup for this since I'd like to use one normally open and one normally closed valve. From what I collected if I had just used normally closed valves I may have to have one relay for the "open" function of the valve and one for the "closed" one. Again, this may be wrong but I will gladly accept any insight offered! So in the end I'm thinking (could be wrong) that with the n/o and n/c valve that I'd have one relay to apply the power to either open the N/C valve or close the N/O one, thus only requiring 2 relays.
These are the valve's I've found and if they'll work then I wouldn't mind using them
and the relay (this is the 4 relay version though I understand I may only need 2, or I may need more than 4 though I can't see that being the case. Any insight helps!)

Thank you anyone, in advance, for any information you help me with. Please bare with me on the quotation's and (){}[]<> usage as I was only trying to differentiate parts I was especially unsure about or words that I was using that could be in the incorrect context or used incorrectly altogether.


Joined Jan 8, 2017
If you use a normally open and a normally closed valve then just connecting the coils in parallel would do what you need. (It should not matter that they both may be open for a few mS as they switch on and off.) A raspberry pi seems overkill for this application. I would think a plug in timer that powers a simple circuit that provides a 15 second pulse would do what you want. An NE555 timer could produce the 15 second pulse.