steps that i followed to work ws2812B with jetson nano board using spi interface.
Install Pip3 if not already installed:
sudo apt-get install python3-pip
Reboot
Install Adafruit-Blinka 5.8.0:
pip3 install Adafruit-Blinka
Enable SPI on Jetson Nano:
sudo /opt/nvidia/jetson-io/jetson-io.py
Select Configure 40-pin expansion header at the bottom.
Select spi1 (19, 21, 23, 24, 26) and then select Back
Finally select Save and reboot to reconfigure pins. This will create a config file and reboot the Jetson Nano.
After the Nano boots up again, verify you have the SPI devices with the command:
ls /dev/spi*
if it doesnt show any spidevice then try sudo modprobe spidev
Then, we need to set user permissions. In order to use the Jetson GPIO Library, the correct user permissions/groups must be set first. Start by creating a new gpio user group:
sudo groupadd -f -r gpio
sudo usermod -a -G gpio username
Clone the Repo and copy the rules:
cd ~
git clone GitHub - NVIDIA/jetson-gpio: A Python library that enables the use of Jetson's GPIOs
sudo cp ~/jetson-gpio/lib/python/Jetson/GPIO/99-gpio.rules /etc/udev/rules.d
This section was originally written for releases before JetPack 4.3. For JetPack 4.3, the udev rules are in: /lib/udev/rulesd/60-jetson-gpio-common.rules. This should mean that you don’t have to copy the file anymore with JetPack 4.3 and above.
Also, it appears as if the default is for users to be included in the gpio group. You can check this by:
$ groups
Clone the Repo and copy the rules:
cd ~
git clone GitHub - NVIDIA/jetson-gpio: A Python library that enables the use of Jetson's GPIOs
sudo cp ~/jetson-gpio/lib/python/Jetson/GPIO/99-gpio.rules /etc/udev/rules.d
This section was originally written for releases before JetPack 4.3. For JetPack 4.3, the udev rules are in: /lib/udev/rulesd/60-jetson-gpio-common.rules. This should mean that you don’t have to copy the file anymore with JetPack 4.3 and above.
Also, it appears as if the default is for users to be included in the gpio group. You can check this by:
$ groups
Reboot
Update just in case if a library is missing:
sudo pip3 install --upgrade adafruit_blinka
Install CircuitPython NeoPixel_SPI library;:
pip3 install adafruit-circuitpython-neopixel-spi
Reboot again and that´s all!!!
Connect “Din” of your Neopixel to the SPI1_MOSI pin of your Jetson Nano(pin 19 of the expansion header), Gnd to Gnd and 5v to 5v.
sample script :
import board
import neopixel_spi
pixels = neopixel_spi.NeoPixel_SPI(board.SPI(), 10)
pixels.fill(0xff0000)
If an error occurs
Check you have installed this dependencies:
Adafruit CircuitPython BusDevice
pip3 install adafruit-circuitpython-busdevice
Pypixelbuf
pip3 install adafruit-circuitpython-pypixelbuf
python script : make sure that your python3 version is 3.7+
SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
SPDX-License-Identifier: MIT
import time
import board
import neopixel_spi as neopixel
NUM_PIXELS = 12 // change number acc. to length of led stripe
PIXEL_ORDER = neopixel.GRB
COLORS = (0xFF0000, 0x00FF00, 0x0000FF)
DELAY = 1 //change delay according to your requierment
spi = board.SPI()
pixels = neopixel.NeoPixel_SPI(
spi, NUM_PIXELS, pixel_order=PIXEL_ORDER, auto_write=False
)
while True:
for color in COLORS:
for i in range(NUM_PIXELS):
pixels[i] = color
pixels.show()
time.sleep(DELAY)
pixels.fill(0)