Sjohn21 / MMM-GPIO-HANDLER

A Handler for GPIO Input and Output for Magic Mirror
MIT License
1 stars 0 forks source link

pigpio doesn't currently work on a raspberry pi 5 #1

Open Kayakbabe opened 5 months ago

Kayakbabe commented 5 months ago

pigpio doesn't currently work on a raspberry pi 5 . could this be modified to use gpiozero? or another library that does work on the 5? The change in the rpi5 is that it uses a seperate chip nw the rp1 chip for gpio control instead. With the increased power of the rpi 5, i think controlling led lights around or with the mirror would be very useful. Especially to use them for ambient notifications.

Kayakbabe commented 5 months ago

I found this...https://bobrathbone.com/raspberrypi/gpio_converter.html
which might help but I think it's for rpi:gpio

Sjohn21 commented 5 months ago

Thanks for opening this issue. As I both use rpi 3's and 4's at the moment I was not aware. A quick read learned me that indeed the the rpi 5 is not supported by the pigpio library and currently it seems that are no plans for support as the architecture is completely different and likely not backwards compatible.

The pigpio-client is a node.js wrapper that uses the pigpio library to communicate with the socket. The link does give insight in libraries, but no wrapper. Writing a node.js wrapper is currently not something I have the time to dive into. As I lack the skills to write such a wrapper I would need to learn, but currently I do not have suffient time in the near foreseeing future. However, I would not be surprised such a wrapper already exists. If such a wrapper exist I think it would be fairly easy to build in a version check and use the correponding wrapper. I will have a look and if anyone has suggestions please let me know.

Sjohn21 commented 5 months ago

I found this...https://bobrathbone.com/raspberrypi/gpio_converter.html which might help but I think it's for rpi:gpio

I did some reading today. For reference this module uses the pigpio-client which exposes the socket interface APIs of the pigpio library (github repo) using nodejs. In this comment of the issue stating it doesn't work on the RPi 5, guymcswain (also the author of pigpio-client and big contributor to pigpio) explains he has the aspiration to update the library to support RPi5, but also states it's not an easy job and needs help. I would if I could, but as stated before I lack the time (and knowledge). If the pigpio library gets updated I assume this module would work (maybe with minor updates) on RPi5.

As that might take a long time or might never happen I've looked into other options. GPIOconverter is indeed for RPi.GPIO and would not work for pigpio. As for gpiozero this library uses Python, but actually uses underlying libraries, including RPi.GPIO, lgpio, rpio, a native approach and finally also pigpio.

Both GPIOconverter and gpiozero list lgpio to be working with RPi5. I see this as the most promising intermediate step as it has a Deamon (no issues with root for Magic Mirror). This library supports PMW, albeit it being only softwarePWM.

However, I could not find a nodewrapper for rgpiod (the lg deamon) just yet. Maybe guymcswain could give me pointers how to write this nodewrapper or is able to convert pigpio-client to a lgpio-client easily as the both deamons/libraries are originally written by the same author and have a lot of similar api functions. I will try to drop him a message.

In the meantime if someone else could help, I am open to support.

Tom-Hirschberger commented 3 months ago

Hi, just stumbled over your module as i updated the release info of my GPIO module in the forum. My module (MMM-GPIO-Notifications) "only" is designed to send notifications based on GPIO events but i had the same problems with my module recently. Main problem with the current libs is you need to know the gpiochip and the line the GPIO you want to address are using. I wrote a converter script which calls the "gpioinfo" command and converts the info into a json file.

Today i released a new version of my module which uses the "opengpio" npm lib to handle GPIO stuff directly in JavaScript. The library supports PWM, too. Maybe this is helpful for you.

Edit: As the current Bookworm release uses kernel 6.6 on Raspberry 4 you will face the same issues even with older Raspberry modules not only with the 5 version