2

I have several RasPIs set up with Ubuntu Server 18.04 64Bit. One freshly setup up RasPIs 3B+ and two 4Bs. On all I can run the following minimum script without any error messages:

#!/usr/bin/env python
from gpiozero import Button, LED
from signal import pause

def print_pin(button):
    print(str(button.pin.number))

button1 = Button(20)
led1 = LED(4)

led1.blink()
button1.when_pressed = print_pin

pause()

The LED blinks on all of the RasPIs, however the button just works on the RasPI 3B+, but on none of the 4Bs.

I can't get any button working on the 4Bs, however LEDs work just fine and on some of them I use I2C, which also works perfectly fine. What could be the problem here?

I'm using the following versions on all RasPIs:

Linux ubuntu 5.3.0-1030-raspi2 #32~18.04.2-Ubuntu
gpiozero==1.5.1
RPi.GPIO==0.6.5
python-rpi.gpio 0.6.5-1ubuntu0.18.04.1

Just for completeness: In addition the 3B+ and one of the 4Bs have the following GPIO library installed for I2C:

Adafruit-GPIO==1.0.4
4
  • Probably wrong wiring. We need clear photos showing the connections you have made on the Pi4B.
    – joan
    Commented Aug 7, 2020 at 9:24
  • Ubuntu implementations have limited support for Pi hardware. Expecting an 2 year OLD (obsolete) OS to support hardware that wasn't released when it was is wishful thinking at best. Even the latest Ubuntu (which only claims to be a server) has limited support.
    – Milliways
    Commented Aug 7, 2020 at 9:48
  • @joan I applied exactly the same wiring to all PIs. Since 3B+ and 4B have the same pinout it should either be wrong for all of them or for none.
    – MichelH
    Commented Aug 7, 2020 at 10:05
  • @Milliways I'm aware of this issue, however I have to run ROS Melodic on these PIs and Melodic is tied to Ubuntu 18.04. I've used Ubuntu Server 18.04 with ROS on a RasPI 4 very often before without any issues, but never used the GPIOs before with Ubuntu Server.
    – MichelH
    Commented Aug 7, 2020 at 10:10

1 Answer 1

1

I believe the problem is really in the old OS (or probably rather: Old libs) in use. The Pi4 requires an update to the I/O library for the input pull-up resistor setting to work properly, which is likely used by the above Button class. Try a never version of Rpi.Gpio, when possible.

Alternatively, you could add an external pull-up resistor to your button pin (assuming the button closes to ground).

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.