Can't address more than 620 leds in a strip

Hello everyone, I have searched for the answer to my problem but haven't found any sadly. Basically I am using my Arduino UNO to controll a WS2815 12v led strip which is 12.5m long with about 750 leds.


This is the schematic of my connection. Have in mind that used strip in the picture is 5v and has only 1 data line. Mine has 2 and I have made a short between them so both of the channels get the same data. Also I am using power injection on both ends of the strip so power drop is not an issue. My problem is whenever I use more than 622 leds in the code it doesn't run at all. Have in mind that this code only uses 2% of RAM and 8% of storage. I'm not that good with addresses, I understand how they work as I'm studying to become an electrical engineer so programming stuff isn't all that new for me. I have put the used code down below.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 9

Adafruit_NeoPixel strip = Adafruit_NeoPixel(622, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.setBrightness(50);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // put your main code here, to run repeatedly:
rainbow(20);
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

You should try to improve your searching skills. This is a very common question on this forum.

Your Uno does not have sufficient RAM memory for so many LEDs.

And why does my compailer say that there is more than enough RAM available ?

Because the compiler does not know how much RAM will be required when the code runs.

1 Like

you are using library that allocates RAM for each LED at runtime. There are libraries that don’t do that and can handle longer strips

Can you maybe name some of those libraries if you know them by name ?

Ahh so basically code doesn't calculate it in advance but allocates the memory when the code is running ?

it depends on either the code use dynamic memory allocation or not

I never used one because it is easy enough to bit bash it with a small asm code, but many seem to prefer FastLED, try that maybe

All libraries for addressable LED uses 24bits color scheme and preallocates buffer as 3 bytes for each pixel, so for Uno limits the strip length to 600-620 leds
The only way to increase number of leds - use decreased color depth. But better to choose the board with more RAM.

Definitely not all libraries. As I said I don’t use any, but I remember seeing those that don’t.

Basically the answer has been given. Neopixel allocates a buffer on the heap which is not part of the calculated RAM use. Also any local variables are not included in this calculation. For you current purpose where you are setting all leds to the same color, i don't see why that matters, you can simply connect the output pin to 2 strips. If you decide that you do want to make patterns, you will have to create those normally in a buffer, so even working without a complete buffer will have complications. The obvious solution is to use a board with more RAM, and an ESP is the board i would chose.
That said, if you go into neopixel.ccp and find the show() function, you will find in between aal those board specific bit of code the part that is responsible for the timing. If you send the signal 1 pixel at a time, all you need to do is make sure that you send the next pixel within the 50us reset time and will be forwarded to the next pixel. (i Saw this implemented on an ATtiny13 by This guy and i have used that method successfully on an ATtiny13 as well) I don't know of any library that does it like this, but i guess there might be. Again creating the whole output on the fly has other complications and a board with more RAM is a better option

Could I maybe allocate the memory in the permament memory as opposed to allocating it in the flash memory ?

Many, but not all, Arduino boards with more memory RAM than Uno run at 3.3V not 5V. This can be a problem when using ws2812 led strips because they do not always work with a 3.3V data signal. You may be lucky and find that your strips work well with 3.3V data. But if not, you may need to shift the voltage of the data signal from 3.3V to 5V. Many level shifters sold cheaply on eBay do not work well for this purpose because they are the bi-directional type designed for i²c bus level shifting. Instead of this type, I would suggest a 74hct14 or 74hc14 chip.

What do you mean by "permanent memory" if you do not mean flash memory? Did you mean EEPROM memory?

Yes in the EEPROM, I don't know if that would work to be honest so that's why I'm asking.

I found a new board in my city, it says that it uses a ESP32-WROVER-E module with 4MB flash and 8MB PSRAM memory. Is it a good solution for this ?

EEPROM: I don't know, I never heard that anyone tried that. But none of the commonly used libraries will use EEPROM.

ESP32: Yes, I think so. But it is one of those 3.3V boards I mentioned.

Yes, you're correct. So my best option is to do that plus the level shifter for the logic ?

I have a few LM358 Op-Amp lying around maybe use them for the level shifter purpose ?

You could try without a level shifter to begin. If you get unreliable patterns, patterns that flicker all the time or flicker when you touch the board, or stop flickering when you touch the board, you need that level shifter chip.

Thank you for your time I know what to do now !

Hmmm... I don't know... It's an interesting question.

LM358 has a "Gain-bandwidth product" of about 1MHz, which is only a little higher than the 800KHz signal used by ws2812. But only a small gain is needed to boost 3.3V to 5V, so maybe.... This is really beyond my level of op-amp knowledge!

I would grab a 74hct14, I know those work.

1 Like