WS2812B weird issue

Hi guys. I'm working on the project that requires me to run five strips of WS2812S LEDs with 214 pixels total. Everything works great on the bench but when I power it up with my actual strips all of them have a very strange flickering issue. It almost seems as if they are all turning on for a fraction of a second and then goes back to the color I tell them to. The code is below. You will see that I am purposely turning some pixels black but that's not what I am seeing. I've even commented that portion out and it still does it. My guess its cabling but I'd like to get some opinions. Each strand I soldered on 22 awg pig tails and ran 16 awg speaker wire in between. The Arduino is approximately 10' away from the first strand. If it is cabling what type of cable is recommended? Would it help moving the Arduino closer to the first strip?

#include <FastLED.h>
#include <FastLED.h>

#define LED_TYPE        WS2812B
#define COLOR_ORDER     GRB
#define LED_PIN   3
#define dimmerPin 7
#define NUM_LEDS 214

unsigned long runStartMillis;
unsigned long runCurrentMillis;
unsigned long modeStartMillis;
unsigned long modeCurrentMillis;
int runDly;
int modeDly = 10 * 1000;
int mode = 1;
int count = 0;
int modes = 4;
int brightDimmer;
int brightness;

bool upDone = false;

CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(115200);
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(brightness);
  FastLED.clear();
  runStartMillis = millis();
  modeStartMillis = millis();
}

void loop() {
  brightDimmer = analogRead(dimmerPin);
  brightDimmer = map(brightDimmer, 0, 1024, 30, 254);
  brightness = brightDimmer;

  runCurrentMillis = millis();
  modeCurrentMillis = millis();
  if (modeCurrentMillis - modeStartMillis > modeDly) {
    mode = random(1, modes + 1);
    modeStartMillis = modeCurrentMillis;
    if (mode != 4) {
      count = 0;
    }
  }

  if (mode > modes) {
    mode = 1;
  }
  //mode = 4;
  // *** ///////////////////////////////////////////////////
  if (mode == 1) {
    runDly = 1;
    if (runCurrentMillis - runStartMillis > runDly) {
      Yellow();
      runStartMillis = runCurrentMillis;
    }
  }
  //////////////////////////////////////////////////////////

  // *** ///////////////////////////////////////////////////
  if (mode == 2) {
    runDly = 1;
    if (runCurrentMillis - runStartMillis > runDly) {
      YellowGreen();
      runStartMillis = runCurrentMillis;
    }
  }
  //////////////////////////////////////////////////////////

  // *** ///////////////////////////////////////////////////
  if (mode == 3) {
    runDly = 1;
    if (runCurrentMillis - runStartMillis > runDly) {
      Green();
      runStartMillis = runCurrentMillis;
    }
  }
  //////////////////////////////////////////////////////////

  // *** ///////////////////////////////////////////////////
  if (mode == 4) {
    runDly = 30;
    if (runCurrentMillis - runStartMillis > runDly) {
      if (upDone == false) {
        count++;
      }
      if (upDone == true) {
        count--;
      }
      if (count == NUM_LEDS) {
        count = NUM_LEDS - 1;
        upDone = true;
      }
      if (upDone == true && count == 0) {
        upDone = false;
      }
      Trail(count);
      runStartMillis = runCurrentMillis;
      Serial.println(count);
    }
  }
  //////////////////////////////////////////////////////////
}

void Yellow() {
  FastLED.setBrightness(brightness);
  fill_solid(leds, NUM_LEDS, CRGB(255, 255, 0));
  FastLED.show();

  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  FastLED.show();
}

void Green() {
  FastLED.setBrightness(brightness);
  fill_solid(leds, NUM_LEDS, CRGB(0, 255, 0));
  FastLED.show();

  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  FastLED.show();
}

void YellowGreen() {
  FastLED.setBrightness(brightness);
  fill_solid(leds, NUM_LEDS, CRGB(128, 255, 0));
  FastLED.show();

  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
  FastLED.show();
}

void Trail(int count) {
  FastLED.setBrightness(brightness);
  fill_solid(leds, NUM_LEDS, CRGB(255, 255, 0));
  FastLED.show();
  leds[count].setRGB(0, 0, 0);
  FastLED.show();
}

Power supply issue.

Show a wiring diagram and picture of the setup please.

Better to have the LED strip with its own 5V regulator and not share, except ground, the 5V with the MCU.

Here are pics of my controller. The setup would be almost impossible to post. It's a log bonfire which is 10' wide and 25' tall or so. The speaker wire is ran through the logs around to the front where I have the LEDs fastened to wooden strips on different levels.

I have a spare buck/boost I could mount up next to the first strip and run 12 VDC to that.

KrafterHD:
I have a spare buck/boost I could mount up next to the first strip and run 12 VDC to that.

Worth a try, put filtering caps on the buck output.

For my light strips I use a linear 7805 per light strip, 276 LED's per strip.

Idahowalker:
Worth a try, put filtering caps on the buck output.

Will do. Thank you for your input.

OK, well the full rating for 214 WS2812 LEDs would be 12 Amps, so we presume you have a regulated 5 V supply of at least that rating.

You do realise that the LED strips themselves cannot carry that current, so you need to provide a power cable - 5 V and ground - to each end of every 50 LEDs - about 3 Amps. The cable should be at least 1 mm2 - 22 AWG sounds a trifle shy of this. However you must also provide a reasonably substantial ground paired together with the data wire where it runs from one strip to the next.

The "controller" in your image above seems to bear no relation whatsoever with the use of WS2812 strips - it seems to be for 12 V non-addressable RGB strips instead.

Given that your 5 V supply is properly regulated, it definitely should be used to power the Arduino as well as the LED strips in order to avoid the situation where the strips and the Arduino are not powered at the same time. The 330 Ohm resistor in series with the data input terminal of the first strip - and each successive strip separated by a couple of feet from its predecessor - is also protection against powering mismatches. Not to forget the 470 µF or 1 mF capacitor advised across 5 V and ground at the start of each strip.

And the 5 V power to the "5V" Arduino pin should be brought back from the point where the 5 V is supplied to the first strip, along with the data wire and ground so that the data is not interfered with by any voltage drop between the two. All three wires together as should all wiring between parts be bundled; there must be no open loops formed between power and ground or data and ground connections,

Paul__B:
OK, well the full rating for 214 WS2812 LEDs would be 12 Amps, so we presume you have a regulated 5 V supply of at least that rating.
You do realise that the LED strips themselves cannot carry that current, so you need to provide a power cable - 5 V and ground - to each end of every 50 LEDs - about 3 Amps. The cable should be at least 1 mm2 - 22 AWG sounds a trifle shy of this.

Thanks for your input. I'm confident that it is not a power issue. I have have five different strips with the longest and the first one being maybe 40 pixels. the next two from there are about 7 foot away and the last two about 5 foot from there. I have a 5 volt 16 awg trunk running the entire way so each of the five strips are powered from the trunk and not from each other. The data line is also 16 awg. On top of that, as a first troubleshooting step, I disconnected all but the first strip and I still had the same problem.

However you must also provide a reasonably substantial ground paired together with the data wire where it runs from one strip to the next.

I have some high quality shielded cable that I will run a test with. I hope it's that easy.

The "controller" in your image above seems to bear no relation whatsoever with the use of WS2812 strips - it seems to be for 12 V non-addressable RGB strips instead.

If you look close you will see a 5 volt converter that I'm powering the Arduino's with and the WS2812B LEDs. I do however have 12 volt RGB LEDs as well. The 12 volt device you are seeing is simply an inline DC current meter.

Given that your 5 V supply is properly regulated, it definitely should be used to power the Arduino as well as the LED strips in order to avoid the situation where the strips and the Arduino are not powered at the same time. The 330 Ohm resistor in series with the data input terminal of the first strip - and each successive strip separated by a couple of feet from its predecessor - is also protection against powering mismatches. Not to forget the 470 µF or 1 mF capacitor advised across 5 V and ground at the start of each strip.

This cuold be part of my issue. I don't have either of those but can be easily added.

And the 5 V power to the "5V" Arduino pin should be brought back from the point where the 5 V is supplied to the first strip, along with the data wire and ground so that the data is not interfered with by any voltage drop between the two. All three wires together as should all wiring between parts be bundled; there must be no open loops formed between power and ground or data and ground connections,

Thanks agian for the input.

KrafterHD:
I have some high quality shielded cable that I will run a test with. I hope it's that easy.

Probably a bad idea. Shielded cable has a high capacitance, Bad enough for audio but not appropriate for Radio Frequency data streams such as we are using here.

Shielding is not the point, it is ensuring ground currents do not develop voltage drops which interfere with the data. Just use "figure 8" cable.

Paul__B:
Probably a bad idea. Shielded cable has a high capacitance, Bad enough for audio but not appropriate for Radio Frequency data streams such as we are using here.

Shielding is not the point, it is ensuring ground currents do not develop voltage drops which interfere with the data. Just use "figure 8" cable.

Figure 8? Is that what I'd call twisted pair cable?

if you look close you will see a 5 volt converter that I'm powering the Arduino's with and the WS2812B LEDs.

When I powered my led strip from the same supply as the MCU, I had the random flickering issue when no signal was applied. When I moved the LED strip to its own 5V supply the random flickering stopped.

Idahowalker:
When I powered my led strip from the same supply as the MCU, I had the random flickering issue when no signal was applied. When I moved the LED strip to its own 5V supply the random flickering stopped.

Very interesting! I will add the caps and resistors and use a separate buck if the problem still exists.

Idahowalker:
Show a wiring diagram and picture of the setup please.

Still waiting for the wiring diagram, that picture tells us next to nothing.

Grumpy_Mike:
Still waiting for the wiring diagram, that picture tells us next to nothing.

I get your reply. Believe me I do. I've been an active user, admins and moderators of several support sites myself. I know how some users are. But I do not have a wiring diagram because one was not required for me to build it but if you look at the code and the reverse side of the circuit board you can see what I have and that it is correct. From there I'm going out from pin 3 via a terminal to the LED strip and bring 5 volts in to power the Arduino into a terminal. I added a pot on A7 so I can adjust the brightness of the strips which is also visible in the pic. I have a separate terminal strip to supply 5 volts to the LEDs. It's a very basic design.


So... I put in a resistor inline with the data wire and a 470 uF cap both at the first row of LEDs and disconnected the other rows. I also added a 2200 uF cap across the power at the Arduino. I powered it on and it worked perfectly. The weird flickering was gone. I then wired up the RGB LEDs to do a complete test and the flickering came back...... My guess it's PWM interference. So the next thing I'm going to try is to install a cap on the Arduino that runs the RGB LEDs but if that fails then I'll run a separate 5 Volt power supply for the WS2812B LEDs. The worse case scenario I'll totally isolate the WS21812B and the RGB LEDs.

Thanks for the input guys. It was greatly appreciated.

KrafterHD:
Figure 8? Is that what I'd call twisted pair cable?

I don't know why you would call it that. :astonished:

It's not twisted at all. "Figure 8" refers to the cross section such as common flat two wire lamp cord or speaker cable. The important thing is that the two wires are not separate.

The only reason that WS2812 strips should flicker given that the power supply is not overloaded, is that the code is sending intermittent commands. Bad code.

Paul__B:
I don't know why you would call it that. :astonished:

It's not twisted at all. "Figure 8" refers to the cross section such as common flat two wire lamp cord or speaker cable. The important thing is that the two wires are not separate.

The only reason that WS2812 strips should flicker given that the power supply is not overloaded, is that the code is sending intermittent commands. Bad code.

Thanks for your input. Little did I know that I am already using "figure 8" speaker wire.

I was able to pinpoint my issue. I believe it's PMW interference coming from the other Arduino which controls some RGB LEDs (see above post). I have a few ideas on how to counter that. The signal wire is currently on one single wire of the figure 8. I will ground the other side and see what happens.

Thanks again.

What might help is to run ground and data as a twisted pair wherever you use wire to jump to a new strand.

Without a schematic, we're only guessing. And so are you.

If the voltage at an LED goes below its minimum value, then it will go haywire, and so will the LEDS after it.