RPi.GPIO Input Pin Pull Up/Down Not Working on Pi 4B

  • Info:

    - Raspberry Pi 4B, 1 GB

    - LibreELEC v9.1.501

    - 'Raspberry Pi Tools' plugin v9.1.901.106

    TLDR: RPi.GPIO needs a version bump from 0.6.3 to 0.7

    I have a number of scripts that utilize the GPIO and worked perfectly on the Pi 3B. I have encountered some problems after migrating to the Pi 4B. It appears that input pins are stuck as either up or down regardless of the direction they are pulled during pin setup. Here is a linux script to test:

    #!/usr/bin/python

    import sys
    sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib")
    import RPi.GPIO as GPIO
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)

    pins = (3,5,7,8,10,11,12,13,15,16,18,19,21,22,23,24,26,29,31,32,33,35,36,37,38,40)

    print('UP TEST')
    for pin in range (0,26):
    try:
    GPIO.setup(pins[pin], GPIO.IN, pull_up_down=GPIO.PUD_UP)
    print('pin ' + str(pins[pin]) + ' = ' + str(GPIO.input(pins[pin])))
    except ValueError:
    print ('pin '+ str(pins[pin]) + ' = ' "ValueError")

    print('\nDOWN TEST')
    for pin in range (0,26):
    try:
    GPIO.setup(pins[pin], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    print('pin ' + str(pins[pin]) + ' = ' + str(GPIO.input(pins[pin])))
    except ValueError:
    print ('pin '+ str(pins[pin]) + ' = ' "ValueError")

    Which produces the following output on my Pi 4B running the latest official LibreELEC (v9.1.501) with 'Raspberry Pi Tools' plugin v9.1.901.106:

    UP TEST
    pin 3 = 1
    pin 5 = 1
    pin 7 = 0
    pin 8 = 1
    pin 10 = 1
    pin 11 = 1
    pin 12 = 0
    pin 13 = 1
    pin 15 = 1
    pin 16 = 0
    pin 18 = 0
    pin 19 = 0
    pin 21 = 0
    pin 22 = 0
    pin 23 = 0
    pin 24 = 1
    pin 26 = 0
    pin 29 = ValueError
    pin 31 = ValueError
    pin 32 = ValueError
    pin 33 = ValueError
    pin 35 = ValueError
    pin 36 = ValueError
    pin 37 = ValueError
    pin 38 = ValueError
    pin 40 = ValueError

    DOWN TEST
    pin 3 = 1
    pin 5 = 1
    pin 7 = 0
    pin 8 = 1
    pin 10 = 1
    pin 11 = 1
    pin 12 = 0
    pin 13 = 1
    pin 15 = 1
    pin 16 = 0
    pin 18 = 0
    pin 19 = 0
    pin 21 = 0
    pin 22 = 0
    pin 23 = 0
    pin 24 = 1
    pin 26 = 0
    pin 29 = ValueError
    pin 31 = ValueError
    pin 32 = ValueError
    pin 33 = ValueError
    pin 35 = ValueError
    pin 36 = ValueError
    pin 37 = ValueError
    pin 38 = ValueError
    pin 40 = ValueError

    Notice that the input pins are not influenced by the pull up/down setup. Also pins above 26 throw an error during setup. This issue has been discussed elsewhere (I adapted the script from here) and the v0.7 update for the RPi.GPIO library fixed this issue on July 21, 2019 (see here and here). I see that the Raspberry Pi Tools plugin has not been updated for 6 months and it currently uses RPi.GPIO v0.6.3. Can someone please bump the RPi.GPIO dependency to v0.7?

    Sorry for the bad code formatting. The code blocks ignored line returns which looked even worse.

  • @Iridium Sorry about reposting. I wasn't getting any responses for an issue that appeared to be rather important. Obviously I posted in the wrong place. Feel free to delete those older posts.


    @HiassofT

    That did the trick. Everything is working perfectly now. Many thanks!