I am about to change my garden automation project and was wondering if anyone had experience using this rayshobby.net - OpenSprinkler? Or does anyone have other good approaches for an garden automation system indoors with a raspberry pi?

  • How did it go? Any success?
    – Piotr Kula
    Mar 18, 2015 at 20:03

1 Answer 1


I have no experience with this device but it is good to see that you can connect it to your network. It has its own WebUI and also what you are interested in is the "Firmware" API.

What makes it slighltly easier to use is the the API is epxosed as GET URL's. What that means is you request data like, based on an arbitary IP. and the result is some nice JSON (but not completely structured).

{ "devt":1413630371, "nbrd":1, "en":1, "rd":0, "rs":1, "rdst":0, "loc":"Boston, MA", "wtkey":"12345678", "sunrise":412,
"sunset":1065, "sbits":[64], "ps":[[0,0,0],[6,10800,1413637861],[0,0,0],[7,10800,1413648721],[4,7200,1413659581],
[0,0,0],[3,7430,1413573001],[0,0,0]], "lrun":[0,0,0,0]}

Why is this good? Well, it means you can write your own app using HTML and jQuery. No need for server side, like PHP, Python or .NET. They not excluded but its easy to use URL GET's

on your HTML page you would write some javascript leverageing jQuery library similarly to.

 var basicData; //Global variable that can be used later
      //This anonymous function fires once the device returns and closes the HTTP steam. The key is to store data to the global variable we defined earlier.
       basicData = jQuery.parseJSON(returnData);

What the parseJSON does for you is create an Object like variable. You assign it to a "global" variable so that you can access it in other places. So you can now easily access the data and do stuff with HTML on your page.

  $('#device_time').text(basicData.devt); //epoch-unix time
  $('device_pid_1').ps[0][0]; //yikes.. the JSON does not name the array parameters
  $('device_pid_2').ps[1][0]; //etc

Using the same $.get method you can set stuff on the device.

$.get('', fucntion(returnData){
   //returns an error code which are defined in the first chapter of the API Manual
   var r = $.jQuery.parseJSON(returnData);
   if (r.result == 1)
        alert('wohoo! It worked');
   if (r.result == 16)
      alert('Data was missing!');

Using just basic HTML and jQuery you can achieve that. You can do debbugging the JS in Chrome or FireBug. All this is easy and free. Just a small learning curve, which in my opinion is worth learning.

This is very flat code and may grow to become very large. It would be recommeneded to create objects that can parse data and be reused as needed. this can either be achieved by prototyping javascript, creating a jQuery plugin or creating objects in separate files.

Wether you run this on the Pi or not is a question of your requirements. You can go the server side way, recommend is Python since its easy to learn... but C# is also easy, and also supported on Linux now with Mono or KRE (vNext) using Visual Studio Community.

  • 1
    ok thanks for that answer. i will take it into consideration on the weekend and see where i go from there. I just thought maybe someone has experience with that on Raspberrypi.stackexchange and thought its a good place to ask :-)
    – Klettseb
    Feb 19, 2015 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.