0

I had a Pi Zero. I broke it and the SD card, then bought a Pi Zero 2 and installed raspbian v 12 (bookworm).

Now when I try to import devs.py in separate processes, I get lgpio.error: 'GPIO busy'.

devs.py:

from gpiozero import OutputDevice
    
devs = (
    OutputDevice(2),
    OutputDevice(3),
)

shell.py:

import code
import devs

code.interact(local={ 'devs': devs })

The daemon that starts at boot via /etc/rc.local:

import devs

while True:
    do_something()

This is extremely inconvenient. Now every time I need to ssh into the pi and open a shell, I have to comment out the rc.local file and reboot.

I never had this problem when I was using the Pi Zero, so it must have something to do with configuration or the newer OS install.

How can I import devs.py in separate, running processes?

1
  • WHY would anyone use an obsolete SysV tool rc.local on a systemd OS? What is do_something()?
    – Milliways
    Commented Jul 2 at 0:08

1 Answer 1

1

Perhaps use a different backend for gpiozero. lgpio uses the /dev/gpiochip interface to the GPIO rather than the deprecated sysfs interface. The /dev/gpiochip interface only allows one process to access a GPIO at any one time.

Both RPi.GPIO and pigpio should work as backends on a Pi Zero.

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.