Can anyone offer a suggestion here? I’m having problems setting a GPIO output pin on my MusicBox
I have a Raspberry Pi 2 B, with a HiFiBerry DAC+, running Pi MusicBox 0.6 with python GPIO 0.5.11
As far as I can discover, the HiFiBerry DAC+ uses GPIO2-3 (and possibly 6) and 18-21, so I think I should be able to set GPIO25 (header pin 22) as an output, but the test case (below) does not work - I just get a list of messages like this:
root@BerryBox:/myProject# sudo python testcase.py
testcase.py:13: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(outpin, GPIO.OUT)
should be 1, state=0
should be 0, state=0
should be 1, state=0
should be 0, state=0
should be 1, state=0
should be 0, state=0
should be 1, state=0
should be 0, state=0
...etc
Is there something in MusicBox or Mopidy that is already using this (and other) GPIO pins? I didn’t measure any signal on that pin with a multimeter so I tried reading the output after I had written it, shown in the python script below. The output simply never gets set to “1” - I tried removing the HiFiBerry DAC and it still didnt work, so is there something in MusicBox that is somehow using the pin? the “channel already in use” warning seemed to be pointing that way?
# test case: why is the output GPIO pin never set?
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
#GPIO.setwarnings(False)
#HiFiBerry uses GPIO2,3,6 and 18-21
outpin=22 # GPIO 25
GPIO.setup(outpin, GPIO.OUT)
while True:
GPIO.output(outpin, True)
print "should be 1, state=%d" % (GPIO.input(outpin))
time.sleep(1)
GPIO.output(outpin, False)
print "should be 0, state=%d" % (GPIO.input(outpin))
time.sleep(1)
I’ve tried this test case on another Pi which isn’t running MusicBox, and it works there, confirming that its OK to read an input from an output pin, as described here:
http://sourceforge.net/p/raspberry-gpio-python/wiki/Outputs/
So, I think it must be MusicBox/Mopidy getting in the way. I’m probably missing something really obvious. Can anyone see it?
Thanks