Raspberry Pi 5 GPIO access (pigpio binding)

Platform information:
Hardware: Raspberry Pi 5
Issue of the topic: pigpio does not support RPi5

Hi all, I just upgraded my hardware from a RPI4 to a RPi5 and realized that pigpio does not work on the latter, see also Github.

To be able to access the GPIOs with my Openhab installation, i created a docker container running mqtt-io incombination with gpiozero as a workaround. With the container running you can access the RPi5 GPIOs via MQTT.

I uploaded the corresponding code and some brief instructions to github.

Please feel free to use the workaround, in case you come accross the same issue.

1 Like

Thanks for the post! This is one of those rare cases where I needed to move a post into the Tutorials and Solutions category. It is more clear that you’ve posted a workaround (or for some perhaps a permanent approach to control GPIO on machines other than the same one where OH is running.

Hello radioaktivman,

I have openhab4 instance on my Raspberry Pi 4 and it works perfectly. So when PI5 has arrived on the market I decided to upgrade it and as you guess this it the reason I’m in this thread :wink:

pigpio is not developed anymore and does not work on PI5 nowadays.

I was trying to run this container on my PI5 and it finishes with these errors below. I have a quite good knowledge of Linux but I’m totally green in Python so I don’t know how to deal with it. Maybe I’m doing something wrong…

2024-05-15 10:55:50 mqtt_io.__main__ [ERROR] MqttIo crashed!
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/server.py", line 1447, in run
    self._init_gpio_modules()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/server.py", line 273, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/server.py", line 131, in _init_module
    return module_class(module_config)
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/modules/gpio/gpiod.py", line 35, in setup_module
    self.chip = gpiod.chip(self.config["chip"])
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiodcxx/__init__.py", line 105, in __init__
    self.open(device, how)
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiodcxx/__init__.py", line 132, in open
    chip_struct = func(device)
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiod/__init__.py", line 1098, in gpiod_chip_open_lookup
    chip = gpiod_chip_open_by_label(descr)
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiod/__init__.py", line 1065, in gpiod_chip_open_by_label
    chip_iter = iter(gpiod_chip_iter())
TypeError: iter() returned non-iterator of type 'NoneType'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/__main__.py", line 115, in <module>
    main()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/server.py", line 1447, in run
    self._init_gpio_modules()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/server.py", line 273, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/server.py", line 131, in _init_module
    return module_class(module_config)
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/local/lib/python3.8/site-packages/mqtt_io/modules/gpio/gpiod.py", line 35, in setup_module
    self.chip = gpiod.chip(self.config["chip"])
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiodcxx/__init__.py", line 105, in __init__
    self.open(device, how)
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiodcxx/__init__.py", line 132, in open
    chip_struct = func(device)
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiod/__init__.py", line 1098, in gpiod_chip_open_lookup
    chip = gpiod_chip_open_by_label(descr)
  File "/usr/local/lib/python3.8/site-packages/gpiod/libgpiod/__init__.py", line 1065, in gpiod_chip_open_by_label
    chip_iter = iter(gpiod_chip_iter())
TypeError: iter() returned non-iterator of type 'NoneType'

Config is modified:

mqtt:
  host: localhost
  topic_prefix: home

gpio_modules:
  - module: gpiod
    chip: gpiochip4
    name: rpi


digital_outputs:
  # Pin 1 is an output connected to a light
  - name: GPIO21OUT
    module: rpi
    pin: 21
    inverted: TRUE
  - name: GPIO20OUT
    module: rpi
    pin: 20
    inverted: TRUE
  - name: GPIO16OUT
    module: rpi
    pin: 16
    inverted: TRUE
  - name: GPIO12OUT
    module: rpi
    pin: 12
    inverted: TRUE

As you see a part of it is from your example, because I even cannot run this container so I still haven’t it adapted for my needs.