WS2812 Addressable LEDs: Raspberry Pi Quickstart Guide

I am also a beginner and have several questions about this guide and setup.

  1. I am currently trying to use two 5m 60 LEDs/m WS2812B Light Strips and am wondering what kind of power supply I would need.
  2. Is this compatible with a Raspberry Pi in my current setup?
  3. Is there anything I need to look out for when hooking everything up? Not trying to fry my RSP or the lights.
  4. Is there any way to reduce discoloration?

Any tips would be helpful. Please help me out.

Hi Alex,

If you’re looking for more nitty-gritty info on WS2812s, you can’t beat Adafruit’s NeoPixel Uberguide:

Have a read through that, and let us know if any questions go unanswered :slight_smile:

-James

When I try to install the python code, it gives me the message " can’t open file ‘setup.py’: [Errno 2] No such file or directory"
Is there a fix to this?

Can someone please help with this? I have been trying for 3 days now with no luck. I get the message

[bash: line 22: cd: python: No such file or directory python: can’t open file ‘setup.py’: [Errno 2] No such file or directory]

Is there any way to fix this?

1 Like

@Alexander207140 @Adrian200392 @tsykes We’ll take a run at this with gusto today and update you here with what we find.
The guide is well out of date - the underlying package has been updated a lot since we originally authored this guide and we need to re-design the installation procedure.
Sit tight! Help is on the way!

1 Like

How to run WS2812B LEDs as of 27-JUL-2022

Install the package from the terminal. Must use sudo and must use pip3

sudo pip3 install rpi_ws281x

Clone the repo (to get access to the examples)

cd
git clone https://github.com/jgarff/rpi_ws281x.git

Run Thonny as a super-user

sudo thonny

In thonny, navigate to the example and run it:

You can see in the above screenshot my code is running without issue, and the hardware is working (below)

@Alexander207140 @Adrian200392 @tsykes give this a try and let me know how it goes.

3 Likes

Stuck again, with a new problem. When I run the first command, sudo pip3 install rpi_sw281x, I get the error “Could not find a version that satisfies the requirement rpi_sw281x
No matching distribution found for rpi_sw281x” Any suggestions?

1 Like

Apologies @Alexander207140 - that’s my stupid typo:
sudo pip3 install rpi_ws281x is the correct command
i have updated my original comment

1 Like

hi! im having issues with the rpi_ws281x. when i enter the code :cd rpi_ws281x/python/examples/
i get:
bash: cd: rpi_ws281x/python/examples/: No such file or directory

i also tried installing it again and i got this
sudo pip install rpi_ws281x
Looking in indexes: Simple index, piwheels - Simple index
Requirement already satisfied: rpi_ws281x in /usr/local/lib/python3.9/dist-packages (4.3.4)

the errors are still the same. i was hopinh someone could help? thanks!!

2 Likes

Hi Brittney,

Happy to dissect these errors for you!

bash: cd: rpi_ws281x/python/examples/: No such file or directory

This one means it can’t find the rpi_ws281x folder, which I believe gets created when you run step 1 in the tutorial (curl -L http://coreelec.io/33 | bash) it creates this folder.

You don’t need to run these steps according to the updated post from Michael:

sudo pip install rpi_ws281x
Looking in indexes: Simple index, piwheels - Simple index
Requirement already satisfied: rpi_ws281x in /usr/local/lib/python3.9/dist-packages (4.3.4)

This means your python package is already installed. Great! Nothing more for you to do.

Follow the rest of Michael’s instructions (running Thonny etc. and you should be back on track!
-James

2 Likes

Try pip3 install as Michael mentioned.

1 Like

I had a heck of a time getting it to work. Ended up in my /boot/config.txt files to use the PWM GPIO18 option I had to uncomment dtparam=audio=on line in addition to adding in the hdmi_force_hotplug=1 and hdmi_force_edid_audio=1 lines. I was initially trying on older RPI 1 Model B+ and RPI3 Model B. Turns out works on both with the config.txt file set properly. I was worried that speed on older devices was not good.

2 Likes

Hi! I’m having troubles with my setup. I’m using RPi 4b and I was able to connect everything as shown in the guide but only the first lamp lights up, I know It’s not power issue because when I connected it with Arduino all LEDs light up without any problems. Could someone help me debug this please? Thanks!

Hi @Nikodem263067 - wecome to the forums :smiley:

in the code there will be a variable that specifies the number of less eg. NUM_LEDS or similar. What is this set to?

A picture of your setup might also help a lot, just in case

I have WS2815 LEDs.
These are 12v with a LEDs with Di/Bi.
These operate correctly, however if I leave the lights off (rpi still on) after approx 3+ hours some LEDs turn on (random colours).
The length is 240leds (3.15A).
Would putting a drop down resistor from the data line (Di) to ground solve this without interfering with the Di signal? And if so what size resistor would I use?
PS. The Bi line is down to ground directly.
Attached is photo of my setup connected directly to rpi.
So I was thinking of adding a resistor between Di and GND

2 Likes

Hi Frank. Welcome back :slight_smile:

When you say you turned the LEDs off, do you mean that you sent a data message that set all the LEDs to zero brightness?

Maybe, instead of sending a data, you could you could cut 12v and stop powering the LEDs entirely. No power, no flashing.

You could achieve this with a mosfet.
I learned about MOSFETs here:

I’d recommend this mosfet

12v to the collector, emitter to the LEDs (through a resistor).
When you want the LEDs to stay off for a long period of time, you could write some code that sends a LOW signal to the gate cutting power to the LEDs entirely.

What do you think?
Pix :heavy_heart_exclamation:

1 Like

Yeah data message.

Unfortunately, I cant cut 12V supply as this is all controlled by another controller (Used for a CNC). So the 12V system is outputted by this controller.

The Data sent I believe is a brightness off used by a gcode command.

So this is why im assuming noise is producing a signal which is why these lights get turned on.

Because these leds are used based on activity of the CNC, or its status they do need to remain on and not actually be turned off via source.

Hence why I thought maybe a pull down resistor on data line of led strip, so any transient voltages get pulled to ground ?

1 Like

Any update?
Attached is pic of led’s after a few hours of it being turned off (brightness set to 0).
Because this is controlled as mentioned earlier from another controller. I’m assuming transient voltages are being induced into the data line. So hopefully a drop down resistor from data line to gnd will stop this.
Question is what size for a strip length of 240leds (3.15A) @ 12Vdc?

1 Like

Hi Frank,

Sorry for the delay in getting back to you!

Before we get too deep into the discussion would it be possible to send through some more context about your setup?

  • Do you have access to the code running on the PI?

Is the CNC’s input to the LEDs through the PI? i.e. a serial command sent through or intercepted?)

A 10k ohm pull-down ought to work fine,

There’s a good topic here where a Maker is running WLED, if we have direct control the main LED controller we can cut power to the LED strip with a relay (just a different component to Pix’s idea)

Liam

Hi Liam, would you suggest a 10K ohm resistor from data(di) to gnd? Or a 10K variable resistor?
My concern with the resistor is that it may mess up the data when I want it On and or set to a certain color?

1 Like