zebu
February 16, 2021, 7:29am
1
Hi,
I got a Raspberry PI 4B with Volumio 2.681 and IQaudio DAC+. And I got a python script which is successfully tested on raspberry pi OS but it don’t work on Volumio:
import RPi.GPIO as GPIO
import time
button1 = 13
button2 = 16
button3 = 18
button4 = 22
button5 = 37
led = 11
def setup():
print("Setup Buttons")
GPIO.setmode(GPIO.BOARD)
GPIO.setup(button1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(button2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(button3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(button4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#GPIO.setup(button5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(led, GPIO.OUT)
print("Setup finished")
def loop():
while True:
buttonPushed(button1)
buttonPushed(button2)
buttonPushed(button3)
buttonPushed(button4)
#buttonPushed(button5)
def endprogram():
GPIO.output(led, False)
GPIO.cleanup()
def buttonPushed(pin):
buttonState = GPIO.input(pin)
if buttonState == 0:
GPIO.output(led, True)
print("Button on GPIO " + str(pin) + " pushed")
while GPIO.input(pin) == 0:
time.sleep(0.2)
else:
GPIO.output(led, False)
if __name__ == '__main__':
setup()
try:
loop()
except KeyboardInterrupt:
print ('keyboard interrupt detected')
endprogram()
A simple program to test the buttons, but I only get the message “Button on GPIO 13 pushed”. It seems there’s something wrong with my setup. Is there something I have to know about Volumio and GPIOs or do I need an update on wiringpi? I haven’t found anything in the forums and docs.
Any help would be appreciated.
Carsten
PS: I don’t want to use the GPIO plugin
Hi,
Looking at the pinout for the IQaudio DAC+ it looks like several of your buttons collide with pins used by the DAC. These will be used in the DT overlay and therefore probably not available for you to use in wiringpi.
zebu
February 17, 2021, 3:35pm
3
But why does it work on Raspberry Pi OS?
But why does it work on Raspberry Pi OS?
Did you enable the DT overlay for the DAC in Raspberry Pi OS? If so, how?
zebu
February 17, 2021, 6:39pm
5
I checked it and added/updated the following lines to my /boot/config.txt (Raspberry Pi OS)
#dtparam=audio=on
dtoverlay=iqaudio-dacplus
And it still works.
If you are on Volumio 2.xx the GPIO rules may not be the most updated.
Check which version you have installed with
apt-cache policy raspberrypi-sys-mods
zebu
February 18, 2021, 12:21pm
7
volumio@volumio:~$ apt-cache policy raspberrypi-sys-mods
raspberrypi-sys-mods:
Installed: 20170519
Candidate: 20170519
Version table:
*** 20170519 0
500 http://archive.volumio.org/debian/ jessie/main armhf Packages
100 /var/lib/dpkg/status
pi@raspberrypi:~ $ apt-cache policy raspberrypi-sys-mods
raspberrypi-sys-mods:
Installiert: 20201026
Installationskandidat: 20201026
Versionstabelle:
*** 20201026 500
500 http://archive.raspberrypi.org/debian buster/main armhf Packages
100 /var/lib/dpkg/status
Can update with rpi-update?
Can update with rpi-update?
That’s not normally recommended. I don’t know what state Volumio would be in afterwards.
dvo
February 18, 2021, 3:39pm
9
update you can …upgrade you can’t it will screw up your system…
zebu
February 18, 2021, 4:09pm
10
sudo pip3 install RPi.GPIO --upgrade
Upgrade does the trick!
zebu
February 18, 2021, 4:36pm
12
sadly you are right. The system doesn’t start. I take a backup and try again. Perhaps some of my previous tries damaged the system.
dvo
February 18, 2021, 4:45pm
13
only use update … upgrade will kill it most of the times …
No, that would upgrade your kernel leaving you with a non bootable device.
That should work without bricking the system…
zebu
February 18, 2021, 5:37pm
15
RPi.GPIO --upgrade makes my script work but after starting it Volumio hangs up. Only a reboot makes Volumio working again.
A partial success
So it seems to be a problem with my script? Or the import of RPi.GPIO?
zebu
February 18, 2021, 5:43pm
16
Perhaps the best idea is to buy a raspberry pi 3B+ and wait until 4B is supported.
https://volumio.github.io/docs/FAQs/General.html
zebu
February 20, 2021, 6:16pm
17
Now it works. I moved button3 to pin 38 and it works. It seems that pin is preallocated.