PidogV2 reporting "GPIO busy" errors on all examples

Hi All,

Complete Newbie here, so please be kind :slight_smile:

I have successfully completed the build on Pidog V2 with a Raspberry Pi 5 and when I first set it up I could run all the example code without issues. However today when I have connected up (connecting via windows powershell works fine), none of the example code will run successfully and in every case I get a series of code errors always finishing with a “GPIO busy” error is being reported. The Pidog will still connect perfectly to the Sunfounder App and all functions on there work without fault. I’ve re-booted both the laptop and the Pidog to no avail and not sure what to try next…any thoughts please?

Example:

sudo python3 1_wake_up.py
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/gpiozero/pins/pi.py”, line 411, in pin
pin = self.pins[info]
~~~~~~~~~^^^^^^
KeyError: PinInfo(number=29, name=‘GPIO5’, names=frozenset({‘BCM5’, 5, ‘BOARD29’, ‘WPI21’, ‘J8:29’, ‘GPIO5’, ‘5’}), pull=‘’, row=15, col=1, interfaces=frozenset({‘’, ‘gpio’, ‘dpi’, ‘uart’, ‘i2c’, ‘spi’}))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/mrcrispi/pidog/examples/1_wake_up.py”, line 7, in
my_dog = Pidog(head_init_angles=[0, 0, -30])
File “/usr/local/lib/python3.13/dist-packages/pidog/pidog.py”, line 131, in init
utils.reset_mcu()
~~~~~~~~~~~~~~~^^
File “/usr/local/lib/python3.13/dist-packages/robot_hat/utils.py”, line 155, in reset_mcu
pin = Pin(“MCURST”)
File “/usr/local/lib/python3.13/dist-packages/robot_hat/pin.py”, line 96, in init
self.setup(mode, pull, active_state)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.13/dist-packages/robot_hat/pin.py”, line 134, in setup
self.gpio = OutputDevice(self._pin_num)
~~~~~~~~~~~~^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/gpiozero/devices.py”, line 108, in call
self = super().call(*args, **kwargs)
File “/usr/lib/python3/dist-packages/gpiozero/output_devices.py”, line 74, in init
super().init(pin, pin_factory=pin_factory)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/gpiozero/mixins.py”, line 75, in init
super().init(*args, **kwargs)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/gpiozero/devices.py”, line 553, in init
pin = self.pin_factory.pin(pin)
File “/usr/lib/python3/dist-packages/gpiozero/pins/pi.py”, line 413, in pin
pin = self.pin_class(self, info)
File “/usr/lib/python3/dist-packages/gpiozero/pins/lgpio.py”, line 126, in init
lgpio.gpio_claim_input(
~~~~~~~~~~~~~~~~~~~~~~^
self.factory._handle, self._number, lgpio.SET_PULL_NONE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/lgpio.py”, line 755, in gpio_claim_input
return _u2i(_lgpio._gpio_claim_input(handle&0xffff, lFlags, gpio))
File “/usr/lib/python3/dist-packages/lgpio.py”, line 458, in _u2i
raise error(error_text(v))
lgpio.error: ‘GPIO busy’

Based on the log information you provided, it appears that the GPIO pins are occupied, which is preventing the PiDogV2 example code from obtaining control of the pins.

You mentioned that you were able to connect with the SunFounder Controller App, correct? This indicates that you could previously run the 12_app_control.py example. However, after restarting the system and attempting to run other example codes, you encounter the same error message about the GPIO pins being occupied.

Therefore, we suspect that you may have configured PiDog to start automatically on boot. This means that after a system restart, the 12_app_control.py example code runs automatically, which allows the app to connect. When you then try to run another example code, it fails because the system cannot run two scripts that require the same GPIO pins simultaneously. This results in the “GPIO pins occupied” error.

Solution:
If you wish to run other examples, you must first disable the automatic startup of PiDog.

Please disable it by running the following commands:

cd ~/pidog/bin
sudo pidog_app disable

After successfully disabling it, restart your system. You should then be able to run other example codes.

That worked perfectly :grinning_face: - thank you so much and what a great service!