Internal pull-up resistors not working

Bug #1899824 reported by MinePro120
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
rpi.gpio (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Consider the 3 following scripts :

1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/python3

from gpiozero import Button
import time
import os

stopButton = Button (17)

while True:
     if stopButton.is_pressed:
         os.system ("sudo shutdown now -h")
     time.sleep (1)
exit (1)
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/python3

import RPi.GPIO as GPIO
import os
import time
from threading import Thread

GPIO.setwarnings (False)
GPIO.setmode (GPIO.BCM)
shutdown_pin = 26
GPIO.setup (shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def shutdown_check():
        while True:
                pulsetime = 1
                GPIO.wait_for_edge (shutdown_pin, GPIO.FALLING)
                print ("falling detected")
                time.sleep (0.01)
                while GPIO.input (shutdown_pin) == GPIO.LOW:
                        time.sleep (0.01)
                        pulsetime += 1
                if pulsetime >=2 and pulsetime <=3:
                        os.system ("sudo reboot")
                elif pulsetime >=4 and pulsetime <=5:
                        os.system ("sudo shutdown now -h")
try:
        t1 = Thread (target = shutdown_check)
        t1.start ()
except:
        t1.stop ()
        GPIO.cleanup ()
        exit (0)
3~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/python3

import RPi.GPIO as GPIO
import time
import os

GPIO.setmode (GPIO.BCM)
GPIO.setup (17, GPIO.IN, pull_up_down = GPIO.PUD_UP)

def Shutdown (channel):
    print ("Shutting down...")
    os.system ("echo $(date) >> shutdown.log")
    time.sleep (3)
    os.system ("sudo shutdown now -h")
    exit (0)

GPIO.add_event_detect (17, GPIO.FALLING, callback = Shutdown, bouncetime=2000)

while 1:
    time.sleep (1)
exit (1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The above scripts are common shutdown scripts that can be found on the web, utilizing an NO pushbutton connected to GPIO 26 and ground (physical 37). None of the above scripts work though, since the internal pull-up resistors don't seem to work, and the GPIOs always read LOW. My setup has been tested twice in Raspberry Pi OS (the resistors worked there, measured with a scope). gpiozero uses rpi.gpio as the pin factory. A different pin was tested too.

UPDATE: The pip3 version of RPi.GPIO (and gpiozero) works fine.

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: python3-rpi.gpio 0.6.5-1ubuntu3
ProcVersionSignature: Ubuntu 5.4.0-1021.24-raspi 5.4.65
Uname: Linux 5.4.0-1021-raspi aarch64
ApportVersion: 2.20.11-0ubuntu27.9
Architecture: arm64
CasperMD5CheckResult: skip
Date: Wed Oct 14 20:27:59 2020
ImageMediaBuild: 20200731
ProcEnviron:
 TERM=alacritty
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=C.UTF-8
 SHELL=/bin/bash
SourcePackage: rpi.gpio
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
MinePro120 (minepro120) wrote :
description: updated
MinePro120 (minepro120)
summary: - RPi.GPIO doesn't detect falling edge (wait_for_edge, add_event_detect)
+ Internal pull-up resistors not working
description: updated
MinePro120 (minepro120)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in rpi.gpio (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.