Arduino Forum

Using Arduino => Project Guidance => Topic started by: Digitidope on Jan 24, 2019, 12:56 am

Title: Water irrigation system - control three valves from one pin, how?
Post by: Digitidope on Jan 24, 2019, 12:56 am
Hello forum! I'm building a small automatic watering system on my balcony.

It will consist of two 12v water pumps and three valves, controlled by an arduino, a RTC and a WiFi controller. The valves and pumps will be powdered by solar panel and a 12v battery and the controller, WiFi and RTC by a 6v battery (also charged by solar).

There will be three valves attached to a small water tank somewhat above my plants in height. I want to open a valve when it's time to water the corresponding plant box and have the water drop down into the box by gravity.

I've found a solenoid direct valve that will open when given power and close (by spring or magnet or something) when power is turned off.

This could possibly be done with a relay on each valve, each relay connected to the 12v battery and to a separate pin on the arduino board.

Is there some way that one could control the three valves from one pin on the arduino?

Does there exist some kind of relay/transistor that can take let's say three different signals from the controller (for instance low, medium and high), and then relay the full 12v signal to the valve that correspond with that particular input signal?

This will be my first introduction in electronics/arduino project of any kind and that is why I am asking, to lean a bit more. I have spent many days now reading up on the basics of electronics and looking at arduino water systems online but I haven't figured out what device I could use here.

There is no wire diagram yet (haven't gotten to that part yet) but I hope the images of the planned circuit can be of help.

In advance thanks for any answer.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Delta_G on Jan 24, 2019, 01:15 am
OP's pictures:

(https://forum.arduino.cc/index.php?action=dlattach;topic=592785.0;attach=291512)


(https://forum.arduino.cc/index.php?action=dlattach;topic=592785.0;attach=291514)
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Digitidope on Jan 24, 2019, 01:16 am
Thank you Delta G!
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: jremington on Jan 24, 2019, 01:17 am
If the relay contacts can handle the current required by all three valves, just switch them in parallel. Check the relay specifications, or post links to the specs for the relay and the valves.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Delta_G on Jan 24, 2019, 01:18 am
Quote
Is there some way that one could control the three valves from one pin on the arduino?
sure, if you want all three valves to do the same thing.  


Quote
Does there exist some kind of relay/transistor that can take let's say three different signals from the controller (for instance low, medium and high), and then relay the full 12v signal to the valve that correspond with that particular input signal?
I can't even imagine how that would work.  But no, there's no such relay.  You could build one with three relays and a microcontroller, but then why not just do it with the microcontroller you have.  
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Digitidope on Jan 24, 2019, 01:21 am
https://www.ebay.com/itm/1-2-Gravity-Feed-Electric-Solenoid-Valve-12-volt-DDT-CD-12VDC-Plastic-Body-N-C/290763981675?_trkparms=aid%3D222007%26algo%3DSIM.MBE%26ao%3D1%26asc%3D20160323102634%26meid%3D4c1cef4b600540e7b1f85c985e7159d0%26pid%3D100623%26rk%3D4%26rkt%3D6%26mehot%3Dpp%26sd%3D300653378588%26itm%3D290763981675&_trksid=p2047675.c100623.m-1

The valve in question.

Haven't chosen relays yet.

Not quite sure what you mean, Jremington!

*i should have specified that I want the different valves to open and close at different times.

Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Delta_G on Jan 24, 2019, 01:23 am
Quote
Not quite sure what you mean, Jremington!
He is talking about if you want all three valves to come on together, then you just power them in parallel off the same relay.  But that doesn't sound like what you want.  It sounds like you want the valves to be individually controllable, in which case you're going to need three pins.


What is the point of this exercise?  Are you out of pins or something?  That is a much easier problem to solve. 
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: TomGeorge on Jan 24, 2019, 01:23 am
Hi,
Welcome to the Forum.

Why do you want to use one pin to control 3 valves independently.

You need to do a list of your input and output devices and set out what pins they will use to check your I/O numbers.
Do not forget that the analog input pins can be configured as digital I/O.

Thanks... Tom.... :)
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: larryd on Jan 24, 2019, 01:28 am
Forget about valves.

Use 3 bilge pumps like these.   6.7 x 5.0 x 1.3 in. more like 6.7 x 1.5x 1.3 in.

https://www.princessauto.com/en/detail/12v-200-gph-bilge-pump/A-p4270013e     (https://www.princessauto.com/en/detail/12v-200-gph-bilge-pump/A-p4270013e)

(https://www.princessauto.com/hlr-system/Thumbnails/42/427/4270/4270013.jpg)
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: MorganS on Jan 24, 2019, 01:29 am
You could definitely do that. Try Google to see if someone else has done it and if there is a module you can buy. That kind of multi-level control is very common in the steering-wheel controls on any car that has buttons in the wheel.

But it is highly likely that you won't find a module and the easiest way to build it is to use another Arduino. I suggest the Micro is easier to work with.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Digitidope on Jan 24, 2019, 01:32 am
Thanks Tom!

So something like this does not exist? https://imgur.com/a/BKlaibP

Haha, for no other reason than to see if it was possible. I'm really a beginner and I though that  the less pins I use the more pins I could use for later add'ons to this system. And it's fun to learn!

So the reason I could not find something like this is because it doesn't exist. Hmm I will have to live with using three pins and three relays then^^
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Digitidope on Jan 24, 2019, 01:40 am
I see Morgan! Will have to google some steering wheels.

Larry's, using this one: https://m.banggood.com/DC-12V-Solar-Powered-Water-Pump-700LH-Brushless-Magnetic-Submersible-Water-Pumps-p-1275049.html?utm_design=41&utm_source=emarsys&utm_medium=Shipoutinform171129&utm_campaign=trigger-emarsys&utm_content=Winna&sc_src=email_2671705&sc_eh=3767757c547288891&sc_llid=9773714&sc_lid=104858042&sc_uid=LqFr0QT0QQ

The reason for the tank #2 and the valves to gravity fed tube was is because I thought that this pump would pump water too strongly and damage the plants in doing so. But perhaps it can just be used at a lower voltage and hence simplifying the whole thing.

Hmm but would still need valves to direct the water to different places as I want control over the exact amount going into each plant box (overenthusiastic gardener).

Thanks for the replies.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: TomGeorge on Jan 24, 2019, 01:44 am
Hi,

If you had 4 or more outputs to control then there are multiplexer ICs to expand your I/O.
The condition is that they use 2 or 3 pins themselves.

Tom... :)
PS keep learning mate. 
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: MorganS on Jan 24, 2019, 01:46 am
An I2C port expander will use only 2 precious pins.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: bperrybap on Jan 24, 2019, 01:47 am
Quote
Is there some way that one could control the three valves from one pin on the arduino?
sure, if you want all three valves to do the same thing.  
Actually, there are several ways to control multiple things with a single wire but it takes more circuitry and potentially some clever s/w.

There is the standardized Modbus interface, but those devices are expensive.

It could be something custom like using analog voltages created from PWM signals, frequencies that are filtered using notch filters, or a simple serial (not async) interface that can be decoded using an RC network and a shift register.
I have used the latter to control a hd44780 LCD from an ATTiny part.

But all those are much more complex than just using multiple Arduino pins.

--- bill
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: bperrybap on Jan 24, 2019, 01:54 am
An I2C port expander will use only 2 precious pins.
And if using something like the PCF8574 i/o expander chip then each chip has 8 i/o pins and you can control up to 16 of those chips on the same bus.

You can even re-purpose the cheap ($1 USD) LCD backpacks that use the PCF8574 chip for this.

--- bill
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: larryd on Jan 24, 2019, 01:55 am
Those may work, not sure of the dimensions.

I have used the ones I linked.
You can easily adjust the pressure either by lowering the voltage or adding a Y connector tube.
One leg of the Y tube has an adjustable clamp to regulate that legs flow.
The other leg just returns it's water to the same reservoir the submersible pump sits in.
You can also feed the pump output into a trough that acts like manifold the length of the area to be watered thus reducing water pressure.

I'd stay away from valves and just use several inexpense simple pumps.


Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Digitidope on Jan 24, 2019, 02:01 am
That actually sounded really interesting bperrybap! I'll take notice, might come in handy some day, although perhaps a bit complicated for this one. Especially since it was so easy to expand the pin count on the arduino, didn't know that.

Larryd I think you might be right. As the distance from the small tank (#2) to the small balcony box furtherest away from it will be about 4-5 meters I'm not sure if gravity alone will be able to push the water all the way. Three small pumps would probably cost the same as one valve, thanks for the input.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Delta_G on Jan 24, 2019, 02:01 am
sure, if you want all three valves to do the same thing.  


Actually, there are several ways to control multiple things with a single wire but it takes more circuitry and potentially some clever s/w.

There is the standardized Modbus interface, but those devices are expensive.

It could be something custom like using analog voltages created from PWM signals, frequencies that are filtered using notch filters, or a simple serial (not async) interface that can be decoded using an RC network and a shift register.
I have used the latter to control a hd44780 LCD from an ATTiny part.

But all those are much more complex than just using multiple Arduino pins.

--- bill
Actually...


I went on to say in that post that you could conceivably create this with three relays, a uc, and some way to communicate from your first Arduino to the one with the relays.  But at that point, why not just run them from the first Arduino.

And it becomes a question of why do you want to do this.  If there is a real problem then there may be a real solution.  But this is an example of the x-y problem as it is.  
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: bperrybap on Jan 24, 2019, 02:06 am
Actually...


I went on to say in that post that you could conceivably create this with three relays, a uc, and some way to communicate from your first Arduino to the one with the relays.
And I did see that, but I was talking about solutions that didn't need another microcontroller on the other end.

--- bill
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Delta_G on Jan 24, 2019, 02:30 am
And I did see that, but I was talking about solutions that didn't need another microcontroller on the other end.

--- bill
How would you use modbus to control a valve without some controller to receive the modbus signal and physically switch the valve? 
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: bperrybap on Jan 24, 2019, 02:51 am
How would you use modbus to control a valve without some controller to receive the modbus signal and physically switch the valve? 
You can't, I guess I was a bit unclear.
I actually meant having to use another Arduino type micro-controller requiring programming on the receiver end since I was assuming using an off the shelf modbus relay/pump/device which has a microcontroller built into the device - which is why they are so expensive.

--- bill
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: Delta_G on Jan 24, 2019, 02:57 am
You can't, I guess I was a bit unclear.
I actually meant having to use another Arduino type micro-controller requiring programming on the receiver end since I was assuming using an off the shelf modbus relay/pump/device which has a microcontroller built into the device - which is why they are so expensive.

--- bill
Right.  That's what I said.  You'd have to have a controller on the other end to control the valves.  Or some seriously genius circuitry. 

Once you involve the second controller this becomes a trivial matter of choosing a communication protocol. 
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: wvmarle on Jan 24, 2019, 07:14 am
Hmm but would still need valves to direct the water to different places as I want control over the exact amount going into each plant box (overenthusiastic gardener).
Regular pumps give more exact control than valves (the flow of which is highly dependent of how much water there happens to be in your reservoir).

If you want really tight control look into peristaltic pumps. They're slow but very accurate.

Instead of relays, you can also switch your pumps with a MOSFET transistor. Smaller and more efficient than a relay. The IRLZ44N is a popular one to use with Arduinos.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: dave-in-nj on Jan 24, 2019, 01:04 pm
She cost of an Arduino is so cheap that normally we would not consider that you can easily control 10 valves on one pin.

If you have even seen a LED bar display that shows power level, like on a graphic equalizer, you know what I mean.
one LED or a different one, or a different one.....going up and down....

In any Arduino, the analog output pin can send out different levels of voltage.  

You can create a circuit (wish I had my Forrest Mimms book handy) that uses op-amps/comparators,  transistors, resistors and LED's on an analog signal to have one LED light at a time as the voltage changes.

power level circuit (http://www.circuit-finder.com/categories/audio/sound-level-meter/424/three-level-audio-power-indicator)
this shows how you can have each light come on at a voltage, but stay on. so two or three would be lit at at time.
you need a duplicate one that turns off as the voltage increases.  a window comparator circuit.

Most of us would user either an I2C port expander a Shift Register, or get a larger pin count Arduino board.

So, the answer is definitely YES.
Since you are asking, the ability for you to make the circuit is a bit of a steep learning curve, but not more than an advanced beginner level.

The cost will be much higher than buying a new Arduino.

The time to make one is much longer than to get a second UNO, or a MEGA and just use individual pins.

Since you can get a 16 pin port expander and run it on I2C from 2 pins,  there is a simple solution.
but if your goal is to learn about electronic circuits and you don't mind making circuit boards,  you can get to your goal that way too.
Title: Re: Water irrigation system - control three valves from one pin, how?
Post by: wvmarle on Jan 24, 2019, 01:15 pm
In any Arduino, the analog output pin can send out different levels of voltage.   
If only it had analog output pins... It only has a number of digital pins that can do PWM (using indeed the aptly named AnalogWrite() command).