Battery-powered irrigation controller

  • Contest Winner

    Hi, this is still a work in progress but I wanted to share the approach I'm aiming to for a battery-powered irrigation controller in case can be useful to somebody else.

    Since I have no way to power a device in my garden, I cannot use neither an electrovalve nor a traditional relay controlling a valve (would drain the battery while staying on).

    I then found the following solenoid valves which works at a low voltage (3.6V) and requires just a pulse to switch (you may find the same also on amazon):

    The principle behind is to switch with positive/negative pulses which I've discovered means simply connecting the two wires to vcc and gnd to open and reverse the wires to close.

    All good but when I tried to control this with two arduino pins, there was no way to have it working and the reason simply is the solenoid requires a LOT of current (I've measured between 0.6 and 1A) which is of course way more than what the board the provide.

    After some googling I've discovered I needed a H-bridge ( to control programmatically the valve. I've tried building mine on a breadboard with different transistors/resistor but the valve didn't switch due to a massive voltage drop. Once gain due to the current draw.

    I then bought the following and everything looks working just fine:

    I still need to build the rest but this looks like the easy part since I just need to connect the arduino board to IN1 and IN2 and use simple HIGH pulse to open or close.


  • Mod

    can't you use a regular relay and a small solar panel to keep battery charged?

  • Contest Winner

    Using a solar panel can be for sure a good alternative but I wanted something without this requirement since where I have to put this I don't have a good exposure and I'm always afraid the battery cannot recharge in a good way.

  • Mod

    Is the node going to sleep?

  • Contest Winner

    Absolutely, otherwise cannot survive for long I'm afraid. I'll put it to sleep for e.g. 5-10 minutes and with smart sleep I'll send the on/off command when online, at least this is the plan

  • Hardware Contributor

    that's a cool project 👍
    I have built a device like this, batt operated custom board, but not finished sw and enclosure for the moment (too much projects). I'll use it in my garden soon as seedling has started too here.
    I also have solar charging option on my board.

  • Mod

    @user2684 can't you use like 4 relays to supply voltage with different polarity? 2 give pulse for opening and 2 give pulse to close. Maybe not as neat and tidy as the H Bridge but it may do the job without voltage drop.

  • Contest Winner

    @gohan you're right, a set of relays could definitely do the job, good alternative thanks for the advice!

  • Hardware Contributor

    @gohan - I'm struggling to determine why you would prefer to use 4 relays rather than a H-Bridge. If the device is a simple pulse activated device then i don't see any reason to use a relay over a H-Bridge. Is there a specific reason why you would and i'm not aware of that characteristic?

    Or am I not following your project plans properly?

  • Mod

    @Samuel235 it is in the first post where he is saying the H bridge didn't work
    @user2684 said in Battery-powered irrigation controller:

    After some googling I've discovered I needed a H-bridge ( to control programmatically the valve. I've tried building mine on a breadboard with different transistors/resistor but the valve didn't switch due to a massive voltage drop. Once gain due to the current draw.

  • Hardware Contributor

    In my circuit, I'm not using h-bridge nor relays and i can also control higher voltage solenoid valves like rainbird.. (i'll post my project later),
    but imho, I think the H-bridge should work, that depends on resistors values or the circuit was not optimized. 4 relays is a bit gorgeous maybe, but if it works, then it's the most important 🙂

  • Mod

    @scalz sometimes you've got to use what is available and 4 relays usually are laying around somewhere 😄

  • Hardware Contributor

    Well I brushed over that because i don't see how a H-Bridge wouldn't work due to high voltage drops. They use these ICs for motors and are fine with that and hence why I kind of brushed over that first point.

    I was thinking more in terms of a new product being made for people, relays wouldn't be the best option for a few reasons, one being cost. However, if its just a few products for yourself then its fine obviously 🙂

  • Contest Winner

    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 ( I have the following configuration:

      // open valve 1
      // close valve 1
      // open valve 2
      // close valve 2

    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 ( 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):



  • Mod

    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?

  • Contest Winner

    @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.

  • Mod

    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)

  • Contest Winner

    @gohan thanks good to know, I will give it a try, a 3 AA pack is actually using too much space!

  • Mod

    Remember that lithium batteries suffer heat, so put the box in shade 🙂

  • Contest Winner

    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(( 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

  • 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)

  • Contest Winner

    @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 (

    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: and seems to work just fine.

  • 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

  • Contest Winner

    @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

  • Mod

    Timeout is a nice safe feature, but also could be that if you loose connection to controller for more than X minutes it should shut everything down.

  • Contest Winner

    @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!

  • Contest Winner

    Just to share this pointer from a similar project: 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.

  • Contest Winner

    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.

  • Contest Winner

    @Tmaster thanks, I'll give it a try as well! regarding the voltage regulator, is there anything able to provide >1A as output as far as you know? Thanks

  • 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 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:

    1. simple circuit (relay, capacitor, L293 IC and additional capacitor for power supply filtering)
    2. simple interface (use it like normal relay)
    3. 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:

    1. the capacitor between relay and the ground has to be quite large about 1-2mF so its size is significant
    2. the l293 ic maybe not very cheap

  • Contest Winner

    Hi, just to spend a final word on this project. Despite the battery consumption is not that great (even if I believe by better sizing the capacitor the result would be much better), three AA battery lasted for more than two months powering the valve on and off twice a day and checking in with the controller every minute. I've changed the battery recently just because the valve operates at 3.6v and I was unsure there was enough power to still perform in a good shape for long. Below the battery discharging trend:


  • @user2684 How is your project going now? I am trying to use the same valves and diver board but I can not seem to get it to work. Could you answer some questions for me in order to help me get it to work.

    Am i right in saying that if I connect the power leads of the valve to a + source (Li 18650 4.1v 2500ma) it should open the valve and the if I reverse the the leads it should close the valve?

  • Contest Winner

    @ionu very sorry for missing your reply for more than 6 months but I didn't get any notification 😞 Your understanding is correct, if you just connect the + and - of the battery to the valve you should hear a "click" and if you reverse the wire, another "click". I wonder if that battery would be powerful enough, I've noticed that valve drains really a lot of current (>1A) when triggering. Try with AA batteries at first, just to check if the valve is functioning.

    My project has evolved over the time, let me share a picture below:

    • 1: is the amazing EasyPCB from @sundberg84 RFM69 version
    • 2: since the valve works at 3.7v I'm powering the project with 3 AA batteries. I've noticed the valve works just fine with 4.5v when full, till down to around 3v
    • 3: this is a step down regulator for providing 3.3v to the arduino and the radio. I've soldered it there on the EasyPCB (where a booster is supposed to be soldered) since I needed to use the voltage divider which is not available when using the voltage regulator spot. For this reason the battery is connected to the "<=3.3" plug
    • 4: this is the voltage divider for measuring the battery, since we have 4.5v I've coupled the 1M with a 300k
    • 5: this is the bi-stable valve. Can be found on amazon for 5 euros. Ships from china of course
    • 6: this is a 2200uF capacitor placed between the + and the - of the H bridge controlling the valve. Without it, the huge current drain would destroy the battery shortly
    • 7: this is an analog rain sensor. It is powered on by an arduino pin so to save battery while sleeping
    • 8: this is an analog soil moisture. It is powered on by an arduino pin so to save battery while sleeping
    • 9: this is a button to manually turn the valve on or off. It is connected to the arduino pin 3
    • 10: this is the H-bridge capable of controlling the valve since rated at 2A

    The code I'm using, based on NodeManager, is the following:

     * MySensors node configuration
    // General settings
    #define SKETCH_NAME "Irrigation"
    #define SKETCH_VERSION "2.0"
    #define MY_NODE_ID 6
    // RFM69 radio settings
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    #define MY_RFM69_NEW_DRIVER
    // Advanced settings
    #define MY_BAUD_RATE 9600
     * NodeManager modules for supported sensors
    #define USE_BATTERY
    #define USE_SIGNAL
    #define USE_ANALOG_INPUT
    #define USE_INTERRUPT
     * NodeManager built-in features
    // Enable/disable NodeManager's features
    #define FEATURE_DEBUG ON
    #define FEATURE_SLEEP ON
    #define FEATURE_TIME OFF
    #define FEATURE_RTC OFF
    #define FEATURE_SD OFF
     * Load NodeManager Library
    #include "NodeManagerLibrary.h"
    NodeManager node;
     * Add your sensors below
    // built-in sensors
    SensorBattery battery(node);
    SensorConfiguration configuration(node);
    SensorSignal signal(node);
    PowerManager power(-1,A1,300);
    // Attached sensors
    SensorRain rain(node,A4);
    SensorSoilMoisture soil(node,A5);
    SensorInterrupt button(node,3);
    SensorLatchingRelay2Pins valve(node,5,6);
     * Main Sketch
    void toggleValve(Sensor* sensor) {
    // before
    void before() {
      // setup the serial port baud rate
      * Configure your sensors below
      // battery sensor
      //signal sensor
      // valve
      // button
      // rain sensor
      // soil moisture sensor
      // node configuration
      * Configure your sensors above
    // presentation
    void presentation() {
      // call NodeManager presentation routine
    // setup
    void setup() {
      // call NodeManager setup routine
    // loop
    void loop() {
      // call NodeManager loop routine
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
    #if FEATURE_TIME == ON
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine

    Rain and soil moisture are connected to A4 and A5, reports every 10 minutes and are powered on just before taking the measure through pin A1. The button through the hooking function toggles the valve, when pressed. The valve (or better the H-bridge) is connected through pin 5 and 6 (off and on). The node wakes up every minute to pick up from the controller new orders (using smart sleep). There is also a safeguard of 60 minutes (if something goes wrong with the communication, irrigation is turned off regardless after 60 minutes).

  • @user2684 hi,
    Thank you for sharing your project here!!! I've been looking quite a long time until I found it 🙂

    I have a question regarding safety problem. In case the battery drops after opening below the voltage needed to close it again the water would not stop. Do you have an idea how to solve this problem?
    Or do you just replace the batteries "early" enough?

  • @Andreas-Menzel That is an old thread, but my thoughts would be to send battery level back often enough so you have time to change it, or better yet send battery level and add solar panel to recharge battery. A lot will depend on usage frequency, temperature, levels of sunlight etc...

    You could also add a flow sensor or pressure switch to alert you if the water does not turn off.

  • Contest Winner

    @Andreas-Menzel I personally tend to replace the batteries early enough. I also have at the controller level a couple of safety checks with are ensuring 1) the "close" message is acknowledged by the sensor and if not resend it again 2) a humidity sensor in the ground checking if it is still irrigating after e.g. 2-3 hours the valve is supposed to be closed.
    I've noticed if the battery is almost over and unable to close the valve once, it will likely succeed when retrying. Then of course batteries have to be changed.
    Over the years I've refined this old project over and over mainly making the capacitor bigger since the valve would otherwise drain so much current to dramatically shorten the battery's life. But this is still border line for the capability of a battery powered sensor I believe.

Log in to reply

Suggested Topics

  • 1
  • 3
  • 1
  • 1
  • 25
  • 1887
  • 6
  • 7