WS2812 Addressable LEDs: Raspberry Pi Quickstart Guide

Hey Phillip,

I can’t notice any issues with the circuit which you’ve sent other then checking the continuity and the script that you’re running on the Pi (also ensuring that the GPIO is being controlled correctly with another script) as well as checking the soldering joints for continuity to ensure that there’s no shorting on the custom joints. Hopefully one of these steps will identify your issue.

All the best with it!

Bryce
Core Electronics | Support

Thanks Bryce,

I actually have investigated since I posted that and the issue was that the level shifter I used was of a different kind, apparently. It has to be fed 5V only. Providing those 5V supplies the 3.3V to OUTPUT current, i.e. feeding a 3.3 Volt current to the Pi. If someone runs into similar issues, maybe this will be of interest to them: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=261663#p1596202 where it is discussed. I have now moved my project over to a Arduino which provides 5V natively.

Hello,



I am sort of confused and really need a bit of help! I have two questions. My first question is that if there’s a 5V pin on the Pi, then why would you need to use a Logic Level converter? Can’t you directly connect the LED strip to the Pi?



My second question, is that I am using a LED strip that says “24V” on the ends of the strip where there are the labels for all four of the wires running through. So if it is 24V and I cut the strip short, then will it still be the same amount of power, or would it reduce? And if it does not reduce, then how can i use a 3.3V to 5V converter?



Thank you so much!

Hey Sanju,

To answer your questions, the Pi’s 5V rail is only a fixed supply that connects to the power supply of the Pi and doesn’t have any logical capabilities, only acting to power devices that require a 5V input of a low current continuously, so it is not advised to connect the LED strip directly to the Pi if it is a high powered appliance. As for your second question the logic to control the LED is not necessarily the same voltage as the LED itself, in this case it’s an awkward 5V between the 3.3V of the Pi and the 24V requirement of the LED if the LED that your using has a 5V logic requirement so a logic level converter is essential.

As for the power requirement cutting the strip shorter will decrease the power requirement, but not the required voltage. This occurs because power is the product of current (a difference in charge per unit time) and voltage (the relative strength of the ‘force’ between two parts on a circuit, also known as EMF) so cutting the strip shorter will decrease how much power is required to operate it continuously as having less LED will require less current, but the voltage should remain the same to maintain brightness. Reducing the voltage no matter the length of strip will decrease the power usage but also the brightness of all LED and at a certain level it will cut of almost completely (as is the nature of LED).

I hope this explanation helps you understand how the system operates. All the best with it!

Bryce
Core Electronics | Support

thank you for the help ,
is this example also good for ws2815 ?
I managed to install and run the example script without LEDs and without Logic Level Converter (ordered just now) as I do not have one just now (all locks good) when I connect my LEDs it dose not light :frowning: .
If not please point me in the right direction.
Thank you in advance
Mihai L.

It works like charmed , I connected the DI with BI wrong , Corected it and it locks SUPER thank you

Hi Mihai,

WS protocols are all very similar, all being based off WorldSemi’s designs (hence the name) below I’ve attached some useful links to take a look at which should help you get a better understanding of how to setup WS2815 LED strips and all kinds of various protocols. All the best with it!

http://www.world-semi.com/solution/list-4-1.html (Most useful resource for this situation)

Bryce
Support | Core Electronics

Raspberry pi 3b+, 8 bit neopixel bar, freetronics logic level converter, breadboard. Jumped as per the diagram.
Running from terminal and have done the uncomment part in the boot config.
All works apart from one problem:
All pixels light as soon as power applied and remain this way throughout the test and remain lit even after “-c”.
Sometimes they all light bright white or a mix of colours but always a few bright white, the strandtest runs over the top, strandtest interrupted and the previously “error lit” pixels remain lit.
My only guess is a hardware issue, perhaps bad solder or over heat while soldering on the level converter, although nothing immediately visible.
My plan: use my extra level converter and try again.
Any other suggestions or tests I could do?

Hi Naughton,

Interesting problem. I’d imagine this is being caused by a faulty connection, but as a test, do you have another microcontroller available that you could use to try and develop the rig without the Pi and see whether the issues are able to be replicated. Please let us know if you’re able to resolve your issue, as this would be very helpful for other users in the future.

All the best with it!

Bryce
Core Electronics | Support

Hey guys! Great tut, thank you :smiley: Running into an error with my install maybe? Please halp.

Some trouble here…seems like I’m running into same problem with line 9 of the rpi_ws281x module:

pi@raspberrypi:~/rpi_ws281x/python/examples $ sudo python strandtest.py 
Traceback (most recent call last):
  File "strandtest.py", line 9, in <module>
    from rpi_ws281x import *
ImportError: No module named rpi_ws281x

Here’s my install log:

pi@raspberrypi:~ $ curl -L http://coreelec.io/33 | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
100   741  100   741    0     0    251      0  0:00:02  0:00:02 --:--:--   251
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.6).
git is already the newest version (1:2.20.1-2+deb10u3).
python-dev is already the newest version (2.7.16-1).
scons is already the newest version (3.0.1-2).
swig is already the newest version (3.0.12-2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Cloning into 'rpi_ws281x'...
remote: Enumerating objects: 831, done.
remote: Total 831 (delta 0), reused 0 (delta 0), pack-reused 831
Receiving objects: 100% (831/831), 362.70 KiB | 1011.00 KiB/s, done.
Resolving deltas: 100% (509/509), done.
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Version version.h
CC      main.o
CC      mailbox.o
CC      ws2811.o
CC      pwm.o
CC      pcm.o
CC      dma.o
CC      rpihw.o
AR      libws2811.a
RANLIB  libws2811.a
LINK    test
scons: done building targets.
running install
running bdist_egg
running egg_info
creating rpi_ws281x.egg-info
writing rpi_ws281x.egg-info/PKG-INFO
writing top-level names to rpi_ws281x.egg-info/top_level.txt
writing dependency_links to rpi_ws281x.egg-info/dependency_links.txt
writing manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
reading manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
writing manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
creating build
creating build/lib.linux-armv7l-2.7
copying neopixel.py -> build/lib.linux-armv7l-2.7
running build_ext
building '_rpi_ws281x' extension
swigging rpi_ws281x.i to rpi_ws281x_wrap.c
swig -python -o rpi_ws281x_wrap.c rpi_ws281x.i
creating build/temp.linux-armv7l-2.7
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-armv7l-2.7/rpi_ws281x_wrap.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/rpi_ws281x_wrap.o -L../. -lws2811 -lrt -o build/lib.linux-armv7l-2.7/_rpi_ws281x.so
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
copying build/lib.linux-armv7l-2.7/_rpi_ws281x.so -> build/bdist.linux-armv7l/egg
copying build/lib.linux-armv7l-2.7/neopixel.py -> build/bdist.linux-armv7l/egg
byte-compiling build/bdist.linux-armv7l/egg/neopixel.py to neopixel.pyc
creating stub loader for _rpi_ws281x.so
byte-compiling build/bdist.linux-armv7l/egg/_rpi_ws281x.py to _rpi_ws281x.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying rpi_ws281x.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying rpi_ws281x.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying rpi_ws281x.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying rpi_ws281x.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
writing build/bdist.linux-armv7l/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/rpi_ws281x-1.0.0-py2.7-linux-armv7l.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing rpi_ws281x-1.0.0-py2.7-linux-armv7l.egg
Removing /usr/local/lib/python2.7/dist-packages/rpi_ws281x-1.0.0-py2.7-linux-armv7l.egg
Copying rpi_ws281x-1.0.0-py2.7-linux-armv7l.egg to /usr/local/lib/python2.7/dist-packages
rpi-ws281x 1.0.0 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.7/dist-packages/rpi_ws281x-1.0.0-py2.7-linux-armv7l.egg
Processing dependencies for rpi-ws281x==1.0.0
Finished processing dependencies for rpi-ws281x==1.0.0 

Hi Andrew,

Could you please use sudo nano strandtest.py when in the appropriate directory. Just to confirm that this issue isn’t being caused by any of the syntax within the script, as that appears to have the appropriate dependencies installed. Thanks.

Bryce
Core Electronics | Support

Yes, I’m able to open strandtest.py in nano…

What is the default version of python?
From the cli prompt, “python --version”

The output above shows the rpi-2382x being installed for python 2.7, so if you are running python 3.6 it will not find it.

Hi @Bryce

From the readme for the git repository currently used by the tutorial:

This Python code is being phased out and replaced with https://github.com/rpi-ws281x/rpi-ws281x-python

If you’re just looking to install the Python library, you can: sudo pip install rpi_ws281x or sudo pip3 install rpi_ws281x depending on your Python version of choice or find releases here: https://github.com/rpi-ws281x/rpi-ws281x-python/releases

So please update the tutorial to install the module with pip/pip3 as above.

Thanks.

Edit: fix autocorrect f*up

1 Like

Hey @Robin57159

Thanks for letting me know :+1:. I’ll add it as an edit to be completed with the next site updates.

Bryce
Core Electronics | Support

Hey I have a strip of these leds, I followed the instructions above however only around 20 leds light up (out of the 150) and they flash erratically, I dont have a logic level shifter attached… would this be the problem?

Hi Harry,

It could be a few things. Are you supplying enough power?

I’d suggest starting a new topic with some photos of your wiring and code.

Regards,
Oliver
Support | Core Electronics

Hi @Harry129816

Let’s do a little math with the wild assumption that the individual LEDs will draw in the region of 10 to 20 ma.

We will need to be able to provide 1.5 to 3.0 amps to drive 150 LEDs. As @Oliver suggested, check your power source is capable of providing this.

Hello everyone,

I have a LED Strip of 1 meter with 60 LEDs. I use a switching power supply that give 5V and 10 A as output.
I am using a Raspberry pi 3 to address the LEDs through a logic converter 3.3V 5V.
When I am running strandtest.py with all the 60 LEDs it worked, but no LED light up.
I have cut one LED from the strip. When I am running strandtest.py with only one LED it worked, and the LED light up.
I think the problem is caused by a lack of power. What is the recommended switching power supply to get all 60 LEDs light up

Here is the link to the switching power supply, that I am actually using.

Best regards,
Wilfried Wakeu

Hi Wilfried,

That should be enough power for just 60 WS2812s (assuming this is indeed what you’re using?).

It is possible you’re running into a speed limit on your logic level converter, again, depending on what you’re using.

Can you make a new topic and give us some photos of how you’ve got everything wired up, and let us know exactly which LEDs you’re using?

Regards,
Oliver
Support | Core Electronics

In your example, the Pi is being powered by a separate power adapter. I’d like to power both the Pi and LEDs using the same 5V DC power plug. Is it permissible to connect a wire from the 5V adapter to one of the 5V pins on the Pi? If not, how should it be wired?

Thank you!