OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) PHP based Interval Program

This topic contains 10 replies, has 0 voices, and was last updated by  ndboost 6 years, 2 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #22449

    ndboost
    Participant

    Im an avid php developer that will be working on developing another example of the OpenSprinkler Interval Program.

    The only issue I’m having is grasping the concept of how to interact with the opensprinkler board via php. I can use a GPIO php lib but im not sure how to use that to interact with the GPIO pins accordingly.

    The new program will use the latest standards for the web, including web sockets, html5, css3, and be mobile friendly/responsive..

    Anyone care to help me with the GPIO interface?

    The project will be hosted on github, and be completely open source.

    #23766

    zither911
    Participant

    hi,

    i’ve also started but am not clued up in PHP. so i’ll try to help.
    I’ll try and explain. Ray’s board uses a shift register to control the 8 valves. Go and read this to understand how a shift register works – http://bildr.org/2011/02/74hc595/
    Now that i hope you know how it works, you’ll understand the 4 wires you have to connect from the Pi to the sprinkler board.
    Also if you open his manual test program you will see his shift functions especially the shiftout one. etc
    So using the PhpGpio module, we can talk to the pins like he talks to them in Python.

    Hope this helps so far.

    #23767

    pothibo
    Member

    Hey guys,

    I’m glad to see some people thinking of using the Pi for their sprinkler, I just wanted to let you know that I started a project in Go lang to handle the Pi with the Open Sprinkler. You might want to have a look.

    http://pothibo.com/index.php/2013/05/31/control-your-sprinklers-on-your-raspberry-pi/

    I know Go is a young language but so far, I’ve been happy with the results. If you end up giving my project a go and you need help, don’t hesitate!

    #23768

    ndboost
    Participant

    Can someone chime in and provide some lamen term explanation of how the ipensprinkler interval program function
    def setShiftRegister(srvals) works? What do each of these defined pins map out to?

    I am trying to translate this python code to ruby.

    pin_sr_dat = 27 #Use for rev 2 Pi
    pin_sr_clk = 4
    pin_sr_noe = 17
    pin_sr_lat = 22

    #23769

    zither911
    Participant

    @ndboost wrote:

    Can someone chime in and provide some lamen term explanation of how the ipensprinkler interval program function
    def setShiftRegister(srvals) works? What do each of these defined pins map out to?

    I am trying to translate this python code to ruby.

    pin_sr_dat = 27 #Use for rev 2 Pi
    pin_sr_clk = 4
    pin_sr_noe = 17
    pin_sr_lat = 22

    Go watch the video i posted to understand the logic. the mappings are in this thread : viewtopic.php?f=28&t=109

    #23770

    aleatorvb
    Member

    ndboost – do you need any help with what you’re doing? Do you intend to release it to the comunity?

    I’m currently doing a php script that can be run as a service or as a cron job under linux and provides current weather and weather predictions. I’ve added 11 free weather api’s so far, working on the prediction model and statistical analysis.

    #23771

    ndboost
    Participant

    I dont currently need help.. I also switched from PHP to Ruby as its easier for me to integrate.

    #23772

    ndboost
    Participant

    For those that were interested the program is written in Ruby on Rails…
    https://github.com/mikedevita/rubysprinkler

    there is no working interface with the sprinkler system yet, still laying the config/foundation.. but authentication works.

    Default user/pass is [email protected]/changeme

    uses sqlite as the database backend. the eventual plan is to disable registrations and just have a user account created by default.

    #23773

    ndboost
    Participant

    I still haven’t come across an ideal solution to task scheduling.. which is what will be needed to handle “run for 15 mins”, or “run at 12pm tomorrow”.

    I am trying to not rely on external services such as resque, IronMQ, IronWorker etc..

    I found this: http://rufus.rubyforge.org/rufus-scheduler/ rufus-scheduler.. works similar to cron tab.

    the concept will be the program will have a restful json based API to interact with the stations.. things like

    http://rubysprinkler/stations///runtime/
    or for scheduled runs
    http://rubysprinkler/stations//schedule/

    one example i have currently “working” is: http://rubysprinkler/stations/1/start/runtime/10 & http://rubysrpinkler/stations/1/stop

    #23774

    pothibo
    Member

    Hi there, I’m a ruby on rails developer as well and glad you started a project in rails. However, you might want to be careful with memory allocation on the Pi. Rails isn’t really friendly on RAM. Pi rev1 only has 256mb Ram.

    As for the the interval scheduling, I used on my project a start date, with an interval. Ie: Monday 9th June 2013 6:00AM. Every week. I use a runloop to check sqlite if I have a matching interval and then open the relays with the matched scheduled. I don’t know if it makes sense.

    Good luck !

    #23775

    ndboost
    Participant

    I definitely have a huge concern for memory consumption pothibo.. I know rails is a friggin hog, i attempted to dev this in sinatrarb but its a pain getting a worthy authentication system in place with it.

    I might still switch back over to sinatra since its light weight.. but until i find a feasible authentication solution i’m not comfortable using it.

    This will be running on a rev2 512mb RPi btw.

    I have to hit up the electronics warehouse here in Arizona for a few parts.. a few 74hc74’s to mimic the shift register the OS uses so i dont have to bring the current sprinkler system offline (i have several RPi’s) But hopefully should be able to make some pretty significant breakthroughs on the code base this weekend.

    #23776

    ndboost
    Participant

    Alright so i’ve figured a work around for Sinatra authentication and started work on the REST API to handle manual schedules using Rufus-Scheduler but for the life of me i can’t figure out how to get it to work.

    So i think its back to the drawing board to figure out another task scheduling solution. If i cant figure a multi-threaded efficient solution i may end up going back to a python/flask solution blah!

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) PHP based Interval Program