0

For starters, I'm using a generic 5 meter, 30 pixels/meter, 5V WS2812B LED strip. I've got a 5V/20A (100W) power supply as well.

I'm using the adafruit-circuitpython-neopixel library, and my code I've been running in the Python shell is below.

The issue is this: when I have the DATA wire from the LED strip connected to board.D18, the VCC (from both ends of the LED strip) connected to the + terminal on the power supply, and the ground (again, from both ends of the LED strip) connected to the - terminal on the power supply, the entire LED strip will light up bright white. Testing from the Python shell, no matter what pixel_order or bpp values I pass into the neopixel.NeoPixel constructor, I am unable to get consistent colors from the LED strip. Most of them will go random colors, occasionally one of them will go the color I input, but most of the time they just stay bright white. They also won't respect any brightness parameter changes.

When I instead connect the grounds from both ends of the LED strip to ground pins on the Raspberry Pi (pins 9 & 14), the LED strip is fully dark and does not come on no matter what commands are passed to it. I bought 5 of these strips, and so far I'm having these issues with 2 of them. I'm at a loss here. What am I doing wrong? Are these LED strips just incredibly poor quality (which wouldn't be surprising considering where I bought them)? Am I programming them incorrectly? Did I wire them incorrectly?

import board
import neopixel

led_pin = board.D18
led_count = 150

pixels = neopixel.NeoPixel(led_pin, led_count, brightness=0.2)
pixels.fill((255, 0, 0))  # attempting to set all LEDs Red
pixels.fill((0, 255, 0))  # attempting to set all LEDs Green
pixels.fill((0, 0, 255))  # attempting to set all LEDs Blue


ORDER = neopixel.GRB

# specifically setting bytes per pixel to 3
pixels = neopixel.NeoPixel(led_pin, led_count, brightness=0.2, bpp=3, pixel_order=ORDER)
pixels.fill((255, 0, 0))  # attempting to set all LEDs Green
pixels.fill((0, 255, 0))  # attempting to set all LEDs Red
pixels.fill((0, 0, 255))  # attempting to set all LEDs Blue

# specifically setting bytes per pixel to 4
pixels = neopixel.NeoPixel(led_pin, led_count, brightness=0.2, bpp=4, pixel_order=ORDER)
pixels.fill((255, 0, 0))  # attempting to set all LEDs Green
pixels.fill((0, 255, 0))  # attempting to set all LEDs Red
pixels.fill((0, 0, 255))  # attempting to set all LEDs Blue

ORDER = neopixel.RGB

# specifically setting bytes per pixel to 3
pixels = neopixel.NeoPixel(led_pin, led_count, brightness=0.2, bpp=3, pixel_order=ORDER)
pixels.fill((255, 0, 0))  # attempting to set all LEDs Red
pixels.fill((0, 255, 0))  # attempting to set all LEDs Green
pixels.fill((0, 0, 255))  # attempting to set all LEDs Blue

# specifically setting bytes per pixel to 4
pixels = neopixel.NeoPixel(led_pin, led_count, brightness=0.2, bpp=4, pixel_order=ORDER)
pixels.fill((255, 0, 0))  # attempting to set all LEDs Red
pixels.fill((0, 255, 0))  # attempting to set all LEDs Green
pixels.fill((0, 0, 255))  # attempting to set all LEDs Blue

At this point, I've tested the adafruit-circuitpython-neopixel library and the rpi_ws281x library. I've tested with the grounds connected to the Raspberry Pi's GPIO header and with the grounds connected to the power supply's - header. I've even cut the strip down to just 15 LEDs, and it still does not make a difference.

EDIT: I got it working! I cut the strip down to just 15 LEDs, and wired the positive contact from the start of the strip to one of my 5V pins on the Raspberry Pi's GPIO header. It now displays colors and animations properly using both the adafruit-circuitpython-neopixel library AND the rpi_ws281x library. The only problem now is how do I go about powering a much longer strip with the external power supply without disrupting my ability to change the colors and whatnot?

6
  • Are you aware that the data generally is fed in at one specific end only. It is not always obvious which end!
    – CoderMike
    Nov 26, 2023 at 22:15
  • I've only got the data line connected on one end, unfortunately it doesn't appear to be that simple of a solution. I have the data line connected to the data pin that was soldered from the factory. Nov 26, 2023 at 22:43
  • "Am I programming them incorrectly? Did I wire them incorrectly?" We don't know because you haven't said WHAT YOU DID. CircuitPython is an Adafruit aberration designed for microcontrollers - can be installed on Linux (according to Adafruit) but their instructions are out of date and won't work on Bookworm. I suggest you look for a standard Python module.
    – Milliways
    Nov 27, 2023 at 0:34
  • I explained how the setup is wired currently, and posted the code I used to test in the Python shell. I'm not sure what else I could have added to the original post to show "what I did". Nov 27, 2023 at 0:36
  • Maybe I got it wrong from the question and you alread did it this way? The "+" from the power-supply should be connected to the strips "+", the strip's "data-IN" to PI's data-pin and the strip's "-" BOTH to PI's ground AND to the power-supply's "-" Nov 27, 2023 at 20:47

1 Answer 1

0

Try addressing individual pixels to see if you can control them separately. For example:

pixels[0] = (255, 0, 0)  # Set the first pixel to Red
pixels[1] = (0, 255, 0)  # Set the second pixel to Green

Also check you have made data, power, and ground connections correctly.You can also make a PCB with the LEDS for a tidy connection:

https://www.pcbway.com/project/shareproject/PCB_for_WS2812B_2020_with_Pin_Header_Connector_9b46260c.html

1
  • They're currently not lighting up at all, because I have the grounds connected to the GND pins on the Pi's GPIO header at the suggestion of ChatGPT. I'm about to rewire them to the power supply and see if anything changes. Addressing the pixels individually does change the colors, albeit incorrectly. Nov 27, 2023 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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