Python RuntimeError: Failed to add edge detection when using GPIO on DietPi

Creating a bug report/issue

[Yes] I have searched the existing open and closed issues

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=9
    G_DIETPI_VERSION_SUB=12
    G_DIETPI_VERSION_RC=1
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’
  • Distro version | bookworm 1
  • Kernel version | Linux coktailmaschine 6.12.25+rpt-rpi-v6 #1 Raspbian 1:6.12.25-1+rpt1 (2025-04-30) armv6l GNU/Linux
  • Architecture | armhf
  • SBC model | RPi Zero W (armv6l)
  • Power supply used | 5V 3A
  • SD card used | SanDisk ultra

Additional Information (if applicable)

  • Hi everyone,

    I’m trying to run some simple Python GPIO code on my DietPi setup, but I’m running into this error:

    GPIO.setmode(GPIO.BCM) GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(LED_GPIO, GPIO.OUT) GPIO.add_event_detect(BUTTON_GPIO, GPIO.BOTH, callback=button_callback, bouncetime=50)

    Error output:

    GPIO.add_event_detect(BUTTON_GPIO, GPIO.BOTH, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Failed to add edge detection

    What I’ve tried so far:

    • Confirmed that I’m using the correct BCM pin numbers

    • Tried running the script with sudo

    • Checked that nothing else is using the GPIO pins

    • Updated DietPi and Python packages

    System details:

    • DietPi version: [your version here]

    • Raspberry Pi model: [your model here]

    • Python version: [your version here]

    • GPIO library: RPi.GPIO

    Has anyone else encountered this on DietPi? Is this a permissions or driver issue, or something with how DietPi handles GPIO?

    Thanks in advance!

This topic was automatically closed 178 days after the last reply. New replies are no longer allowed.