-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Failed To Add Edge Detection, GPIOZERO
Hello guys,
So I have been trying to do some raspberry pi projects, and I use Raspberry Pi 4 with the latest version of bullseye installed. These days, for some reason, some of my GPIO pins say failed to add edge detection rpigpio.py when used in a program. When I try to install lgpio, I always get an error like failed building wheel. Can anyone help me solve the problem with my gpio pins?
So I have been trying to do some raspberry pi projects, and I use Raspberry Pi 4 with the latest version of bullseye installed. These days, for some reason, some of my GPIO pins say failed to add edge detection rpigpio.py when used in a program. When I try to install lgpio, I always get an error like failed building wheel. Can anyone help me solve the problem with my gpio pins?
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
Re: Failed To Add Edge Detection, GPIOZERO
Why are you using Bullseye? The current version is Bookworm!
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
I am using it as I am on Raspberry Pi 4, I cannot install it through noobs, and don't know how to remove Noobs. And I do not have admin privelege on my computer to install the imager.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
Can you post a short python script that shows this happening?
On my Pi4 running Bullseye 32-bit with all updates, and RPi.GPIO 0.7.0, this works fine:
On my Pi4 running Bullseye 32-bit with all updates, and RPi.GPIO 0.7.0, this works fine:
Code: Select all
from time import sleep
import RPi.GPIO as GPIO
GPIO.setwarnings(True)
GPIO.setmode(GPIO.BCM)
def button_callback(channel):
print ("\ncallback on ",channel)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_OFF)
GPIO.add_event_detect(21, GPIO.RISING, callback=button_callback)
n=0
while True:
print (n,end="")
sleep(1)
n=n+1
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
here is my code:

and here is my physical setup(Pins 3.3v, GPIO4, GND):





My full error is :
This happens with GPIO #4 and GPIO 14 as of now with my Raspberry Pi 4B

and here is my physical setup(Pins 3.3v, GPIO4, GND):





My full error is :
Code: Select all
Traceback (most recent call last):
File "/home/procidic/LightSensor.py", line 2, in <module>
ldr = LightSensor(4)
File "/home/procidic/.local/lib/python3.9/site-packages/gpiozero/devices.py", line 108, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/home/procidic/.local/lib/python3.9/site-packages/gpiozero/input_devices.py", line 679, in __init__
self.pin.when_changed = self._cap_charged
File "/home/procidic/.local/lib/python3.9/site-packages/gpiozero/pins/__init__.py", line 432, in <lambda>
lambda self, value: self._set_when_changed(value),
File "/home/procidic/.local/lib/python3.9/site-packages/gpiozero/pins/pi.py", line 319, in _set_when_changed
self._enable_event_detect()
File "/home/procidic/.local/lib/python3.9/site-packages/gpiozero/pins/rpigpio.py", line 226, in _enable_event_detect
GPIO.add_event_detect(
RuntimeError: Failed to add edge detection
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
Add Device to the import
and add this line to your script *after ldr=.." to see which "pin factory" it is using
My Pi4 running that script does not give an error and shows:
Code: Select all
from gpiozero import LightSensor, Buzzer, Device
Code: Select all
print ("factory=",Device.pin_factory)
Code: Select all
factory= <gpiozero.pins.rpigpio.RPiGPIOFactory object at 0xf730dda8>
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
it says factory: noneneilgl wrote: ↑Tue Jul 29, 2025 9:56 pmAdd Device to the importand add this line to your script *after ldr=.." to see which "pin factory" it is usingCode: Select all
from gpiozero import LightSensor, Buzzer, Device
My Pi4 running that script does not give an error and shows:Code: Select all
print ("factory=",Device.pin_factory)
Code: Select all
factory= <gpiozero.pins.rpigpio.RPiGPIOFactory object at 0xf730dda8>
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
What happens if you run this script, which sets the "pin factory"
Code: Select all
from gpiozero import LightSensor, Device
from gpiozero.pins.rpigpio import RPiGPIOFactory
Device.pin_factory = RPiGPIOFactory()
ldr = LightSensor(4)
print ("factory=",Device.pin_factory)
print (ldr.value)
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
Still says failed to add edge detection.neilgl wrote: ↑Wed Jul 30, 2025 10:05 amWhat happens if you run this script, which sets the "pin factory"Code: Select all
from gpiozero import LightSensor, Device from gpiozero.pins.rpigpio import RPiGPIOFactory Device.pin_factory = RPiGPIOFactory() ldr = LightSensor(4) print ("factory=",Device.pin_factory) print (ldr.value)
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
Guys, I decided to install bookworm on my Raspberry Pi. I rewrote the OS to bookworm, so the gpio pins would work. If it does work, I will let you know.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
Ok bookworm or bullseye on the Pi4 should work fine.
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
The Error is Gone, and now I have lgpio, but now it says GPIO busy instead, even though I never ran any gpio applications beforehand.
I was installing Argonone configuration at the time of running the script.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
On Pi4 running Bookworm 64-bit, running this script (LightSensor.py) in Thonny does not give any error:
I do not have an Argon case.
So maybe that "Argonone configuration" is doing something to affect the GPIO e.g. fan control or some other service running in the background?
What is that "Argonone configuration" = maybe a script downloaded from the argon site?
Code: Select all
from gpiozero import LightSensor
ldr = LightSensor(4)
print (ldr.value)
So maybe that "Argonone configuration" is doing something to affect the GPIO e.g. fan control or some other service running in the background?
What is that "Argonone configuration" = maybe a script downloaded from the argon site?
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
It wasn't the case. I ran it today, as the script was done downloading, but it still said GPIO Busy. This occured on Pin 4 and 14.neilgl wrote: ↑Thu Jul 31, 2025 7:48 pmOn Pi4 running Bookworm 64-bit, running this script (LightSensor.py) in Thonny does not give any error:I do not have an Argon case.Code: Select all
from gpiozero import LightSensor ldr = LightSensor(4) print (ldr.value)
So maybe that "Argonone configuration" is doing something to affect the GPIO e.g. fan control or some other service running in the background?
What is that "Argonone configuration" = maybe a script downloaded from the argon site?
I'm not sure what is wrong. I use the extention pins on my argon case.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
If you get time, install Bookworm again, then without any Argon downloads, run the gpiozero script.
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
I need the argon script for my fan.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
Yes you can install the Argon script later, after checking that the gpiozero script works before the argon install (and maybe not after)
Re: Failed To Add Edge Detection, GPIOZERO
There is a similar error reported for a some time now.
https://github.com/gpiozero/gpiozero/issues/1135
https://github.com/gpiozero/gpiozero/issues/1135
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
That old issue does not seem to be present now?
Anyway, with a fresh install of Bookworm 64-bit, do all updates, run the script (as above)
No errors of the type "Failed To Add Edge Detection"
Anyway, with a fresh install of Bookworm 64-bit, do all updates, run the script (as above)
Code: Select all
python LightSensor.py
0.0
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
It wasn't specific for Light Sensor. It was for any electronic component I pluggged into GPIO 4 and 14. It no longer is Failed to add edge detection, but rather GPIO Busy.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
Seems to be the Argon script causing the issue.
On the Pi4 with Bookworm 64-bit, LightSensor.py was working OK (GPIO 4). Then download and run the Argon script (curl.... | bash)
The same script now fails with "gpio busy"
Note I have not (yet) done 'argon-config'
I might look at the cause when I get a minute...
On the Pi4 with Bookworm 64-bit, LightSensor.py was working OK (GPIO 4). Then download and run the Argon script (curl.... | bash)
The same script now fails with "gpio busy"
Note I have not (yet) done 'argon-config'
I might look at the cause when I get a minute...
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
Later, the argon script argonpowerbutton.py (which is run automatically from argononed.py service) uses GPIO4:
So that explains why we get a "GPIO Busy" error.
Workaround - use a different pin for the LDR (GPIO 21 worked for me)
Code: Select all
LINE_SHUTDOWN=4
Workaround - use a different pin for the LDR (GPIO 21 worked for me)
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
worked for me. GPIO 14 had a similar issue. Im buying a raspberry pi build hat, so when I use it, Imma uninstall the script as my pi would not be in the case.neilgl wrote: ↑Sat Aug 02, 2025 11:29 amLater, the argon script argonpowerbutton.py (which is run automatically from argononed.py service) uses GPIO4:So that explains why we get a "GPIO Busy" error.Code: Select all
LINE_SHUTDOWN=4
Workaround - use a different pin for the LDR (GPIO 21 worked for me)
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
-
- Posts: 20
- Joined: Tue Jul 29, 2025 5:36 pm
- Location: Montgomery County, Maryland, United States
Re: Failed To Add Edge Detection, GPIOZERO
neilgl Thank you for your help.
Code: Select all
def signature():
name = input("sign: ")
print("name")
signature()
- neilgl
- Posts: 11167
- Joined: Sun Jan 26, 2014 8:36 pm
- Location: Near The National Museum of Computing
Re: Failed To Add Edge Detection, GPIOZERO
OK it was interesting.