OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › PHP based Interval Program
- This topic is empty.
-
AuthorPosts
-
May 29, 2013 at 4:03 am #22449
ndboostParticipantIm 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.
May 30, 2013 at 1:36 pm #23766
zither911Participanthi,
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.
May 31, 2013 at 3:09 pm #23767
pothiboMemberHey 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!
June 6, 2013 at 4:40 am #23768
ndboostParticipantCan 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 = 22June 6, 2013 at 6:31 am #23769
zither911Participant@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 = 22Go watch the video i posted to understand the logic. the mappings are in this thread : viewtopic.php?f=28&t=109
June 6, 2013 at 7:12 am #23770
aleatorvbMemberndboost – 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.
June 6, 2013 at 5:42 pm #23771
ndboostParticipantI dont currently need help.. I also switched from PHP to Ruby as its easier for me to integrate.
June 7, 2013 at 6:46 am #23772
ndboostParticipantFor those that were interested the program is written in Ruby on Rails…
https://github.com/mikedevita/rubysprinklerthere 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.
June 7, 2013 at 7:11 am #23773
ndboostParticipantI 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
June 7, 2013 at 4:35 pm #23774
pothiboMemberHi 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 !
June 7, 2013 at 8:50 pm #23775
ndboostParticipantI 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.
June 8, 2013 at 7:23 am #23776
ndboostParticipantAlright 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!
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › PHP based Interval Program