When the Raspberry Pi 5 came out, it was released on completely different underlying hardware than the previous Raspberry Pi boards. Specifically, it used the RP1 chip to handle pretty much all of the Peripheral IO. This made some of the existing libraries such as RPi.GPIO and the NeoPixels stop working and alternatives needed to be found.
For Blinka, libgpiod was originally used because many of the other supported boards had worked with this library and with some testing, I found it to be about 3 times faster than the recommended gpiozero. However, this lacked some crucial features such as PWM. Eventually, I stumbled upon rpi-lgpio, which was basically a wrapper around another library called lgpio, and served as a drop-in replacement for RPi.GPIO and included PWM. Unfortunately, because the RP1 chip remained undocumented, the only option for folks to use NeoPixels was with the Adafruit_CircuitPython_NeoPixel_SPI library and it used the SPI port, so it couldn't be use in conjunction with another SPI device.
However, with the release of the RP1 documentation, a new library was written to make use of the NeoPixels in a similar way to that of the Pi 4, freeing up the SPI port. However, at the time of this writing, changes to allow access to the PIO through the kernel are new and it will require a firmware upgrade, which is generally not recommended under normal circumstances as it hasn't been as thoroughly tested.
An update to the kernel is required to run this, which is generally not recommended under normal circumstances.
Installation
Make sure you already have Blinka installed. After that, you will want to first start by checking the permissions to see if a firmware update is necessary. Type the following:
ls -l /dev/pio0
If the response is no such file or directory
, then you will need to update the firmware.
You can update the firmware by running the following command:
sudo rpi-update
When it asks if you would like to proceed, choose yes.
After updating it, you will need to reboot the pi:
sudo reboot
Making sure you have your virtual environment activated first, you will need to install the Adafruit_Blinka_Raspberry_Pi5_Neopixel library:
pip install Adafruit-Blinka-Raspberry-Pi5-Neopixel
Updating Permissions
After installing the necessary items, you will want to check that you have the appropriate permissions. You can check this by running the following command again:
ls -l /dev/pio0
If it shows that both group and file are owned by root, you will need to update the permissions by adding to the rules file.
You can update the rules file, by typing the following:
sudo nano /etc/udev/rules.d/99-com.rules
Add the following line to the end of the file:
SUBSYSTEM=="*-pio", GROUP="gpio", MODE="0660"
Go ahead and reboot once more. When you type the command to check, it should show gpio as one of the items:
To get the led_animation.py example code onto your Raspberry Pi, you can use the wget command:
wget https://raw.githubusercontent.com/adafruit/Adafruit_Blinka_Raspberry_Pi5_Neopixel/refs/heads/main/examples/led_animation.py
To run the example, you will need a couple more libraries installed. Making sure you have your virtual environment activated first (if you get an error, it's likely not activated), install using the following command:
pip install adafruit-circuitpython-pixelbuf adafruit-circuitpython-led-animation
The example expects your NeoPixels to be connected to pin D13, but you can adjust the code to use any pin as needed. You may also need to adjust the number_of_pixels
variable and byteorder
parameter in the Pi5Pixelbuf initializer to match your actual hardware.
Finally, you can run the example with the following command:
python led_animation.py
You should see a variety of different animations run on the NeoPixels.
Page last edited December 23, 2024
Text editor powered by tinymce.