OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Water pump is shared between pool and sprinklers – manual pool filling?

Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • #36702

    Axel
    Participant

    Hi guys,

    The water pump will be shared between the swimming pool and the sprinkler system. I need to implement a manual switch that will allow the pool boy to fill the pool. This would turn on the pump and open the pool valve. How would I implement this using OSPI? Sorry if this is a noobie question but I’ve never implemented a sprinkler system before.

    Thanks in advance

    Axel

    #36714

    Axel
    Participant

    Hi, I’ve though about this and the switch should be sensed by OSPI, suspend the sprinkling cycle, close all the valves except the pool valve and turn on the water pump. Can this be configured? Is there any provision for inputs on the interface board or do I have to use the Pi’s GPIO ports?

    Thanks

    #36723

    mark
    Participant

    Simple question, complicated answer.  Yes, using the GPIO pins you could get the pi to know the pump is on manually.  Now what to do with that signal?  If you want all the zones to shut down, that’s one item you’d have to write/update in the python ospi service.  If you want to ‘suspend’ the zone, then pick up from where you left off, that’s way more complicated.  When a program starts, it writes the start and end times into variables.  You’ll have to start a separate timer from when the pool pump started to when it’s shut off, then go through those variables, add the time, then start the service as normal again.  Problems you’ll run into are what if a program hasn’t started yet, but does after pool boy is there?  What if one program has started (and is now suspended), then another one is set to start before pool boy is finished?  I’m sure there are other situations, but you get the point.  How would you update the logging for times the zones ran vs. suspended?  Yes, it can be done, but a you can start to see, it won’t be simple.

    Maybe an easier solution would be to make the pool it’s own zone.  I would expose a ‘Pool Fill’ button on a simple web page accessed on an internal ip (I’m assuming your pool boy has a smart phone).  That button click calls the webservice to stop all programs, then starts the ‘pool’ zone in manual mode.  Click the button again, and the zone is shut off.  Or just give the pool boy access to your sprinkler webpage.  Let him click into manual mode, stop anything that is currently running, start and stop the ‘pool’ zone manually.

    Good luck!

    #36724

    Axel
    Participant

    The pool boy does not have a smartphone.

    I want to connect an external on/off switch to a GPIO pin and sense the position of that switch.

    When detecting a “Switch transition to on” event, OSPI should stop all the active sprinkler cycles (shut down the water pump and close all valves) and start a “fill pool” cycle (open the pool valve and start the water pump).

    When detecting a “Switch transition to off” event, OSPI should end the “fill pool” cycle by turning the water pump off and close all the valves.

    When OSPI detects that a sprinkler cycle should start, it should check the current state of the switch and if it’s on, then the sprinkler cycle is not started.

    That makes sense to me, but I don’t know how hard it would be to code since I am a C/C++ programmer but I don’t know your framework.

    #36742

    mark
    Participant

    Not needing a ‘suspend’ function makes things a lot easier.  Ok, in ospi.py there is a call to ‘check_rain()’.  That operation lives in ‘helpers.py’.  Follow how that function sets the values for rain detected.  I’d start by coping that function, then mapping the signal to a different GPIO pin.  Then look at the ‘program_running’ if statement also in ospi.py.  That shuts down the zones if rain (or in your case now) your switch is tripped.  You’ll need to add a new ‘if’ path for your function when the switch is triggered so that you can start your custom zones and do <stuff>.  Of course this is a high overview, but following how that rain on/off works should get you started and close to your goal.

    #36759

    Axel
    Participant

    Could I use the rain sensor port instead of an RPi GPIO port? That would probably make it much easier for me.

    #36773

    Ray
    Keymaster

    You can use the rain sensor port for sure — a rain sensor itself is a switch (i.e. activated or deactivated by rain). You can connect a normal switch to rain sensor port, and when the switch is closed the OSPi will stop watering. However, the firmware currently does not support any ‘suspend’ function — if a program is supposed to run while the switch is on, the program run will be skipped and will not be kept in the queue. Hopefully the chances of your pool filling overlapping with sprinkler run are small.

    #38322

    Axel
    Participant

    Hi Ray,

    I’ve finally had time to play with OSPi. I am using it on an RPi2 since my old RPi1 doesn’t have a compatible GPIO socket. I’d really love to be able to use the RPi1 instead, but that’s something I’ll worry about later. Maybe I can use a custom ribbon cable to connect the GPIO pins.

    So anyways, I set it up on the latest official Raspbian from May 5th, got the wifi working and built the source from Git. It worked fine, the application is running and the web server is listening on 8080. Everything great, got it up and running in about half an hour. 🙂

    I copied the C++ source over to my Ubuntu laptop and installed Eclipse for C++. Looking at the code, it seems that all I need to do is to change main.cpp right after “if (os.old_status.rain_sensed != os.status.rain_sensed)” add something like (in pseudo-code):

    if( os.status.rain_sensed ){
    reset_all_stations();
    run_program(“fill_pool”);
    }else{
    stop_program(“fill_pool”);
    }

    I would define fill_pool as station 2 on, for 12 hours and connect my pool filling valve to station 2.

    Does this make sense?

    #38365

    Ray
    Keymaster

    Sure, it makes sense. You are right that this part of the code should be added in the ‘if (os.old_status.rain_sensed != os.status.rain_sensed)’ block because you want to make sure it only triggers the program once every time the rain sensor status changes.

    I am not sure how you plan to implement run_program() and stop_program() functions. There is a ‘manual_start_program’ that’s already implemented and you can certainly make use of it. Note that since programs usually come with specified water times, so once starting they will eventually stop after the specified water times have elapsed. Therefore I am not sure what ‘stop_program’ is really doing. Perhaps you meant calling reset_all_stations there?

    #38371

    Axel
    Participant

    Hi Ray,

    I have some more questions:
    1) I’ve ordered a 1.5″ Hunter PGV151, two 1″ Hunter PVG101 and a 220VAC-24VAC power brick. It should be arriving in the mail at the end of next week. Meanwhile, can I use 220VAC-12VDC power brick and a multimeter to test my code just to see if the stations are getting selected correctly?

    2) Will manual_run_program() immediately stop all the other currently running programs and switch to the chosen program?

    Thanks

    #38477

    Ray
    Keymaster

    1) If you use a DC power supply, you may see the effect that the valve will turn on but will not turn off. Because triacs (which is what OpenSprinkler uses to switch solenoids) are only meant to switch AC current, not DC current. However, if you have a small load (like an LED light or something) it should still be able to turn them off. For additional details, you can read about how triacs work to see why they are not meant for DC current.

    2) manual_run_program will indeed immediately stop all existing running programs. You can see that in the code of that function.

    #38504

    Axel
    Participant

    I received my valves and 24 VAC power supply yesterday and started coding today.

    My workaround is to define a disabled program called “Rain Sensor” that is run when the rain sensor goes from clear to set. This program will run station 2 for 12 hours which is approximately how long it takes to go from totally empty to totally full in my 80,000 liter swimming pool. This program stops due to 12h timeout or due to a rain sensor transition from set to clear.

    This works ok in my “lab” but I am a bit worried about the side effects of playing with the os.status.rain_sensed flag and calling reset_all_stations() which seems to clear the queue. Will this affect the schedule for the rest of the day? I plan to have ospi querying wunderground for rain info. Do you have any tips?

    Here’s the relevant code:

        ProgramStruct rainprog;
        if (os.old_status.rain_sensed != os.status.rain_sensed) {
          if (os.status.rain_sensed) {
            // rain sensor on, record time
            os.rainsense_start_time = curr_time;
    
            for( int rainpid=1;rainpid<255;++rainpid){
              pd.read(rainpid-1, &rainprog);
              if(strstr(rainprog.name,"Rain Sensor")){
                manual_start_program(rainpid);
                break;
              }
            }
          }else{
            // rain sensor off, write log
            write_log(LOGDATA_RAINSENSE, curr_time);
            reset_all_stations();
          }
          os.old_status.rain_sensed = os.status.rain_sensed;
        }
    

    I also noticed that if I stop the service using /etc/init.d/OpenSprinker.sh stop, the valves are left open. This will flood my garden. How do I stop this from happening? We probably need to use the RPi watchdog.

    #38536

    Ray
    Keymaster

    If your work around involved using ‘/etc/init.d/OpenSprinker.sh stop’ regularly, I don’t think it’s a safe solution, because as you noticed, this can leave valves open forever. Technically to solve this problem, when you stop the script from running it needs to send a signal to the firmware to tell it to turn off all open valves.

    Setting os.status.rain_sensed affects all stations that are influenced by rain sensor/rain delay, in that if rain_sensed is true, stations (unless if they are set to ‘ignore rain’) will stop running. Also any change to this flag will be logged as ‘rain sensor’ events.

    Calling reset_all_stations() will not affect future programs during the day. It merely resets all stations. If there is a program scheduled to run in the next minute, it will still run without any problem.

    #42555

    Axel
    Participant

    Well, it’s been more than a year since I bought my OSPI 1.4 and now it’s time to finally put it in production 🙂

    The water pump is 1.5HP 220 VAC and it is currently manually controlled via a contactor that has a simple on-off switch. We use this pump only to fill the pool and the installation will be modified to share it with the sprinkler system.

    I understand that I have to feed power to the contactor control pins to signal it to close the 220V feed and turn on the pump.

    How would I do that with an OSPI? Can I use the onboard relay somehow or do I need to add an external relay circuit (cheap US$ 5) and use GPIO +5V to control the relay?

    Could someone help?

    Thanks in advance
    Axel

    #42557

    Axel
    Participant
    #42645

    Axel
    Participant

    Bump… can someone help? @ray maybe.

    #42663

    Ray
    Keymaster

    If I understand it correctly, I think what you need is a pump start relay. A pump start relay (specifically, the coil pins) can be wired to OpenSprinkler like a normal sprinkler station. Then the contact pins can be wired to high voltage device, such as pump and 220V. If you search for pump start relay you should be able to find plenty of options.

    #42698

    Axel
    Participant

    @Ray, I currently have this contactor controlling my pump and would like to avoid having to buy a new device.

    http://uk.farnell.com/eaton-moeller/dilm12-10-110v50hz-120v60hz/relay-spst-no-690vac-12a/dp/1110422
    datasheet download http://www.farnell.com/datasheets/94707.pdf

    The product page says that the coil voltage is 24VAC. I guess this would work, right?

    #42733

    Ray
    Keymaster

    The coil voltage is 24VAC, and that’s compatible. However, I was also looking at the coil resistance, or at least coil current / power when it’s activated. If the coil draws too much current, it may exceed the OpenSprinkler limits. The datasheet has many items but it’s not clear which are the ones I am looking for…

    #43461

    Axel
    Participant

    Hi, I finished the installation and OSPI uses a GPIO pin wired to a Songle SRD-05DC-SL-C relay which toggles a 220VAC line wired to a contactor to turn the pump on/off. I would have done this differently if the installation were from scratch but I already had all the components in place, so I just had to add the 5 dollar relay.

    My issue now is that the pi’s Edimax EW-7811UN wifi range is horrible and it does not reach my access point. I am going to use a TP-Link AV500 Powerline kit to solve this problem. I can’t recommend these Powerline adapters enough. Three customers and two relatives are using them and they are fantastic. Just plug and play.

    I don’t feel comfortable opening my OSPI to the internet without SSL. Sniffing the OSPI admin password without SSL is trivial and it would give an attacker access to your sprinkler system and possibly to the RPI itself. OSPIi runs as root and my guess is that it would not be too difficult to used malformed HTTP requests to gain root access to the PI and then to my home network.

    #43500

    Ray
    Keymaster

    If the WiFi range is limited, an alternative is to consider adding a range extender:
    https://www.amazon.com/TP-LINK-Wi-Fi-Range-Extender-TL-WA850RE/dp/B00E98O7GC/

    #45115

    Axel
    Participant

    Problem solved with Unified Firmware 2.1.7:
    – Added an additional type of sensor: Program Switch. This allows the user to connect a switch / button to the sensor port and use it to trigger the first program (Program 1). An LCD icon (P1) will be displayed when this sensor is enabled.

    This means I do not need to patch the source code each time a new version is released.

    Thanks a lot!!

Viewing 22 posts - 1 through 22 (of 22 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Water pump is shared between pool and sprinklers – manual pool filling?