1

Background

I'm trying to control a single WS2812b LED strip from a Raspberry Pi. I've followed this tutorial from raspberrypi.com (with the exception of Prep & Installation step 4, because I couldn't find snd-blacklist.conf).

That didn't work, so I also tried this tutorial (which involved adding a Logic Level converter), and when that didn't improve things, a few other tutorials/videos, all to no avail.

Code & Output

The first tutorial got the closest. It had me use this github library, where I eventually ran strandtest.py. It appeared to partially work, but not entirely. I wasn't sure (and I'm still not) if this is a hardware or software issue, so I reduced the code to the minimum possible where it still turns on at least one LED.

import time
from rpi_ws281x import *

LED_COUNT      = 14      # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53

strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
strip.begin()

while True:
    print ('Running display')
    for j in range(100):
        for i in range(strip.numPixels()):
            strip.setPixelColor(i, Color(50, 50, 50))
        strip.show()
        time.sleep(.05)

Yes, those nested loops are necessary. Simplifying to something like this without loops doesn't turn on any LEDs at all:

strip.setPixelColor(0, Color(100, 100, 100))
strip.show()
time.sleep(10)

Demo Video

When I run that code (the first block), this is what happens: https://youtu.be/nzMCeyBNY50

Every time I run the code, I wait a few seconds, and eventually some LEDs turn on. It's different every time: sometimes a couple turn on, sometimes all of them, sometimes they turn off again for a little bit as it keeps running, etc. This was true even before I switched to using the Logic Level converter from the second tutorial, and happens the same way even if I run the original strandtest.py.

Parts

I've followed this schematic from the second tutorial linked above. Note that I'm powering 14 LEDs currently (but would like to do the full strip in the future). Also, this schematic shows the power for the LEDs running through the breadboard, but I've soldered the red power+ directly instead.

schematic from core-electronics.com

Here's a list of the parts I used:

0

Welcome! I am sorry to say you are light on the 50 watt (5 * 10 = 50) power supply, here is why: (Ohm's law states volts * amps = watts). Your Pi needs about 3 amps or 15 watts. You now have 7 amps or 35 Watts remaining. Next you have 5 meters of leds at 18 watts per meter (per your link) so that is (18 * 5) 75 watts. You had 35 watts left after the Pi so you are at a negative 40 watts or -8 amps. Best solution get another power supply and if you use both be sure to connect the grounds of each together and to the Pi ground.

7
  • Sorry, my explanation of the wiring must have been unclear: the pi is powered through the USB port by a standard AC to USB converter, completely separate from the power to the LEDs. I measured the led circuit and it was hitting about 4.8 V (what I'd expect), but it was hardly drawing 1 amp, because I'm only using 14 LEDs and they aren't even fully lit. (Note that I will use more LEDs later if I get this working, and may have to change the power supply).
    – kviLL
    Jul 25 at 0:38
  • One thing I did notice was that the data line was barely at .1 volts (with or without the logic level converter). I thought the pi was supposed to be sending 3.3 V which I would increase to 5 V, but unless I'm measuring poorly (which is definitely a possibility) then the voltage is very low.
    – kviLL
    Jul 25 at 0:40
  • Schematics generally tell more than pages of words!
    – Gil
    Jul 25 at 2:36
  • 1
    @kviLL please edit your question and explain how the LEDs and Pi are being powered.
    – joan
    Jul 25 at 7:58
  • I had included a link to a schematic from one of the tutorials I followed. I've edited the post now to embed the image directly instead, so hopefully that's more clear.
    – kviLL
    Jul 25 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.