WS2812B LED strip won't light past 75

OK, I need some help here. I have a ESP32 controller connected to a WS2812B 300 count LED strip and I can only get the first 75 LEDs to light up. When I set the LED Count to 76 or higher, then nothing lights up. I’m kind of new to the Arduino world so maybe I missed something. I have the Adafruit NeoPixel library added. I’m using an external 5V power supply with a 390-ohm resistor and a 1000 uf capacitor. Everything is wired just like this diagram; except I’m using pin 2. I had a more complicated script for what I was building, but I ended up just pulling some sample code off the Internet to see if I could get it working past 75. I’ve tried a different power supply, different resistor, different output pin, different brightness, different starting LED. Nothing helps. This is the code I currently have.

#include <Adafruit_NeoPixel.h>
#define LED_PIN 2     // Digital pin connected to the LED strip
#define LED_COUNT 75  // Number of LEDs in the strip
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();  // Initialize the LED strip
  strip.show();   // Turn off all LEDs initially
}
void loop() {
  // Set all LEDs to red
  strip.setBrightness(100);  // a value from 0 to 255
  for (int i = 0; i < LED_COUNT; i++) {
    strip.setPixelColor(i, strip.Color(0, 255, 0));  // Green color (RGB values)
    strip.show();                                    // Send the updated pixel colors to the strip
  }

  delay(1000);    // Wait for 1 second before changing colors
  strip.clear();  // set all LEDs to off
  strip.show();   // push update to the WS2812B Led Strip
  delay(1000);
}
  • Hint :thinking:

#define LED_COUNT 75  // Number of LEDs in the strip

  • The 3v ESP should have a 3v to 5v level translator on the output signal line.



  • What happens if try #define LED_COUNT 50 ?

It's a long shot, but check the value of strip.numPixels() to see if the malloc call in the constructor failed. I don't claim to have any familiarity with the library code, but it doesn't look like it's trying to allocate a large amount of memory for each LED.

What was the output with different starting led? For example 20 leds from 70 to 90?
If it shuts down at led n. 75 you probably have physical damage there.

If modifying the #define doesn't get you more than 75 regardless, This is likely the problem.

For my opinion yes.
But OP wrote he tried different starting led, so it should already be confirmed...

@kmin Forgot to @ the OP, not you.

The data out of the LEDs/chips is buffered so 5V data is coming-out of the 1st LED (and all LEDs). If the 1st LED works, that's not causing a problem.

So I thought it might be a physical problem as well, but I don't see any damage to the LED strip. Also, it seems like it should at least light up the first 75 LEDs and then not go any farther. I don't get any LEDs to light up.
van_der_decken might be on to something, even if I don't understand it. This morning I tried to hard code the number of LEDs by changing this code

//#define LED_COUNT 75  // Number of LEDs in the strip
Adafruit_NeoPixel strip(75, LED_PIN, NEO_GRB + NEO_KHZ800);

 for (int i = 0; i < 75; i++) {

This works just fine if I keep the number at 75. But if I change the Adafruit_NeoPixel to 76, it doesn't work. I don't know how these libraries function, but something in this line of code seems to be the problem. I would be curious if anyone else out there can duplicate this issue.

So I'm looking online for solutions and I see another library called FastLED that gets used a lot. Does anyone know the difference between Adafruit_NeoPixel and FastLED. I might try switching it when I get some time, but it would be nice to understand it better.

The constructor calls updateLength() (in spite of the comment for updateLength()) which sets the pixel count to 0 if the malloc() fails.

/*!
  @brief   Change the length of a previously-declared Adafruit_NeoPixel
           strip object. Old data is deallocated and new data is cleared.
           Pin number and pixel format are unchanged.
  @param   n  New length of strip, in pixels.
  @note    This function is deprecated, here only for old projects that
           may still be calling it. New projects should instead use the
           'new' keyword with the first constructor syntax (length, pin,
           type).
*/
void Adafruit_NeoPixel::updateLength(uint16_t n) {
  free(pixels); // Free existing data (if any)

  // Allocate new data -- note: ALL PIXELS ARE CLEARED
  numBytes = n * ((wOffset == rOffset) ? 3 : 4);
  if ((pixels = (uint8_t *)malloc(numBytes))) {
    memset(pixels, 0, numBytes);
    numLEDs = n;
  } else {
    numLEDs = numBytes = 0;
  }
}

Not sure why it fails. An esp32 should have plenty of ram.

SO your first post says 75 light up, your 10th post says none light up. Guess there's a problem, all right.

  • Generally yes, however we should strive for teaching proper design in projects.
    Something borderline might work today but not tomorrow.
    Leaving potential problems in a design is never recommended.

  • Leaving poor coding in a noob’s software doesn’t teach them anything, same with electronic design.

That doesn't mean there is no problem. You didn't answer to my question about different start address.
If you believe the code is your problem, keep it at 75 and instead attach signal pin to second led signal pad. It should illuminate leds from 2 to 76.

  • Did you try a different strip ? :thinking:

  • Replace the 75 and then 76 Pixels.

Try

 setup() {
 uint16_t count=strip.numPixels()

to see how many pixels the object thinks it has. If the result is zero the storage allocation failed, a code problem. If not zero and it matches what you think you have it is probably a wiring error.

OK. This is the only ESP32 microcontroller I have and also the only LED strip. They aren't mine, so I'm reluctant to cut it up. I'm working on a project for someone else, but it's mostly just a proof of concept. I got the project to work, but for my own knowledge, I want to know why I can't go beyond 75 LEDs.
I set the LED_COUNT to 70 and tried moving the data connection to the next LED. That didn't work at all. No LEDs lit up. Weird. Am I doing it wrong? I'm assuming the data pin is directional since there is a little arrow on it showing which way to go. Any LEDs before the connection should just be ignored.
One other note. I noticed if I pinch the data wire between my fingers, I get a lot of flickering and random blinking on the strip just from the noise. But it does go past LED 75. This shows that I'm at least getting power to the rest of the strip. I even tried connecting the data wire after LED 75 and still nothing happens.
I'm going to keep messing with it. I really do appreciate all the feedback. You guys are great.

How does it tell me the answer to this? I don't have the serial display connected. I have one, but that is something new that I haven't messed with yet.

  • Suggest you (or someone else :wink: ) has damaged either pixel 75 or 76. :sob:

For 75 it's --

Adafruit_NeoPixel strip(75, LED_PIN, NEO_GRB + NEO_KHZ800);
 for (int i = 0; i < 75; i++) {

for 76 it's --

Adafruit_NeoPixel strip(76, LED_PIN, NEO_GRB + NEO_KHZ800);

 for (int i = 0; i < 76; i++) {

for 77 it's --

Adafruit_NeoPixel strip(77, LED_PIN, NEO_GRB + NEO_KHZ800);

 for (int i = 0; i < 77; i++) {

for 100 it's

Adafruit_NeoPixel strip(100, LED_PIN, NEO_GRB + NEO_KHZ800);

 for (int i = 0; i < 100; i++) {