Display Hat Mini - failed to add edge detection

Hi All,

I have a Display Hat Mini on a Raspberry Pi Zero. Just setting things up and have run into a few issues, the current one being getting a ‘failed to add edge detection error’.

I tried to run pwm-backlight.py and got this error in relation to line 43 (displayhatmini.on_button_pressed(button_callback) )

GPIO.add_event_detect (pin, GPIO.BOTH, callback=callback) runtime error failed to add edge detection

It also referenced line 99 ( GPIO.add_event_detect(pin, GPIO.BOTH, callback=callback)) from displayhatmini __ init __.py

A quick google led to some apparent issues with RPi_GPIO which is imported in displayhatmini, suggesting that rpi-lgpio be used instead.

This is pushing my knowledge of effective python and packages etc, but I did try to uninstall rpi-gpio, install rpi-lgpio, in my virtual environment where I have the script and packages, but that appears to have just uninstalled rpi-gpio (no longer there in Thonny packages). I also don’t know whether I need to change anything in the original displayhatmini __ init __.py when it imports rpi-gpio.

I’m obviously a beginner, and it’s compounded by the zero being incredibly slow which makes me think I should do all of this on a regular pi, which I also have, to optimise before bringing everything over to the zero.

Any advice, comments or directions to more resources would be great!

If helpful for advice, my end goal in all of this is to actually just use the zero and display to run a simple start/stop timer with few words and a small image on the screen. I thought I would start with the example scripts to familiarise myself, but if I’m trying to solve a problem that I won’t even eventually have given my goal, I am also open to any simpler practice scripts.

Thanks all!

Can you give the commands you used to uninstall rpi-gpio, and then install rpi-lgpio? The problem could be that you have multiple versions around: one version maintained by the PiOS (via apt), the other maintained via pip.

You could also post the output of the following commands: dpkg -l | grep -i gpio and (with activated virtual env): pip3 list.

I don’t think you have to change anything in the source of the displayhatmini library, since rpi-lgpio claims full compatibility.