Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
relay_board plugin with BeagleboneBlack
#1
Hi,

I've been building an irrigation system over a period of years using a Beaglebone Black as controller, and using simple bash scripts to operate GPIO pins that turn relays on and off.  Having finally gotten the bugs out of my entire system, not just hardware and software, but plumbing, wiring, electro-hydraulics, and tweeking sprinklers and drips, its time to think about a more friendly user interface. I like the SIP web user interface, it is very easy to use and fully functional.

It was not difficult to get this SIP app to run on my beaglebone, but I noticed in in the relay_board plugin

Code:
#### define the GPIO pins that will be used ####
try:
    if gv.platform == u"pi":  # If this will run on Raspberry Pi:
...
   else:
        print(u"relay board plugin only supported on pi.")

So I get it that there is little interest in running SIP on BBB. Beaglebone Black is really overkill for this app. And I've considered just buying an RPi. I could easily spare $35 for a RPi, but then I'd have to rewire and remap things, so I thought I'd have a go at making this work on BBB first, and I thought I'd post here before I get too much farther to see who is out there.

I had to supply the BBIO GPIO module here:

Code:
debian@beaglebone:~/SIP$ diff my/relay_board.py original/relay_board.py

24,30c23,28
<     # ~ if gv.use_pigpio:
<         # ~ import pigpio
<         # ~ pi = pigpio.pi()
<     # ~ else:
<         # ~ import RPi.GPIO as GPIO
<         # ~ pi = 0
<     import Adafruit_BBIO.GPIO as GPIO
---
>     if gv.use_pigpio:
>         import pigpio
>         pi = pigpio.pi()
>     else:
>         import RPi.GPIO as GPIO
>         pi = 0

And I had to add my GPIO pin list here:

Code:
#### define the GPIO pins that will be used ####
try:
    if gv.platform == u"pi":  # If this will run on Raspberry Pi:
        if not gv.use_pigpio:
            GPIO.setmode(
                GPIO.BOARD
            )  # IO channels are identified by header connector pin numbers. Pin numbers are
        relay_pins = [
              ...
        ]
        for i in range(len(relay_pins)):
            try:
                relay_pins[i] = gv.pin_map[relay_pins[i]]
            except:
                relay_pins[i] = 0
        pin_rain_sense = gv.pin_map[8]
        pin_relay = gv.pin_map[10]
     else:
         print(u"relay board plugin only supported on pi.")
...

thus:

Code:
102,113c99,100
<     elif gv.platform == u"bo":
<         relay_pins = [
<             'P8_32',
<             'P8_34',
<             'P8_36',
<             'P8_38',
<             'P8_40',
<             'P8_42',
<             'P8_44',
<             'P8_46',
<         ]
<
---
>     else:
>         print(u"relay board plugin only supported on pi.")

I think it is immaterial, but I will mention that I took a shortcut by listing the pin names directly, "P8_xx", instead of doing this pin_map lookup like in the original code:

Code:
for i in range(len(relay_pins)):
            try:
                relay_pins[i] = gv.pin_map[relay_pins[i]]

And though it is a peripheral issue, I will also mention that I disabled the cpu temperature check, which fails on BBB:

Code:
diff SIP-master/helpers.py oob/SIP-master/helpers.py
300,304c300,301
<            
<             #res = os.popen(u"cat /sys/class/hwmon/hwmon0/device/temp1_input").readline()
<             #temp = u"" + str(int(res / 1000.0))
<             return u""
<
---
>             res = os.popen(u"cat /sys/class/hwmon/hwmon0/device/temp1_input").readline()
>             temp = u"" + str(int(res / 1000.0))

to stop cluttering my logs with error messages about "/sys/.../hwmon0/... file not found".

So with that it is basically working, but with a few bugs still to sort out, and I haven't yet tested all the settings and options.

The "Log" feature does not work. At first it was almost working, reporting events and time, but would always report the same station number. Now the log shows nothing at all.

The other weirdness I've noticed is that when I am running sip.py on my BBB and I will have multiple ssh logins open to monitor things, when sip.py crashes or when I click "Restart SIP" on the web interface, all of my ssh sessions are summarily terminated.

So, I don't know if this is interesting to anyone else on this forum. Having gotten this far, I am encouraged to go ahead with making this SIP app work on BBB.

Thank you
Richard (a.k.a. rickyketch)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)