GithubHelp home page GithubHelp logo

rszimm / sprinklers_pi Goto Github PK

View Code? Open in Web Editor NEW
308.0 55.0 100.0 1.99 MB

Sprinkling System Control Program for the Raspberry Pi

License: GNU General Public License v2.0

C++ 90.24% C 0.24% Shell 0.82% CSS 0.09% JavaScript 0.77% Makefile 0.25% HTML 7.39% CMake 0.20%

sprinklers_pi's Introduction

sprinklers_pi

Sprinklers Pi is a sophisticated Irrigation control system for the Raspberry Pi. The system contains a built in mobile web page server that can be used to configure and monitor the system status from anywhere. It can also be cross compiled on an AVR/Arduino platform with appropriate networking and storage hardware.

Major Features

  • Fully contained system with control logic and web serving.
  • Same code can be compiled to run on the Atmel/AVR/Arduino platform.
  • Web based control (including mobile Android iOS)
  • Automatic adjustment of intervals based on weather conditions. (weather underground API)
  • Weather conditions can be pulled from individual personal weather stations or from general weather data based on zipcode.
  • Manual Control
  • Scheduled Control
  • Quick Schedule
  • Named Zones
  • Full Graphing feature of historic logs
  • Ability to run with OpenSprinkler module, direct relay outputs or an external script.
  • Supports master valve/pump output
  • Supports expansion zone board (up to 15 zones)
  • Very simple installation
  • Seasonal adjustment.

Weather Setup

By default, we now ship with no weather provider enabled, and therefore no adjustment performed. Follow the directions below to enable a weather provider. If you change weather providers be sure to run "make clean" before rebuilding.

OpenWeather / OpenWeatherMap

This is the current recommended free provider, however, it is currently unsupported on Arduino/AVR Platforms due to a dependence on curl and a JSON library that is currently untested on Arduino. It works on Linux devices including raspberry pi.

OpenWeatherMap appears to now require a CC on file for new accounts in order to work properly.

As long as you use less than 1000 calls / day it is still free. Sprinklers_pi will only make calls before starting a schedule and when you use the Weather Provider Diagnostics page so you should be no where near this limit.

  1. Uncomment #define WEATHER_OPENWEATHER in config.h before building.
  2. Build and start the server.
  3. Navigate to the Settings Page.
  4. Fill in API Secret with your api key from this page: https://home.openweathermap.org/api_keys
  5. Fill in Location in the format: lattidue,longitude (eg. "40.749748,-73.991618")
  6. Click "OK" at the top to save.
  7. Navigate to the Advanced -> Weather Provider Diagnostics page to test everything is working.

DarkSky Weather

WARNING: Darksky has been aquired by Apple and is shutting down their free API at the end of 2021.

Uncomment #define WEATHER_DARKSKY in config.h before building.

DarkSky is currently unsupported on Arduino/AVR Platforms due to a dependence on curl and a JSON library that is currently untested on Arduino.

Once you have built and started the server fill out the API Secret Key in the Settings page (API Id is unused). Your Secret can be found here: https://darksky.net/dev (account required, free). Location must be (without the quotes):

  • GPS Latitude,Longitude (eg. "40.749748,-73.991618")

Aeris Weather

Uncomment #define WEATHER_AERIS in config.h before building.

Once you have built and started the server fill out the API Id, API Secret, and Location in the Settings page. Your API Id and Secret can be found here: https://www.aerisweather.com/account/apps (account required, free, must be renewed every 2 months). Location can be any of the following:

  • GPS Latitude,Longitude (eg. "40.749748,-73.991618")
  • City, State (eg. "New York, NY")
  • City, Country (eg. "London, United Kingdom")
  • ZIP Code (eg. 10001)

Testing Weather Data

You can click on Advanced -> Weather Provider Diagnostics to verify your setup is working.

See the wiki for more information: https://github.com/rszimm/sprinklers_pi/wiki/Weather-adjustments

Building

make
sudo make install

NOTE: If you are running an older version of g++ compiler you may see the error unrecognized command line option '-std=c++11'. You should either update to g++ version 4.8+, or if you are not using DarkSky as a weather provider, you can remove -std=c++11 at the end of line 8 in the Makefile. You can see what version of g++ you have by running g++ --version.

Running

sudo /etc/init.d/sprinklers_pi start

See the wiki for more information: https://github.com/rszimm/sprinklers_pi/wiki

Live Demo

A live demo site is available here: http://kilby.kewlshells.com:8080/ Please keep it clean.

sprinklers_pi's People

Contributors

bryant1410 avatar codekitchen avatar kanyonkris avatar madisdev avatar mafes avatar nhorvath avatar rszimm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sprinklers_pi's Issues

Feature suggestion: a bit more towards safety

Dear Richard,

I have a feature suggestion which improves the safety of the system - after all, it can cost the user money when irrigation goes wrong. I have had the case that I got a bad response from the Wunderground server (for whatever reason) and it seems to check only once directly before watering. That caused the system to assume 100% and it watered accordingly. Sadly it was pouring with rain that night.

Suggestion 1: implement several checks for Wunderground, maybe once a minute for five minutes before the schedule is set to run
Suggestion 2: implement a user option of what percentage (0-100%) should be used if no valid response is obtained.

Besides that, it's really great, thanks a lot!

Cheers,
Michael

question

this need special board to connect to the PI or just any relay? if is just relay how i chose what pin to use?
thanks

Bugs, Features & Praises

Hi,

I originally wanted to write my own OSPI app until I found yours which had a decent UI. I have flashed the SDCARD image from OSPI which includes everything as a baseline and I'm having some issues. Notably; sometimes I'll get into a menu and I'll often see "Communications Failure". Sometimes I'll even have to reload the page a few times before the data gets populated (so there seems to be an issue related to getting the information). Pressing 'back' to go the main menu does this as well as entering various other menus. I've debugged this a little bit and I can see that I get "NOT ALLOWED" when performing "GET http://ospi.local:8080/json/state".

Other than the 'flakyness', I wanted to add a few features & simplifications (time-willing) which I'm happy to send back your way. ex: using a weather datafeed which doesn't require an API key. Change some of the animations to be symmetric (ie: back should translate opposite to forward) and a somewhat separate system that can automatically set the 'ideal' time for each zone (ie: generally at Dawn).

But more importantly right now; I'd like to get my system to work as expected before I augment it :).

WUnderground Failure

A system that was working has recently started to get errors, "Invalid Response from WUnderground server!" when running diagnostic.
Using a PWS and the settings page is configured with the IP 104.72.15.199.
api.wunderground.com does not resolve to that IP but then it has not from the first time I have installed the program
tail /var/log/sprinklers_pi after running diagnostic shows the entry:
Bad Wunderground Response.

I assume that the WUnderground has changed something....

Host a Demo Site

I think it's really smart to keep a version of this running on a public web server, so people can come in and try it out and get a sense of it without necessarily owning a RasPi or the sprinkler board.

Expanding zone support to 31

Is adding support for 31 zones at direct as updating the define for NUM_ZONES, or is their other work to be done? I'm looking at ordering the raspberry pi version with 3 expansion boards and wanted to ask if I could utilize all of them (or offer to help if work is needed to support more than the 15 zones supported today)

Best,
Bill

hwclock dies when settings change to OpenSprinkler

Sorry to be a pest.
I'm finding that the hwclock becomes unreachable as soon as I change the settings to OpenSprinkler. Additionally I am not able to get the hwclock back until I remove sprinklers_pi (make remove) and reboot.

Schedules run for 1minute only

Am running on raspberry_pi 2 with latest raspian connected to an old water controller. All works fine in manual, but no matter what I set the schedule time to for each zone the schedule only runs for 1 minute. Weather Ubderground feed is working OK. The schedules do start at the correct time.

Any thoughts appreciated

Invalid Response from WUnderground server!

Cannot connect to the WUnderground API, clicking "WUnderground Diagnostics" from the Advanced menu produces the following error:

Invalid Response from WUnderground server!

This is because the WUnderground API servers do not respond to HTTP requests without a Host header.

Possible solution is to remove the WUnderground IP option from the Settings page and have Sprinklers Pi connect to api.wunderground.com instead.

local sensor array vs wunderground

is there any way to point ospi at my Davis weather station directly or is it only possible through wunderground? I have been unable to get wunderground to properly publish my soil moisture, leaf wetness or soil temp data even though it it being published by my system locally and wunderground has placeholders /headings for those variables. I have a Davis Vantage Pro2 Plus weather station plus a separate leaf and soil sensor array and the Davis gear is broadcasting all the variables but Wunderground ust doesn't seem able to get the numbers displayed for the leaf and soil sensor even though it seems to know it's there.

What I really want to do is use the existing weather data and have the ospi calculate realtime ET (evapotranspiration) and use that and soil moisture from my remote sensors to modify my watering tables. I've got really porous volcanic cinder soil so i need to water a little very frequently as the water passes through the root mass quickly so potential for water saving using et and sm are huge...if i can just get it to work.

Graceful failure uncertain

I have been using sprinklers_pi for a few weeks now. It's great. However, on April 18 at about 5:30am for some unknown reason the spinklers_pi program on the Raspberry Pi hung while the sprinklers were on. I can estimate the time because that's the time of the last log entry. The sprinkler station remained on for two hours before I luckily noticed the problem. Yikes... that could be expensive. I could still log into the Pi via Wifi SSH (that's where I viewed the log using sqlite3 and entered the reboot command) but the sprinklers_pi web interface was down until after the reboot (Apache remained up). Everything worked normally after the "sudo reboot".

One idea is to modify the sprinklers_pi code to toggle an unused Pi pin every minute (or so) and an autonomous logic circuit looks for that "heart-beat" signal. If the heart-beat stops the sprinkler power is cut.

BTW, if you use the manual control to turn on a station and then somehow lose communication with the Pi server the sprinkler station will remain on indefinitely. EVEN THOUGH the web page toggle shows the station is off (I think that's because jquery on the client controls the toggle appearance.)

safari on iOS 9 no longer supports sync ajax requests

sprinkers_pi doesn't work on iOS 9 Safari, because it specifies async: false for all the ajax calls, which Safari no longer supports.

Everything actually seems to work fine by just removing that option and allowing the ajax calls to run asynchronously, but I'm not positive yet that this doesn't introduce some race conditions, so I need to do more testing before opening a pull request.

remote sprinklers with ESP8266 (or any url driven relay / sprinkler)

Dears, I had envisaged putting a tiny ESP8266 module outside in the sprinkler box, they are dirt cheap and have built-in wi-fi and webserver. They can control relays with their digital outputs and these can be triggered by simple url requests (http://randomnerdtutorials.com/esp8266-web-server/).
It would be cool if I could combine such a setup with sprinklers_pi. I think what would be needed is another type of output, say "url sprinkler", which is defined by a pair of urls : 1 each for on and off.
Sprinkler_pi would than call (open) these urls as commands to drive the respective sprinklers. Would appreciate if you could evaluate this as an extension/enhancement. Kindest greetings, Peter

Interval suggestions

One thing that would be nice is to know when the next watering cycle date is when editing a schedule when using interval days. It would be nice to have it right below where you enter number of days for interval. If it could update after you enter number of days and after each watering cycle ends, that would be fantastic. That way I can check any time to find out when the next watering cycle is going to start.
Thank you in advance.

Readme file support

hey there,

just digging into this, would be great to see a readme file on compiling, along with information regarding the system.

I haven't really spent much time looking at the code, however are you pushing data to a web client?

Feature request: "use pump output" option to hide/show pump output in zone settings and support up to 8 zones

This has been discussed on the boards, just wanted to add it here for the record:

Although there is a workaround for getting 8 zones (set "pump" to on for 8th zone, off for all others, zone 8 is then the first output), it would be nice if there was a new "use pump output" configuration option on the "Settings" page that did the following:

  • if "use pump output" option is set to "on", then system works as it does now: there is a pump option for each of 7 zones, and the pump is controlled by the first output
  • if "use pump output" option is set to "off", then the "pump" option is hidden for each of the 8 zones, and the first output controls zone 1, rather than the pump.

there might be a clearer/better name for the option...

cominication error

sometimes i get communication error, when i save settings and when i try programming zone not open all page to end off page

GPIO Pins where to connect relays to open electric valves

Hello

I was not able to understand how we can assign zone to the GPIO pins, so that Raspsberry can interect with relays and therefore with the electric valves.

Zone 1 ---- Pin XXX
Zone 2 ---- Pin XXX
etc
etc
etc

Many thanks

Luis

Securing access?

Is there any way to secure the site similar to apache authentication via .htaccess files or something?

Graph

I really just wanted to say thanks very much for developing sprinklers_pi.
I've modified it a bit to work with my h-bridge arduino shield controlling some DC latching relays. I've documented the process here: http://designandmotion.net/new-post/irrigation-for-geeks-how-i-built-my-fully-automated-open-source-watering-system/

One thing I'm still a bit lost with, is the graph. I can't seem to figure out what the axes represent, or where to go to modify them. Is there anything documented about the graphing?

All in all, a great little piece of software, cheers!

When using OSPi, Zone 1 is mapped to port 2 of shift register

Putting a solenoid on the first port of the connector on the OSPi, and manually triggering Zone 1 does nothing.

If you move the solenoid to pin 2 of the connector on the OSPi, and manually trigger Zone 1, it will trigger.

This effectively makes it only possible to control 7 zones and not 8.

Zone duration too short

I've got a citrus zone that requires up to 20 hours of continuous drip irrigation for a deep soak every couple of weeks. Would it be possible to extend the maximum zone duration to 2000 minutes or more?

Wunderground overall scale is 0%

Sorry if this is a wunderground or external issue... but,
I have sprinkler_pi running well but I do have it on a recent (latest) version of Raspian, I am finding that using 'weather adjust' turned on is causing the schedules to not activate fully or at all.
The wcheck is always returning Overall Scale 0% (where I see in the setup pics this should be around 100%) but otherwise this seems to be working with my local PWS sites (say IVICTORI577 here in Melbourne).
The schedules are often activated for very short and very random time lengths or more often just not being activated or logged at all.
Not sure what I should be looking for in diags/text files to understand more.

Extend Max Sprinkler Name Length

Right now the max sprinkler name length is just 16 characters. That's enough for a user name or something, but until you support pictures of the zones or a map of the property, I don't see why you'd limit a sprinkler's name length. Just go multi-line if the name is too long.

Prefer to create zones as needed instead of fixed at 15

I'd prefer to create zones like schedules - one at a time as needed. I only have 3 zones so I'd rather just see 3 zones listed instead of fixed at 15.

At least visually differentiate the enabled and disabled zones (greyed out or something).

sprinkler pi signal speed?

Where can I find information on how fast the signals are sent from the Pi to the shift registers?
I tried capturing them with an Oscilloscope, but was not successful.

Document API

If you document the API methods your web interface is using, it would be easy for people to build new front-end interfaces for it...

I love that it compiles from C++, allowing compiling on various hardwares, really clean back-end, but frankly I think some innovation on the front end would be beneficial.

Run schedules keeps getting set off

Overall, this program looks like exactly what I want for my sprinkler system and I have been configuring it the past couple of days. When I access through Chrome on mac osx, I get frequent error, timeout and other messages.

Using Safari, things seem to work better. However, I click the Run Schedules button and the log always shows that it is turning off all sprinklers:

2014/06/26 17:40:26 Got a client
2014/06/26 17:40:26 Found a KV pair : system -> off
2014/06/26 17:40:26 Page:bin/run
2014/06/26 17:40:26 Turning Off All Zones
2014/06/26 17:40:28 Got a client
2014/06/26 17:40:28 Found a KV pair : system -> on
2014/06/26 17:40:28 Page:bin/run
2014/06/26 17:40:28 Turning Off All Zones

I have version 1.0.6 and am connected through a hard wire rather than wireless so there aren't any connectivity issues...

--Ron

Feature request - Run schedule now

First I want to state that I think the sprinklers_pi is wonderful. Would it be possible to add a function that allows you to run a scheduled routine on demand? Another possible issue is that if you run a sprinkler manually it sets the Run Schedules to Off. Is this the intended flow? Would it be possible to preserve the state of this setting regardless of what has been done with the manual options?

Weather Underground for Canadian cities

I have modified your code so that it works with either zip codes or postal codes. Basically, I had to change the storing of the zip to a character array so that it would work for postal codes or zip codes and alter the GetZip and SetZip functions. If you are interested, I can send it to you and you can merge it into your codebase. Great program by the way.

Jack Collier (Alberta, Canada)

Web response fails on Rasbmc

Often getting failed communications from the web interface. Current version of RASbmc installed as base OS, the XBMC web interface is communicating fine but the sprinklers_pi main page (and further) is returning 'communications failure' or fails to load properly.

Feature request: add login page to secure access to sprinklers_pi web interface with username/password

This has been discussed on the boards, just wanted to add it here for the record.

It would be nice to add some basic password protection to the sprinklers_pi web interface, so that access to all pages was gated by a login page which required username/password. The initial username/password could be defaulted during installation. A new section would be needed on the Settings page to change it. The implementation could be simplified by just requiring a password and eliminating or defaulting the username.

I am not sure what the simplest way to do this would be given the current implementation of the web server. Perhaps HTTP Basic Auth? Although this is not really secure unless done over SSL, it would be better than nothing and would prevent those with access to your local network from easily messing with your sprinklers.

Show custom zone names on main zones page?

Thanks for the great program! How much work would it be on the Zones page to list the custom zone names, rather than (or in addition to) the zone numbers? I took a look at the code (i've actually forked the github repository..) but haven't taken a go at it yet... right now you can only see the zone name if you expand the zone for editing.

regards
Don

Edit Schedule, Time textbox 2,3,4 disabled even though Enable button checked

If Time 2, 3 or 4 is set and enabled, the Edit Schedule page shows the times disabled even though the Enable button is checked. When I click the Enable button twice the time is enabled, so that code works fine. It seems to only be a problem when the Edit Schedule page loads. I fiddled with the code but couldn't get it to work.

Feature Req: Change Time

I want to build one of these for the family. Since they are not 'networked' as such, I will set the Pi up as an access point for them to 'connect to'. It would be nice to have the ability to adjust the time in settings.

Perhaps a 'daylight savings' check box, and the ability to change the time manually.

Good work!

Schedules crossing midnight do not complete

I scheduled the yard system to run at 11:30 at night. The first zone took 27 minutes, the second zone took 25 minutes and then no more zones went. I haven't had a chance to really get into the code yet but will see what I can find. For now, I have changed my schedule to just start after midnight...

Running Garden Lighting / Water Features

It would be a great feature to be able to run Garden Lighting and Water Features with this.
I have been running it for over 6 months and its fantastic. well done.

Using firefox to access

I used Firefox and I experience this:

When Scrolling to the bottom, this occurs. The "SAVE" button pops up at the top.
ab05a0bc-9b4c-11e5-8a10-b667ac9df466

Scrolled back to the top:
8b7d8340-9b4c-11e5-8bda-f8b62c0f9f29

Is this behaviour intentional?

EDIT: Clearly not intentional, if I then refresh the page it scrolls as expected and the save button is at the bottom.

Bug: zones fail to turn on

Having a very odd issue where zones fail to turn on, no voltage across the zone terminal and common, though the interface & logs show it is turned on. Manual or scheduled does not seem to make a difference. Restarting the sprinklers_pi service makes it behave for a short while. Have verified it is not a hardware issue by running other OSPi applications, they function as expected. Running a brand-new RasPi 2. Let me know if there is more info or if any of the logs could be of help.

Configurable GPIO so I2C can be enabled

Hi, this is a fantastic piece of software. Well done.

Would it be possible to make it so we can configure our own GPIO x = Zone y?

I'd like to use I2C but that takes over GPIO 2, 3 and 4 (WiringPI 8,9 & 7). Since I have Pi 2 B+ could simply re map zones 7,8 and 9 to different ones?

Or if it is possible in source, please advise how (no C experience here).

Thanks for the good work. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.