WS2812 Addressable LEDs: Raspberry Pi Quickstart Guide

Hi!

This is my first ever electronics project, and I was wondering what kind of power supply I should be using (and if you stock it)?

I have the rasberry pi, and 1m 60px WS2812B strip.

Hi Billie,

60 pixels can use up to 3600mA of power, or 3.6A. The Raspberry Pi will need up to 1.5 amps. You could power them both with this power supply:

You should power your Raspberry Pi and LEDs should be powered directly from the power supply. Do not power your LED’s through the Raspberry Pi GPIO.

I hope that helps! Let me know if you need any further direction!

Thanks so much Stephen! When you say I could power both with that supply, do you mean I can somehow connect two things to it, or that I will need two power supplies?

You could connect two things to it OR use two power supplies. If you are new to electronics it might be easiest to power your Raspberry Pi with the official power supply, and the lights with this power supply. With a little wiring you could power them both with this though.

hello,
can you mention witch logic level shifter you have used?
i also see in your diagram you invert te colors from the pi to the board and from the board to the level shifter (blue and black)

Hi Jurgen,

I believe Michael used this level shifter:

If you want to go next level. Use this:

It works a bit better for the extremely tight timing restrictions of NeoPixels and WS2812.

When I try to run the test, I get this;

pi@raspberrypi:~/rpi_ws281x/python/examples $ sudo python strandtest.py
Traceback (most recent call last):
File “strandtest.py”, line 9, in
from neopixel import *
File “/home/pi/rpi_ws281x/python/examples/neopixel.py”, line 5, in
import _rpi_ws281x as ws
File “/home/pi/rpi_ws281x/python/examples/_rpi_ws281x.py”, line 101, in
WS2811_TARGET_FREQ = _rpi_ws281x.WS2811_TARGET_FREQ
AttributeError: ‘module’ object has no attribute ‘WS2811_TARGET_FREQ’

Would someone be able to point me in the correct direction to solve this?

Thanks,
Lew Heifner

Hi Lew,

Have you followed every step in this tutorial? It sounds like your missing the dependent libraries for this to work. I just ran through this on a fresh install today and everything works as expected.

1 Like

I did indeed follow every step, on a older install. When I followed you advice and did a complete reinstall and followed the tutorial, it worked great. Thanks very much. Now I need the level shifter and I will have it complete. Thanks for your time, I truly appreciate it.
Lew Heifner

1 Like

3 posts were split to a new topic: WS2812 Issues

Hi! I got mine to work without the level shifter, just one question though, why isn’t a resistor put between the GPIO pin and Data IN of the LED strip, how is the GPIO pin defined in the script, doesn’t the pin sink current? Thanks!

Hi Hosni,

Its good practice to put a resistor in the data line. Feel free to add one in!

Many WS2812 LEDs will run on 3.3v logic, but for shorter distances and there is a higher likelihood of errors. It’s easier to just recommend a level shifter and avoid phantom problems!

Thank you. This is a great video, as are others from Core Electronics I have viewed.

Can you please advise whether the below wiring/connection setup is ok:

12v power to 5m LED strip (WS2812)
5v power to Strawberry Pi
Jumper lead linking data line on LED strip with pin (GPIO 18) on Strawberry Pi

Hi Brent,

They both need to share a common ground.
You may need a Logic Level shifter for this to work.
Does your particular strip take 12v power or is it 5v? Incorrect voltage will destroy the LED strip.

The tutorial has a wiring diagram that you can follow if you unsure about how to wire up your LEDs.

Let me know how it goes!

Hi Stephen

Thanks very much for your response.

The LED strip I have is 12v not 5v.

There are two wiring diagrams I see (one on the tutorial page and one in the video). The video one differs to the tutorial page one in that the latter sees power being sent to both a breadboard (?) and led strip, whilst the former only has power being sent to the breadboard.

So follow up questions:

  • neither wiring diagram has power being supplied separately to strawberry pi and LED - is this just because it is easier to use just one power source?
  • is common ground only necessary when one power source is being used
  • re the wiring diagram in video, how is it possible to send the power to both the LED strip and the breadboard? probably this is a very stupid question, but there are only two wires coming from the 2 pin terminal block yet the diagram requires 4 connections (two on led strip and two on breadboard)

Sorry for these likely silly questions.

Brent

Hi Brent,

The Pi is powered separately in these tutorials, and the diagram is electrically the same in the video and the tutorial. A common ground is required always. 3.3v is being supplied BY the Raspberry Pi, not the other way around.

The diagram was changed in the written tutorial to give an example of how to wire both the strip and the level converter on the board. You could always connect two wires to each terminal in the power connector itself though!

Hi Stephen. Thank you so much.

Hi Stephen, I am currently working on a project that will have the LED strip react to the temperature of the weather throughout the day, would you be able to give me some pointers to help me start in editing the files I need to, thanks

Hi Zach,

Once you have the Lights working you should be able to adjust the brightness by scaling the light by the temperature. You could get the temperature in one of two ways you could add a sensor or you could grab the forecast information from the internet.

How would I go about adjusting the colour of each individual LED?