Guide by Tim; Control Multiple Fully-Addressable WS2812B RGB LED Strips with a Raspberry Pi Single Board Computer

Hey John,

Is definitely within the capability of the Raspberry Pi Single Board Computer. You will definitely need to inject extra power with an external power supply. Refer to this fantastic Adafruit guide on the topic if you are planning on powering significantly more LEDs than a single 5 Metre roll. Thermal and electrical considerations need to be taken.

Kindest regards,
Tim!

1 Like

Hey thank you for the guide this is the only one that has got my lights to work in the first place but I am having a similar issue to those above about only the first couple of lights turning on. I have a Raspberry pi 2b and have turned dtparam=audio=on to off and am still having this issue. Any guidance at all would be helpful.

Thanks,
Caleb

1 Like

Just thought I would let you know that I got my lights working using this guide: https://core-electronics.com.au/guides/ws2812-addressable-leds-raspberry-pi-quickstart-guide/
All I needed to do was change 2 config settings and the whole screen immediately worked
Thanks,
Caleb

1 Like

Welcome Caleb,

Thanks for letting us know and glad to hear you got it working :smiley:

Liam

Hello,
This is my first raspberry pi project and I am sure that I have all of the hardware correct, however when I run the code, this error message comes up:


Can’t open /dev/mem: Permission denied
Traceback (most recent call last):
File “/home/cyrus/Desktop/strandtest.py”, line 91, in
strip.begin()
File “/usr/local/lib/python3.9/dist-packages/rpi_ws281x/rpi_ws281x.py”, line 131, in begin
raise RuntimeError(‘ws2811_init failed with code {0} ({1})’.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -5 (mmap() failed)


None of the lights turn on and nothing happens.
Any Ideas??
Thanks for the help.

Hey Cyrus,
Welcome to the Forums!

It looks like you arent running that Script with the right permissions, you might have to try running it with the ‘sudo’ command like this:

sudo python3 /home/cyrus/Desktop/strandtest.py

Give that a go and see if it works.

Cheers,
Blayden

Hello Tim! I’m trying to get my WS2812B Led Strip to work, but they just won’t turn on.

The code is not giving any error, so I’m just at a loss

Hey Teresa,
Welcome to the forums!

Its no good when things stop working suddenly, though I may be able to help. I just need to get a picture of what may be going wrong first.
What Pi model are you using? What length of LED strip have you got and how many LEDs per meter? Have you got an alternate power source like a Plugpack to supply enough current to the LED strip?

Let me know what your current set up looks like and I will try to help out.

Cheers,
Blayden

Hello Blayden!
Thank you for the warm welcoming!

To answer your questions:

-Its a Raspberry Pi 4 Model B
-I have a 5m WS2812B LED Strip

  • 30 LEDs/m (150 LEDs Total)
  • I do have an alternate power supply. Its a 5v 10A Power Supply and I am using a barrel connector

Additional info:

I’m running the strandest.py code (changed the LED_COUNT to 150)
I am running Thonny with administrator privileges (sudo thonny)
I have run sudo nano boot/config.txt and changed dtparam=audio=on to dtparam=audio=off

Attached there are pictures of the setup running the strandest.py code



Hi Tim

Not sure if you can help, but I tried installing the ’ *
dancyPi-audio-reactive-led
’ thing and when I try to run the sudo python3 visualization.py scroll I get the following error.

Traceback (most recent call last):
File "/home/pi/dancyPi-audio-reactive-led/python/visualization.py", line 418, in
led.update()
File "/home/pi/dancyPi-audio-reactive-led/python/led.py", line 144, in update
_update_pi()
File "/home/pi/dancyPi-audio-reactive-led/python/led.py", line 108, in _update_pi
strip._led_data[i] = int(rgb[i])
AttributeError: 'Adafruit_NeoPixel' object has no attribute '_led_data'

Any ideas?

Regards

Hi @Warren249020.

I’ve made a comment on your Github Issue. TL;DR I suspect it’s the config.py constants.

Maybe @Tim will have some more thoughts as well. :slight_smile:

Question about the two LED strip project. Would it be possible to connect the two strips to become one long strip and program the lights on each strip separately? For example, two 50 LED strips to become one 100 strip and LEDs 1-50 are yellow and LEDs 51-100 are purple?

Thanks!

2 Likes

Welcome to the forum Harry!

You absolutely can, you’ll just have to change some of the code.
The number of LEDs and for your example you might want to write a dedicated function to display a couple of colours :smiley:

Liam

1 Like

Liam,

Thanks for the reply. I was 85% sure I could and you just confirmed it for me. Still developing my coding skills.

Thanks again! Great starter fun project!

1 Like

Hi, I followed this guide and when I connect the LED, several lights start turning on and off. Mostly the first LED, and then starts changing color without any code running. I’ve tried connecting to a RPI3b and a RPI4 and always same strange behaviour. Running the code does not light up any leds … When I disconnect the LED power supply and connect it again, the same LEDS as before will light up … and eventually change again. Does the Led strip have any “memory” ?

I’m using a 1 meter WS2812B with 144 leds, with a 5V 2 Amp Power Supply. Raspberry Pi 4 Model B 1.5GHz 2GB. Raspberry Pi Os 64 bit.
Any help appreciated. Thanks

I just discovered that the power suplly was 12v and not 5v :cold_face: :crazy_face:

2 Likes

That means using this method and expanding on it you can easily control four fully addressable WS2812B strips independently with a single Raspberry Pi Single Board Computer.

Anyone managed to get four different strips to work independently? Please let me know how :slight_smile:
In a sense you can control four strips, but it will be two pairs with the same effect.

The top comment talks about the pi only having two channels:

Hi Tiago
Just having a quick look and as the 2 red wires will be connected at the LED strip you will be putting that 12V onto the RPi pin. Now I don’t know exactly that RPi pin is but it is possible that the RPi has been damaged.
Cheers Bob

1 Like

Hey, i have a problem by starting the script:

Traceback (most recent call last):
  File "/home/pi/Desktop/OneStripNeopixel.py", line 34, in <module>
    pixels1[x] = (255, 10, 10)
  File "/usr/local/lib/python3.11/dist-packages/adafruit_pixelbuf.py", line 309, in __setitem__
    self._set_item(index, r, g, b, w)
  File "/usr/local/lib/python3.11/dist-packages/adafruit_pixelbuf.py", line 273, in _set_item
    raise IndexError
IndexError

what can i do?

That would indicate that you are referencing a pixel beyond the end of the pixel chain. What is the value of x when the error occurs? How many pixels have you specified in the constructor for your pixels1 array?

pixels1 = neopixel.NeoPixel(NEOPIXEL, ??, ...)