OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Dealing with multiple OSPi units? Re: Re: Dealing with multiple OSPi units?

#24855

andrew
Participant

If you’re not worried about network issues preventing the slave from receiving commands from the master, you ought to be able to set something up with a relatively small bit of hacking. Let’s call the back yard your master and the front yard the slave. Your master will consist of one RPi, one controller board, and one extension board (which is a shame since you have ports to spare on the front yard). The slave will consist of one RPi and one controller board.

The quickest thing to do would be to configure the interval program on the master RPi to have an additional extension board (two in total), but hack the code so that the data that would be sent to the controller board and its extension boards would be forwarded to the slave instead. Fortunately, this appears to be fairly easy. In the OSPi.py file, find the definition for the set_output() function (line 282 of the current version). It looks like this:


##### GPIO #####
def set_output():
disableShiftRegisterOutput()
setShiftRegister(gv.srvals)
enableShiftRegisterOutput()

Luckily, this is the only place where data is sent out to the controller board and its extension boards, so you’ll really only have to modify this area to suit your needs. We’ve configured the master to have an extra extension board, so the first thing we need to do is make sure that the data for that extra board is not actually passed to the controller:


##### GPIO #####
def set_output():
local_srvals = gv.srvals[:16] # get the first 16 stations values
remote_srvals = gv.srvals[16:] # get the last 8 station values
disableShiftRegisterOutput()
num_stations = 16 # the following function uses num_stations, so we temporarily change the value
setShiftRegister(local_srvals) # only send the local values to the master's controller
num_stations = gv.sd # put it back to what it was.
enableShiftRegisterOutput()

Next, you’ll need to add some code to the end of that function that connects to the slave and sends the instructions for the remaining 8 values. I’ll leave that up to you, but you could implement some simple socket connections or use a web server, or whatever. On the slave side, whenever it receives data from the master, it should set its own shift registers accordingly. That’s all the slave has to do. For that, you may simply want to copy the original set_output() function (and dependent functions and variables) and simply call them. I can give you tips on the parts I’ve left out; let me know if you need further help or anything’s unclear. Also, I took some guesses wrt the bit ordering of the srvals array. it may be that the elements you want to forward to the slave are the first 8 elements instead of the last. You’ll just need to play with it.