Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Battery-powered irrigation controller

Battery-powered irrigation controller

Scheduled Pinned Locked Moved My Project
47 Posts 13 Posters 17.6k Views 14 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ionuI ionu

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

    U Offline
    U Offline
    user2684
    Contest Winner
    wrote on last edited by user2684
    #36

    @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:
    0_1528148437750_irrigation.png

    • 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
    #define MY_SMART_SLEEP_WAIT_DURATION_MS 1000
    #define MY_SPLASH_SCREEN_DISABLED
    
    /***********************************
     * NodeManager modules for supported sensors
     */
    
    #define USE_BATTERY
    #define USE_SIGNAL
    #define USE_CONFIGURATION
    #define USE_ANALOG_INPUT
    #define USE_DIGITAL_OUTPUT
    #define USE_INTERRUPT
    
    /***********************************
     * NodeManager built-in features
     */
    
    // Enable/disable NodeManager's features
    #define FEATURE_DEBUG ON
    #define FEATURE_POWER_MANAGER ON
    #define FEATURE_INTERRUPTS ON
    #define FEATURE_CONDITIONAL_REPORT OFF
    #define FEATURE_EEPROM OFF
    #define FEATURE_SLEEP ON
    #define FEATURE_RECEIVE ON
    #define FEATURE_TIME OFF
    #define FEATURE_RTC OFF
    #define FEATURE_SD OFF
    #define FEATURE_HOOKING ON
    
    /***********************************
     * 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) {
      valve.toggleStatus();
    }
    
    // before
    void before() {
      // setup the serial port baud rate
      Serial.begin(MY_BAUD_RATE);
      /*
      * Configure your sensors below
      */
    
      // battery sensor
      battery.setMinVoltage(3.2);
      battery.setMaxVoltage(4.6);
      battery.setBatteryInternalVcc(false);
      battery.setBatteryPin(A0);
      battery.setBatteryVoltsPerBit(0.00459433);
      battery.setReportIntervalMinutes(30);
    
      //signal sensor
      signal.setReportIntervalMinutes(30);
    
      // valve
      valve.setSafeguard(60);
      valve.setWaitAfterSet(2000);
      valve.setLegacyMode(true);
    
      // button
      button.setInterruptHook(&toggleValve);
      button.setInitialValue(HIGH);
      button.setInterruptMode(FALLING);
      button.setInvertValueToReport(true);
      node.setInterruptDebounce(1000);
      
      // rain sensor
      rain.setPowerManager(power);
      rain.setReportIntervalMinutes(10);
      rain.setRangeMin(300);
      rain.setReverse(true);
    
      // soil moisture sensor
      soil.setPowerManager(power);
      soil.setReportIntervalMinutes(10);
      soil.setRangeMin(500);
    
      // node configuration
      node.setSleepSeconds(60);
     
      /*
      * Configure your sensors above
      */
      node.before();
    }
    
    // presentation
    void presentation() {
      // call NodeManager presentation routine
      node.presentation();
    }
    
    // setup
    void setup() {
      // call NodeManager setup routine
      node.setup();
    }
    
    // loop
    void loop() {
      // call NodeManager loop routine
      node.loop();
    }
    
    #if FEATURE_RECEIVE == ON
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
      node.receive(message);
    }
    #endif
    
    #if FEATURE_TIME == ON
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine
      node.receiveTime(ts);
    }
    #endif
    

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

    1 Reply Last reply
    1
    • Andreas MenzelA Offline
      Andreas MenzelA Offline
      Andreas Menzel
      wrote on last edited by
      #37

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

      skywatchS U 2 Replies Last reply
      0
      • Andreas MenzelA Andreas Menzel

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

        skywatchS Offline
        skywatchS Offline
        skywatch
        wrote on last edited by skywatch
        #38

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

        1 Reply Last reply
        1
        • Andreas MenzelA Andreas Menzel

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

          U Offline
          U Offline
          user2684
          Contest Winner
          wrote on last edited by
          #39

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

          chamroeun ouC Andreas MenzelA C 3 Replies Last reply
          1
          • U user2684

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

            chamroeun ouC Offline
            chamroeun ouC Offline
            chamroeun ou
            wrote on last edited by
            #40

            @user2684 I am also planning to build latching valve controller. But my valve is 2" to 4" and Its coil specifications are as follow:
            V: 6-20Volt DC (optimal is above 9volt)
            Capacitance Required: 4700uF
            Coil inductance: 90mH
            Pulse duration: 20 to 200mili seconds.

            Do you think h-bridge will work or do you have a better suggestion for this? My goal is also to run the controller on battery and place in farm so it must be waterproof.

            skywatchS G 2 Replies Last reply
            0
            • U user2684

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

              Andreas MenzelA Offline
              Andreas MenzelA Offline
              Andreas Menzel
              wrote on last edited by
              #41

              @user2684 @skywatch thank you for your feedback! :)

              1 Reply Last reply
              0
              • chamroeun ouC chamroeun ou

                @user2684 I am also planning to build latching valve controller. But my valve is 2" to 4" and Its coil specifications are as follow:
                V: 6-20Volt DC (optimal is above 9volt)
                Capacitance Required: 4700uF
                Coil inductance: 90mH
                Pulse duration: 20 to 200mili seconds.

                Do you think h-bridge will work or do you have a better suggestion for this? My goal is also to run the controller on battery and place in farm so it must be waterproof.

                skywatchS Offline
                skywatchS Offline
                skywatch
                wrote on last edited by
                #42

                @chamroeun-ou If you need to reverse polarity then a H bridge would be good - I would aim for 12V (maybe a lead acid battery with solar panel and small charge controler). This assumes a coil pules reversal to change over the relay, if it is dual coil relay then it will be different, but we don't have that info. Also note the coil resistance and therefore current needed. A 6681FNG H bridge would be good as it is rated up to 15V and handles 1A with ease...

                1 Reply Last reply
                0
                • chamroeun ouC chamroeun ou

                  @user2684 I am also planning to build latching valve controller. But my valve is 2" to 4" and Its coil specifications are as follow:
                  V: 6-20Volt DC (optimal is above 9volt)
                  Capacitance Required: 4700uF
                  Coil inductance: 90mH
                  Pulse duration: 20 to 200mili seconds.

                  Do you think h-bridge will work or do you have a better suggestion for this? My goal is also to run the controller on battery and place in farm so it must be waterproof.

                  G Offline
                  G Offline
                  Gilles BILLARD
                  wrote on last edited by
                  #43

                  @chamroeun-ou said in Battery-powered irrigation controller:

                  @user2684 I am also planning to build latching valve controller. But my valve is 2" to 4" and Its coil specifications are as follow:
                  V: 6-20Volt DC (optimal is above 9volt)
                  Capacitance Required: 4700uF
                  Coil inductance: 90mH
                  Pulse duration: 20 to 200mili seconds.

                  Do you think h-bridge will work or do you have a better suggestion for this? My goal is also to run the controller on battery and place in farm so it must be waterproof.

                  HI,
                  I'm doing quite the same project at the moment; I ordered H bridge and also some flow detectors to check if the bistable valve is really in the desired position ( open not to see a desert, closed not to flood everything)
                  Powered by 1 solar panel + 9v batteries + load controler + step down converters for Arduino and radio.

                  1 Reply Last reply
                  0
                  • U user2684

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

                    C Offline
                    C Offline
                    ciaocibai
                    wrote on last edited by
                    #44

                    @user2684 I've just been tinkering on a project like this, so happy to find this and learn from you. Wondering if you've made any significant changes to your circuit and code that you could share so we can learn from your updated experience. How long at you getting from 3AA batteries typically? Love the project.

                    U 1 Reply Last reply
                    0
                    • C ciaocibai

                      @user2684 I've just been tinkering on a project like this, so happy to find this and learn from you. Wondering if you've made any significant changes to your circuit and code that you could share so we can learn from your updated experience. How long at you getting from 3AA batteries typically? Love the project.

                      U Offline
                      U Offline
                      user2684
                      Contest Winner
                      wrote on last edited by
                      #45

                      Hi @ciaocibai, no big changes to the code, maybe just MY_SMART_SLEEP_WAIT_DURATION_MS set to 1000 to ensure the valve is not impacting receiving/transmitting when triggering. All the rest is the same, just using the latest version of NodeManager. Ah, I also added a push button for turning irrigation on/off directly from the device.
                      Difficult to say regarding battery usage: since I've placed it far away I had to do some changes in the radio management piece which is draining battery considerably. With this setup 3 AA batteries last for around 2 months which is nothing but I believe this is mainly due to the radio settings.
                      Just for reference this is the latest version of the code:

                      
                      
                      /**********************************
                       * MySensors node configuration
                       */
                      
                      // General settings
                      #define SKETCH_NAME "Irrigation"
                      #define SKETCH_VERSION "3.2"
                      //#define MY_DEBUG
                      #define MY_NODE_ID 6
                      
                      // RFM69 radio settings
                      #define MY_RADIO_RFM69
                      #define MY_IS_RFM69HW
                      #define MY_RFM69_NEW_DRIVER
                      #define MY_RFM69_ATC_MODE_DISABLED
                      #define MY_RFM69_TX_POWER_DBM (10)
                      #define MY_RFM69_MAX_POWER_LEVEL_DBM (10)
                      
                      // Advanced settings
                      #define MY_BAUD_RATE 9600
                      #define MY_SMART_SLEEP_WAIT_DURATION_MS 1000
                      #define MY_SPLASH_SCREEN_DISABLED
                      #define MY_SIGNAL_REPORT_ENABLED
                      
                      /***********************************
                       * NodeManager configuration
                       */
                      
                      #define NODEMANAGER_DEBUG ON
                      #define NODEMANAGER_INTERRUPTS ON
                      #define NODEMANAGER_SLEEP ON
                      #define NODEMANAGER_RECEIVE ON
                      #define NODEMANAGER_DEBUG_VERBOSE OFF
                      #define NODEMANAGER_POWER_MANAGER OFF
                      #define NODEMANAGER_CONDITIONAL_REPORT OFF
                      #define NODEMANAGER_EEPROM OFF
                      #define NODEMANAGER_TIME OFF
                      #define NODEMANAGER_RTC OFF
                      #define NODEMANAGER_SD OFF
                      #define NODEMANAGER_HOOKING ON
                      #define NODEMANAGER_OTA_CONFIGURATION OFF
                      #define NODEMANAGER_SERIAL_INPUT OFF
                      
                      // import NodeManager library (a nodeManager object will be then made available)
                      #include <MySensors_NodeManager.h>
                      
                      /***********************************
                       * Add your sensors
                       */
                      
                      //PowerManager power(5,6);
                       
                      #include <sensors/SensorBattery.h>
                      SensorBattery battery;
                      
                      #include <sensors/SensorSignal.h>
                      SensorSignal signal;
                      
                      #include <sensors/SensorInterrupt.h>
                      SensorInterrupt button(3);
                      
                      #include <sensors/SensorLatchingRelay2Pins.h>
                      SensorLatchingRelay2Pins valve(5,6);
                      
                      /***********************************
                       * Main Sketch
                       */
                      
                      void toggleValve(Sensor* sensor) {
                        valve.toggleStatus();
                      }
                      
                      // before
                      void before() {
                      	
                        /***********************************
                         * Configure your sensors
                         */
                      
                        // battery sensor
                        battery.setMinVoltage(3.2);
                        battery.setMaxVoltage(4.6);
                        battery.setBatteryInternalVcc(false);
                        battery.setBatteryPin(A0);
                        battery.setBatteryVoltsPerBit(0.00459433);
                        battery.setReportIntervalMinutes(30);
                      
                        //signal sensor
                        signal.setReportIntervalMinutes(30);
                      
                        // button
                        button.setInterruptHook(&toggleValve);
                        button.setInterruptMode(FALLING);
                        button.setInvertValueToReport(true);
                        nodeManager.setInterruptDebounce(1000);
                      
                        // valve
                        valve.setSafeguard(120);
                        valve.setWaitAfterSet(2000);
                        valve.setLegacyMode(true);
                        valve.children.get(1)->setChildId(4);
                      
                        // node configuration
                        nodeManager.setSleepBetweenSendSleepOrWait(true);
                        nodeManager.setSleepSeconds(60*5);
                         
                        // call NodeManager before routine
                        nodeManager.before();
                      }
                      
                      // presentation
                      void presentation() {
                        // call NodeManager presentation routine
                        nodeManager.presentation();
                      }
                      
                      // setup
                      void setup() {
                        // call NodeManager setup routine
                        nodeManager.setup();
                      }
                      
                      // loop
                      void loop() {
                        // call NodeManager loop routine
                        nodeManager.loop();
                      }
                      
                      #if NODEMANAGER_RECEIVE == ON
                      // receive
                      void receive(const MyMessage &message) {
                        // call NodeManager receive routine
                        nodeManager.receive(message);
                      }
                      #endif
                      
                      #if NODEMANAGER_TIME == ON
                      // receiveTime
                      void receiveTime(unsigned long ts) {
                        // call NodeManager receiveTime routine
                        nodeManager.receiveTime(ts);
                      }
                      #endif
                      
                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        Gilles BILLARD
                        wrote on last edited by
                        #46

                        Hi,
                        I have already done all the same plus a flow control to check whether the valve is open or not and... it works perfectly.
                        ++

                        1 Reply Last reply
                        0
                        • I Offline
                          I Offline
                          Ivanli
                          Banned
                          wrote on last edited by
                          #47

                          Thanks for sharing the code, it would be nice to have a video demo.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          19

                          Online

                          11.7k

                          Users

                          11.2k

                          Topics

                          113.1k

                          Posts


                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • MySensors
                          • OpenHardware.io
                          • Categories
                          • Recent
                          • Tags
                          • Popular