Battery-powered irrigation controller
-
Just to share how the finished project looks like in the picture below. I'm powering it with 3 AA batteries (4.5v) since the solenoid valve would not trigger when below 3v. In the picture you can see on the right side the pro mini and the RFM69 radio, on the left the H-bridge module in red and a mini board with a voltage regulator to provide 3.3v to the arduino and the radio and a 1M/300K voltage divider to feed an arduino's analog pin. I have two valves connected to the H-bridge so I'm using 4 pins to control them (pulse on/pulse off for valve 1, pulse on/pulse off for valve 2). On the code side, with NodeManager (https://www.mysensors.org/download/node-manager) I have the following configuration:
nodeManager.setBatteryMin(3.2); nodeManager.setBatteryMax(4.6); nodeManager.setBatteryInternalVcc(false); nodeManager.setBatteryPin(A1); nodeManager.setBatteryVoltsPerBit(0.00459433); nodeManager.setSleep(SLEEP,1,MINUTES); // open valve 1 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,6); // close valve 1 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,7); // open valve 2 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,8); // close valve 2 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,9);The board sleeps for one minute, then reports back (with smart sleep of course) and the controller sends a SET message with payload 1 to the relevant child id to control the valves when instructed. On this side with myHouse (https://www.mysensors.org/controller/myhouse) I can activate it manually or schedule the duration of the irrigation for each zone.
Here's the pictures (as you can clearly see I'm really bad with hardware so I tend to wire everything up without soldering so I can reuse all the components if needed or, more likely, if the project fails :P):


-
Don't worry about the wire mess, it is normal when building a prototype (breadboards and jumper wires exist for a reason :) )
So the node every minute checks if any commands have been sent to switch on or off the valves, right? How much battery life are you getting? I guess it will depends on how much time the valves are on. In theory you could swap the AA batteries with a 18650 to save some space, right? -
Don't worry about the wire mess, it is normal when building a prototype (breadboards and jumper wires exist for a reason :) )
So the node every minute checks if any commands have been sent to switch on or off the valves, right? How much battery life are you getting? I guess it will depends on how much time the valves are on. In theory you could swap the AA batteries with a 18650 to save some space, right?@gohan that's correct, I'm using exactly the same principle in my boiler controller with the sensor checking in periodically for new commands since battery powered. I do expect a decent battery life since the valves I'm using are pulse-based so it doesn't matter for how long they stay on (as in my boiler controller I'm using a latching relay and since January moved from 3v to 2.75 now.). And yes, 18650 would be ideal for this project. Only concern with that battery is that when the solenoid triggers, it draws a lot of current and I'm not 100% sure a rechargeable battery is as good as a standard one to handle it.
-
as rule of thumb 18650 can deliver continuous 2C, so they could take a higher load for a brief moment (depends how long those valves take to open or close)
-
Oh didn't know that, I'll stay with the 3 AA batteries then for now since the box is in full sunshine and can become pretty hot during summer time at this latitude ;-) Thanks
-
That's an interesting project!
how are these valve working after almost a month of work?some bi-state valves have reputation of get stuck opened or closed. They are cheap enough to i like them if the don't get stuck :)And what about time to control the valvs. Are you requesting from gateway?
For power you can use a 4v or 5 v solar panel to charge 1 li-io cell with this charge regulators((https://cdn.instructables.com/FSH/L5F0/IO0G95Y5/FSHL5F0IO0G95Y5.MEDIUM.jpg?width=614)) if regular batteries have poor life, and of course you can hide battery box under a flat rock or a tile because sun heat.There are common 9v valves that are bi-state as well ,like the ones used on rain bird 9v programmers
my irrigation controller (24v Ac controlled by 5v Dc) its about to be presented here as well soon :) i'm finishing tests on attached sensors and stability tests and upload on emoncms.com
-
And about selenoids ,this is how i control them:

on arduino pwm pins you can define how much voltage you send to solenoid with "analogwrite" .
You can use any mosfet or transistor that can handle the 3.5v 1a(buy double or triple value of curente for safe) -
That's an interesting project!
how are these valve working after almost a month of work?some bi-state valves have reputation of get stuck opened or closed. They are cheap enough to i like them if the don't get stuck :)And what about time to control the valvs. Are you requesting from gateway?
For power you can use a 4v or 5 v solar panel to charge 1 li-io cell with this charge regulators((https://cdn.instructables.com/FSH/L5F0/IO0G95Y5/FSHL5F0IO0G95Y5.MEDIUM.jpg?width=614)) if regular batteries have poor life, and of course you can hide battery box under a flat rock or a tile because sun heat.There are common 9v valves that are bi-state as well ,like the ones used on rain bird 9v programmers
my irrigation controller (24v Ac controlled by 5v Dc) its about to be presented here as well soon :) i'm finishing tests on attached sensors and stability tests and upload on emoncms.com
@Tmaster actually I came real here just a few days ago so difficult to say right now. I did notice though a couple of situations in which the command was not executed (which is really annoying since having irrigation going for hours would create a lake :P) but I'm not sure if it is because of the valve or some missing messages from the radio (since quite away from the gw). I was also evaluating a bunch of "close" commands sent periodically by the controller to be sure the valve does not stay open forever but it is not very clean.
Yes, the open/close logic is in the controller which is sending out a turn on/off message during the scheduled timeframes (https://sourceforge.net/p/my-house/forum/general/thread/2d98b751/).
Thanks for the advise regarding the batteries. I'm noticing when the valve toggle a huuuge impact on the battery. After a few tests changed from 4.5v to 3.8v. If confirmed, I will be obliged to move to a rechargeable solution.
Do you have a link of those 9v valves you are using? Just to have a good backup solution in case my approach would somehow fail ;-)
Regarding the solenoid, I'm using the following to control it from the arduino: https://www.aliexpress.com/item/2-DC-motor-drive-module-reversing-PWM-speed-dual-H-bridge-stepper-motor-Mini-victory-L298N/32648692160.html and seems to work just fine.
Thanks -
i think that AA batteries hardly approach the 1A discharge if its your selenoid rate.
Another thing you can change is NEVER trust on a incoming signal to shutdown you valve. if power fails or signal is missing ,you selenoid will be open all life because gw never send the signal in time .what i did is: call time from GW , store it on irrigation node ,and then after time out(2 hours) it shuts off alone .in fact i don't have any code to control valves from gw . Gw only receive status for domotics. all time for valves On and Off its on the node.
See the timeaware sensor example to know how get time from gw and how handle it
you can just use for ex:
if(hour()==09) { //if its 9 hour AM TURN ON
digitalwrite (valve, HIGH)
}
if(hour()==10) { //if its 10 hour AM TURN OFF
digitalwrite (valve,LOW)
}Or on shutdown implement a "time out"timer (if millis have been passed turn off) like on "blink without delay" example
-
i think that AA batteries hardly approach the 1A discharge if its your selenoid rate.
Another thing you can change is NEVER trust on a incoming signal to shutdown you valve. if power fails or signal is missing ,you selenoid will be open all life because gw never send the signal in time .what i did is: call time from GW , store it on irrigation node ,and then after time out(2 hours) it shuts off alone .in fact i don't have any code to control valves from gw . Gw only receive status for domotics. all time for valves On and Off its on the node.
See the timeaware sensor example to know how get time from gw and how handle it
you can just use for ex:
if(hour()==09) { //if its 9 hour AM TURN ON
digitalwrite (valve, HIGH)
}
if(hour()==10) { //if its 10 hour AM TURN OFF
digitalwrite (valve,LOW)
}Or on shutdown implement a "time out"timer (if millis have been passed turn off) like on "blink without delay" example
@Tmaster that's a very good advice, especially if keeping it open for too long could create any damage. But I'd rather keep the logic on the controller otherwise I'd need to flash a new sketch on a weekly basis. The timeout approach would probably be more close to my requirements, even if millis() doesn't work for sleeping nodes, I can still work with the time as you suggested.
Another issue I'm experimenting with this valve is the loss of pressure, which is of course expected but it is so strong I cannot cover my garden correctly :-/ So an alternative I was evaluating is to hack my legacy irrigation controller which is very basic but I need to find a way to handle the rotary encoder. But on the same time I don't want to move away so soon from those valves ;-) -
the only desvantagem you have is ; not having main power there .Because if you have it you coud use standart 24v AC irrigation valves ,controlled by 5vDC as i did and then if power fails it just goes off, because they need current(+-200mha) for work. And they are cheap. the bi state 9v version cost more than 30€ and i never use it
-
the only desvantagem you have is ; not having main power there .Because if you have it you coud use standart 24v AC irrigation valves ,controlled by 5vDC as i did and then if power fails it just goes off, because they need current(+-200mha) for work. And they are cheap. the bi state 9v version cost more than 30€ and i never use it
@Tmaster that's my issue, I don't have power there so I was trying to find out a way to have this working with batteries. But regardless of the issues I'm experiencing, the idea to add an additional safe guard is definitely great, thanks again for the advice!
-
Just to share this pointer from a similar project: http://rayshobby.blogspot.it/2010/06/minty-water-valve-controller.html. It is actually way beyond my knowledge to understand all the steps but I guess could be useful for somebody here.
Changing valve and stepping up to 24v seems too complex for my requirements but adding a big capacitor could be something worth trying also here.
-
Yet another quick update on this. I think I was able to mitigate somehow the few issues I had:
- Regarding the abnormal battery consumption, I placed two 330uF capacitor between gnd and Vcc of the H-bridge powering the valve and they seem to help. After a few on and off the battery went from 4.70V to 4.68V so it was not affected at all. Not sure if it is a good idea or not but I thought could help the valve to be more gentle against the battery. I've also added a sleep of two seconds just after the digitalOutput pulse so to allow the board not to suffer of the voltage drop before sending the ack back to the controller (it was sometimes lost before).
- Regarding the pressure lost at the valve, I was able to gain this pressure somewhere else. First of all I bought new, high quality irrigation sprinklers and they cover with exactly the same pressure almost 50% more ground than the old one. Then I removed a few junctions which were losing additional pressure. Now at least it is usable since I have full coverage of the garden (about 100 square meters) with a single sprinkler.
- Regarding the safeguard, I've added a very simple timer to my sketch. When a valve is turned on, the time starts (it just counts the number of cycles to make it simple). If too many cycles have passed by and the valve is still on, turns it off automatically.
Bottom line, I was about to give up with this but now I'm back on track :)
-
@user2684 said in Battery-powered irrigation controller:
Regarding the abnormal battery consumption, I placed two 330uF capacitor between gnd and Vcc of the H-bridge powering the valve and they seem to help. After a few on and off the battery went from 4.70V to 4.68V so it was not affected at all. Not sure if it is a good idea or not but I thought could help the valve to be more gentle against the battery. I've also added a sleep of two seconds just after the digitalOutput pulse so to allow the board not to suffer of the voltage drop before sending the ack back to the controller (it was sometimes lost before).
AA bateries can't handle much current. You are feeding an solenoid (coil) that probably requires 1A for switch state and it drains too much from aa battery. Buy a 12v /7a battery from chinese brand for 10€ and use a voltage regulator from ebay and you have you problems gone.
-
@user2684 said in Battery-powered irrigation controller:
Regarding the abnormal battery consumption, I placed two 330uF capacitor between gnd and Vcc of the H-bridge powering the valve and they seem to help. After a few on and off the battery went from 4.70V to 4.68V so it was not affected at all. Not sure if it is a good idea or not but I thought could help the valve to be more gentle against the battery. I've also added a sleep of two seconds just after the digitalOutput pulse so to allow the board not to suffer of the voltage drop before sending the ack back to the controller (it was sometimes lost before).
AA bateries can't handle much current. You are feeding an solenoid (coil) that probably requires 1A for switch state and it drains too much from aa battery. Buy a 12v /7a battery from chinese brand for 10€ and use a voltage regulator from ebay and you have you problems gone.
-
Hi all, I just wan't to share with You my idea about controlling bi-stable solenoids (let it be valves or latching relay, doesn't matter). And I wonder why nowbody considering this solution. I'm talking about this kind of circuit http://www.avrfreaks.net/sites/default/files/Latching relay driver.jpg. And those two transistors that have to be controlled with two pins may be replaced with a push-pull driver like L293 (or L203DD which has built-in clamping diodes) which can be cotrolled with just one pin (HIGH - open; LOW - closed). This L293 will make the hardware interface the same as with monostable relays.
So pros are:- simple circuit (relay, capacitor, L293 IC and additional capacitor for power supply filtering)
- simple interface (use it like normal relay)
- safe - bi-stable solenoids have maximum pulse with, with this circuit there is no possibility to cross that requirement (the pulse width is defined by the RC constant of the capacitor and solenoid)
Cons are:
- the capacitor between relay and the ground has to be quite large about 1-2mF so its size is significant
- the l293 ic maybe not very cheap