OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Using a Raspberry Pi with OpenSprinkler

Tagged: 

This topic contains 19 replies, has 10 voices, and was last updated by  Ray 6 days, 10 hours ago.

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #22319

    Dan in CA
    Participant

    I got a Raspberry Pi a couple of months ago. It is often described as a credit card sized computer and costs just $35.00. I’ve been trying out some of its amazing capabilities and thought it might be useful as part of a home automation system. It only uses about a half Watt of power.

    One of my greatest interests is gardening with drip irrigation. Climate change and a growing population make water conservation vitally important. I figured the Raspberry Pi could be programmed to automatically adjust an irrigation schedule based on weather/climate data that it could access from the internet. The problem was how to interface it with sprinkler valves. Out of curiosity I Googled “irrigation controllers with Ethernet” since the Pi has an Ethernet interface. That’s when I discovered OpenSprinkler. I felt like I had just won the lottery! OpenSprinkler has everything I needed and more and at a reasonable price. I ordered the DIY kit and while I was waiting for it to arrive I downloaded the software/firmware zip file from github so I could start getting familiar with it.

    One of the first things I noticed about the OpenSprinkler software was that it fetched the JavaScript files for the web interface from the rayshobby server. Those JavaScript files in turn fetched icons for the buttons from there also. That is obviously due to the fact that the firmware has pretty well maxed out the memory on the OpenSprinkler. The Raspberry Pi uses an SD card to hold the operating system, programs, and data files. It can provide gigabytes of storage depending on the size of the card.

    As soon as I got the OpenSprinkler kit assembled and working I started setting up an SD card for the Pi to work with it. I flashed an 8GB SD card with the latest release of the Raspian (Debian) operating system and installed lighttpd which is a light weight and fast web server. then I put the Icons and JavaScript files for OpenSprinkler on the Pi after modifying the JS files to point to the PI which I set to a static IP address of 192.168.1.50.

    Then It was only a matter of changing one line of the firmware to point to the PI. That was easy but compiling and uploading the modified firmware to OpenSprinkler turned out to be a project in it self but that’s a story for another day.

    Once the updated firmware was installed on OpenSprinkler, I connected the Pi and OpenSprinkler to my home network and fired them up. Then I tried to access OpenSprinkler’s web interface and it worked the first time!!!

    My next step will be to get David Gustavson’s logging scripts working on the PI. As soon as I do that, I would be willing to share the image file for the SD card so anyone who wants to add a Raspberry pi to their OpenSprinkler system could do it with minimum hassle.

    I’m also working on some Python programs to automatically adjust OpenSprinkler’s schedule based on weather conditions.

    I’ll report back as things move along.

    Dan

    #23201

    Ray
    Keymaster

    Thanks for sharing, Dan. It’s great to know that you modified OpenSprinkler firmware to work with Raspi. I’ve got my first Pi recently and am very happy with it. I think a lot of home automation projects will move towards embedded linux in the future. It will lower the programming barrier for users who are less familiar with microcontroller programs but more familiar with script languages. Keep us updated on your progress. Thanks.

    #23202

    shawn
    Participant

    Great idea. I stumbled upon OpenSprinkler in the same manner you did and for the same purpose. I haven’t purchased one of these yet, but plan to shortly. I would be interested in your efforts to integrate it with the Raspberry Pi, since I recently purchased one of those to tackle this very problem.

    Great stuff Ray!

    #23203

    Dan in CA
    Participant

    The combination of Raspberry Pi and OpenSprinkler seems to be working quite well.

    I posted the steps I used to get the pi and OpenSprinkler working together on my blog. At this point the Pi serves the JaveScript files and icons for the UI and handles logging of irrigation events.

    I am in the process of writing a python module for interacting with OpenSprinkler. It will allow to write python programs which can be run on the Pi or other computer on the network that will be able to check and set irrigation schedules on OpenSprinkler. So far I have python functions that can change the Water Level %, set Rain Delay, read and change Run-Once Program settings and do things like set manual mode, reboot, and dis/enable OpenSprinkler. Once the module is ready I will be able to start working on some programs that tweak irrigation schedules based on evapotranspiration (ET) estimates from a local weather station. I will post here when the python module is available.

    Dan

    #23204

    Homerlh
    Member

    This is a totally awesome thread. I have had a Raspberry Pi for a long time. One of the things I wanted to do was develop some sort of web based sprinkler control system for my house.

    I am glad to see that it is already done and it is open source, except for the board.

    So, I buy the board from Rays Hobby for controlling sprinklers that is designed to attach to an arduino and it will work with a Raspberry pi?

    And I get the programs and stuff from here.

    Thank you.

    #23205

    Ray
    Keymaster

    @Homerih: in case you haven’t checked it already, all information about OpenSprinkler can be found at http://www.opensprinkler.com. It runs an ATmega328 microcontroller itself so you don’t need to attach it to any arduino. The microtronoller runs a full-featured program which serves the webpage, and carries out the water schedules. The webpage requires some Javascripts that are currently hosted on rayshobby.net server. Dan’s Raspi scripts are designed to offload these Javascripts to a Pi server, as well as to log the sprinkler status (which the controller doesn’t do itself). Also, using a Pi to interface with OpenSprinkler makes it easy to introduce weather-based features and anything that requires computation beyond what a simple microcontroller can do.

    #23206

    dman
    Participant

    Dan – looking forward to getting this up and running. I have fixed IP for both my existing R-Pi and OpenSprinkler – but I can edit the python, PHP and java files easily to make the changes. However I also customise my Opensprinkler firmware to change MAC address as I have both a v.1.0 and v.1.4 running on my network and it didn’t like duplicate MAC’s.
    You supply the HEX file for the firmware – can you also post the actual source code, or tell me what has changed in the Arduino code? I was hoping that the logging could be all external so I don’t have to reprogram my OpenSprinkler (which is a bit of a challenge under Windows) – just change the exteranl button image and intercept the weather call to the new logging page???
    EDIT: Just realised my question is dumb – obvioulsy need to change where the Opensprinkler looks for java from Rays page to the local server – any other changes?

    #23207

    Andrew
    Participant

    Actually you can change the location that you get the javascript from without reprogramming the the OpenSprinkler.

    What I do is have a php script that runs on a server that you access. It takes any references to the rayshobby.net address and rewrites them to it’s own address and adds the address of the OpenSprinkler in where it should before handing this back to the browser. There is a bit of work to be done after this in the javascript to make sure that the server is kept in the loop but after that it works a treat.

    A few benefits:
    The server logs all changes made along with the username of the person doing it (from the http authentication).
    The scripts are all local and MUCH faster than accessing from the US (we are in Australia).
    The timers each have the password set but the script inserts this into any request thus removing the need for staff to know it.
    I have a very simple index.php that takes the list of OpenSprinklers from a vars.php used by the other script and this displays a selection of timers along with direct commands appropriate for them.

    I will be working on refining it over the next few weeks and will look at publishing it all then. In the meantime I can pass on what I’ve done if you would like to look at it once I can be sure I’m not exposing any of our network data, etc by mistake.

    #23208

    dman
    Participant

    Not sure I fully understand the tech details on rerouting Rays site aradke – but sounds interesting! I’ll certainly be keen to try out your system (in Oz also – Geelong, Vic- but don’t have any real issues with speed on the interface – but quicker is always better!).
    I’m currently running the logger as well as using the RPi as a network print server for an attached USB printer, but if you’re after some beta testers let me know.

    #23210

    perico
    Member

    just asking because I don´t have much idea about it:

    It is possible to wire-connect opensprinkler to the raspberrypi?. I know how to share the connection with windows, but no idea about how to do it with linux.

    The configuration would be: A raspberry pi with wifi adapter and then opensprinkler wired to the pi via ethernet cable.

    #23209

    Ray
    Keymaster

    This should be possible. For exemplar, the OpenSprinkler can be connected to Pi with a cross-over cable, and then Pi is connected to the main router through USB WiFi.

    Just to give everyone a heads up: I am working on an OpenSprinkler Pi edition: basically it’s a shield that’s wired to Pi through the GPIO pins, so the Pi can directly control the shift register and hence the solenoids. The board is essentially a subset of the current OpenSprinkler hardware, with 24VAC->5V power conversion, shift register and triacs, and DS1307 RTC. The 24VAC->5V is capable of outputting 1A current, so it can power a PI board together with a WiFi USB dongle. The hardware has been tested and is working fine. It’s pretty straightforward and the nice thing is that I designed some copper pillars to support the Pi board on top of the shield, so that everything can fit inside the existing OpenSprinkler enclosure. The software is not finished yet: I’ve written a piece of Python code that runs a very simple http server, presenting a list of buttons and allows you to control solenoids manually (very much like the first manual control program for OpenSprinkler which I wrote a long time ago). I am hoping to post about it some time this week and next week. This should probably attract some interests from people who have a Pi at hand.

    Some pictures for the curious:

    #23211

    Andrew
    Participant

    The Pi edition looks fantastic Ray!

    And the options it would open up are huge. Of course the benefit of the existing OpenSprinkler is simplicity and that you know exactly what code is running on the microcontroller without a full OS and all it’s bugs.

    #23212

    Andrew
    Participant

    dman, I’m sorry I didn’t explain clearly.

    Basically, instead of accessing the OpenSprinkler directly you access the server’s web server. Each request you make is then sent to the OpenSprinkler by it instead and the returned page is modified as appropriate before handing it back to your web browser. Hopefully that makes more sense… ❓

    you ==> server
    server ==> OpenSprinkler
    server < == OpenSprinkler
    [server modifies response with links to local copies of javascript, etc]
    you < == server
    [you fetch javascript from local copy]

    So you don’t talk directly to the OpenSprinkler. The server does it on your behalf. There are other things it does as well but they are more for a business environment (like logging who did what, etc) and these are what makes the effort extra worthwhile.

    It is very lightweight stuff though so a Raspberry Pi with a PHP supporting web server would be more than enough, though we have it running on the server that does all the monitoring of the nursery’s watering, tank levels, etc.

    I have a little bit more work to do before I can spend time making it ready for others but if you are interested email me directly: [email protected]

    #23213

    dman
    Participant

    Just had another look at the Sprinklers.php posted by Dan. Although he has the OpenSprinkler at 192.168.1.55 in his instructions, and in the first part of the php file, there are a couple of references to 192.168.1.18 later in the code. If you edit these to be the same as your OpenSprinkler IP you also get the next weeks schedule printed after the logs. Even better, if you enable a rain delay, you see the schedules that won’t be run in red!
    Didn’t even realise that was there – an added bonus – great work Dan!

    #23214

    mrburns42
    Member

    Perico, I think what you want to do is an Ethernet bridge. This is doable from Linux. We have small embedded processors at work that do this. What exactly you have to enable is kind of beyond me. However, you may want to dig around the DD-WRT forums. This port of linux deals with routers and I believe the folks there should know all the setup and config files to change.

    Is the source code for the modification to the OpenSprinkler firmware available? I saw the compiled hex file in the zip file and the instructions mentioned that the firmware was changed. However, what exactly that was modified was not detailed.

    Thanks.


    Steve

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Using a Raspberry Pi with OpenSprinkler