more G-Labs products

Author Topic: Garden Sprinkler System App  (Read 15064 times)

January 01, 2015, 05:45:23 AM
Read 15064 times

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
This is my first attempt on writing an app for HomeGenie.

I borrowed some of the code of the Security Alarm System during the learning process, which was very helpful for me.
Code may still have room for improvement, suggestions are welcome.

As per the subject title of this post, this app is a Garden Sprinkler System controller. The app provides the logic to run the sprinkler system on a Cron based time schedule, the number of groups to activate and the sprinkler time. This needs to run on a Raspberry Pi, the app is configured for the GPIO pins of the Raspberry Pi B+, but with a little change of the code it can be made to work on the Raspberry Pi A or B.

This app has an dependency on the Raspberry Pi B+ modified version of the "GPIO Modules" (1000-GPIO_Modules.hgx) for centralized GPIO pin management.

The following attached files need to be installed on your Raspberry Pi:
=============
1000-GPIO_Modules.hgx  |  GPIO management
1008-Garden_Sprinkler_System.hgx  |  The Sprinkler App
Guytpetj.zip  |  The Widget files for this App - copy the content of the zip file to: /usr/local/bin/homegenie/html/pages/control/widgets/


The second part of the Garden Sprinkler System, the relay module for driving the sprinkler solenoids, requires some handy work and soldering.

Hardware needs:
=============
1 x LED
1 x 220 or 330K Resistor
6 x 1K resistor
6 x NPN transistor 2N3904
1 x Prototype board (http://www.amazon.com/gp/product/B00N1X5CM4/ref=ox_sc_sfl_title_2?ie=UTF8&psc=1&smid=A325CF4XAXVINN)
1 x 8 Relay Module Board (http://www.amazon.com/gp/product/B00C8O9KHA/ref=oh_aui_detailpage_o06_s01?ie=UTF8&psc=1)
some wire and connectors


The attached ScreenShot.jpg file shows how I have my Sprinkler System group configured. The App is in the top left. In addition I configured a switch for each sprinkler group for the odd time that you manually want to run a group.


Have fun playing with this.

Peter
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

January 01, 2015, 10:45:44 AM
Reply #1

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
This is great, I've been wanting to set up something like this in my garden. Which Water Solenoid Valve do you recommend?

January 01, 2015, 07:32:29 PM
Reply #2

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
It's depending on what you get in the Netherlands.

I've cut my Dutch roots 17 years ago and line in the USA now. Spreek nog wel Nederlands, dat vergeet je niet.

I have Orbit solenoids in my system. the sprinkler/irrigation system came with the house when I bought it.
http://www.amazon.com/Orbit-57100-4-Inch-Threaded-Sprinkler/dp/B00004S1V2/ref=sr_1_4?ie=UTF8&qid=1420135414&sr=8-4&keywords=sprinkler+solenoid

Just make sure you get what ever is the standard for where you live. For me in the USA the standard for sprinkler solenoids is a 24 volt AC system. Sticking to the standard means you have the choice of using an of the shelve controller or build one your self like i did once I discovered the unique power of HomeGenie and the Raspberry Pi.

So to make the garden part of the sprinkler system work work you need the following:
========================
24 VAC, 1 Amp minimum, power supply/transformer
Solenoids (as many as you need, for this app not exceeding 6, or with a bit of programming 8 max)

Peter

4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

February 17, 2015, 11:04:37 PM
Reply #3

igorrobertifoc

  • ***
  • Information
  • Full Member
  • Posts: 65
Hello, very well.
I would like to command a sprinkler with zwave.. all with battery because i dont have the Electric on garden.. Do you think is impossible?


February 18, 2015, 04:04:44 PM
Reply #4

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Sprinklers work on 24V typically (in the US anyway).  I do not know if the valve needs a constant 24V to hold the valve open or if it sends a signal to open and then another to close.  If they work with the latter, you might be able to use a large 24V battery that would need to be charged periodically or via a solar panel.

Just a quick search on google and I located a solar powered timer:
http://www.homedepot.com/p/DIG-Solar-Powered-Irrigation-Timer-with-Anti-Siphon-Valve-ECO1ASV-075/203766359

I know nothing about it, but it claims to work without any power other than ambient light.  I imagine you could find something similar and modify it to add a control wire.  There might even be one available that is solar powered and has control wires, though I doubt it.  Control wires run from a controller which requires power.  If you can run control wires, you can run power as well.  So, I think you are likely on your own here.

EDIT:  Well, I take that back!  Hunter makes a sprinkler that might be directly usable for you.  It looks like it even has wireless control via a tablet.

http://www.hunterindustries.com/irrigation-product/sensors/solar-syncr

If Hunter makes one, perhaps Rainbird and others do as well...
« Last Edit: February 18, 2015, 04:06:44 PM by bkenobi »

February 20, 2015, 05:34:57 AM
Reply #5

lv2roc

  • *
  • Information
  • Newbie
  • Posts: 17
Newbie trying to install this "plugin".
I have imported the 1000-GPIO_Modules.hgx in my RASPBERRY PI under Automation and Programs. (circle is green)
Created Sprinklers under Automation and Programs.
Imported 1008-Garden_Sprinkler_System.hgx in my newly created Sprinklers. (circle is green)

Extracted zip file and put the contents in the /usr/local/bin/homegenie/html/pages/control/widgets/ folder.
In Groups and Modules I added the Garden Sprinkler System under the Dashboard.
Restarted HomeGenie.

Still no widgets are displayed like the picture you posted. What am I missing?

I will play with it but like I said I am a newbie and maybe someone else is wondering too.
« Last Edit: February 20, 2015, 05:38:10 AM by lv2roc »

February 20, 2015, 07:13:00 PM
Reply #6

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
Will have to post an update. there was a change in HG where a file extension changed from .json to .js

renaming the .json extension to .js should fix it. The file is in the zip file you had to copy.
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

February 21, 2015, 12:11:50 AM
Reply #7

lv2roc

  • *
  • Information
  • Newbie
  • Posts: 17
Perfect! that did it.

Question though...Can you schedule "zones" or "Sprinkler groups" at different times?
Ex.

Every 2 day turn on at 9:00am Zone 1, then 11:00am Zone 2.
Every day turn Zone 3  at 5:00pm

Will the app do that?
Again just a newbie here and my initial look at the interface looks like you set up the Cron with 1 start time.

Looks to be a great app, just trying to get figure out its full potential.

February 21, 2015, 02:52:50 AM
Reply #8

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
you can make the program do this by extending the pause time between zones

Setup option:
01. Sprinkler Schedule (Cron) [* * * * *]
=== if you make this: 00 09 1-31/2 * * (starts at 09:00 every other day on odd days)

02. Sprinkler Pause Between Groups Time in Seconds
=== if you make this: 6300 (6300 seconds  = 1 hr and 45 min)

03. Sprinkler Active Time in Seconds (600 = 10 minutes)
=== if you make this: 900 (900 seconds is 15 min)


Based on the above, the program will start every 2 days at 09:00, run till 09:15 and then goes in pause till 11:00 to start the next group. It will continue this cycle for the number of groups you activated.

CRON:
# Will only run on odd days:
0 0 1-31/2 * * command

# Will only run on even days:
0 0 2-30/2 * * command


To make different schedules for different days as you asked I will have to add a second CRON instance and list of groups to activate.  This is easily done with some changes to the C# code.


Hope you get this working. For me it works fantastic, much better than the irrigation controller that came with the house.
« Last Edit: February 21, 2015, 02:57:58 AM by enterprised »
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

February 21, 2015, 04:46:58 PM
Reply #9

lv2roc

  • *
  • Information
  • Newbie
  • Posts: 17
Thanks again for your help. I hope other can follow this post to help them as well.

I guess I am off to learn C# after I finish with my self guided Python courses.

Are you allowing others to enhance this app and repost?

I am sure I will be back with questions, thanks again.

February 21, 2015, 04:51:42 PM
Reply #10

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
That is the beauty of open source software, anybody can pitch in and make improvements, either for their selves or to share with the group. :)

This must have been Gene's vision when he made HomeGenie available to all of us.
« Last Edit: February 21, 2015, 09:47:51 PM by enterprised »
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

February 22, 2015, 05:06:30 AM
Reply #11

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
Program Update.

This will address the ,json vs .js issue and add new functionality.

!!!!! you must uninstall/remove previous version of this program prior to installing the attached files !!!!!

The Garden Sprinkler System App now has 3 individual schedules, Schedule A, B and C.
For each schedule you can program a time and date based on CRON and assign the individual sprinkler groups.
This should give full flexibility for even the most demanding and creative schedule you may want to use.

App Notes:
=========
Garden Sprinkler System

Activate sprinkler system (irrigation system) based on CRON scheduler.
This program has 3 individual programmable schedules for both time and sprinkler groups.

!!!!! Make sure that Schedule A, B and C do not overlap in time !!!!!

CRON:
* * * * * ( 1 2 3 4 5 ) command to execute
1 = min (0 to 59)
2 = hour (0 to 23)
3 = day of month (1 to 31) (1-31/2 = odd days, 2-30/2 = even days)
4 = month (1 to 12)
5 = day of week (0 to 6) (0 to 6 are Sunday to Saturday

Groups:
1,2,3,4,5,6 = all groups active
1,3,6 = group 1, 3 and 6 active
none = no group active

« Last Edit: February 22, 2015, 05:58:03 PM by enterprised »
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

February 25, 2015, 10:32:54 PM
Reply #12

lv2roc

  • *
  • Information
  • Newbie
  • Posts: 17
Nice update. I like the 3 CRON jobs to increase flexibility.

I have not had a chance to play with it as much as I would like to, but I would like to know if you can skip a schedule due to weather conditions.

My main conditions are current rain and wind conditions. I do not want it to sprinkle my lawn if it is raining or has rain "x" amount in the last 24 hours. As with the wind, do on run schedule if the wind is above a specified wind speed.

These conditions can be taken off Weather Underground or whatever weather info one uses.

If it does this, would you mind posting an example of how to set it up.

Many thanks!

February 25, 2015, 11:05:13 PM
Reply #13

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I haven't looked at the code, but I don't remember seeing those conditions in the write-up.  I'd say that a check for x inches of rain in last day or predicted x" of rain in next y days would be a good thing to include.  I don't see how wind would be critical, but it could be added as well.  I think to add that check, you simply need to add in the value to check for in the setup and then find a source for rain history and rain/wind forcast.  Then, you just add that check in the same location where it checks the cron event as an additional AND statement.  Shouldn't be all that difficult yet very useful!

February 26, 2015, 04:47:11 AM
Reply #14

lv2roc

  • *
  • Information
  • Newbie
  • Posts: 17
Wind is something I have to deal with each watering session. I live in a high wind area and water my neighbors is nice for him but not me.  ;)

I am not a coder but would like to see the app evolve to help everyone.