WS2812 LED strip flickers on FASTLED

Hi Sifus

I am working on a project to connect my 146 LED long WS2812 strip to a Wemos D1 Mini.
Unfortunately I have some struggles to display the colors correct and a flickering in the LEDs itself.

When I e.g. set all to green they come up in a variance of colors, when I set them to black they flicker in rainbow, …

At first I suspected the length is (certainly) too much for my USB port. But today I hooked it up to a 10amp power supply and yet the symptoms remain.

I tried all kind of codes and decided today “start simple”.
Below sketch is used and somehow sets the colors. However it looks like there is rainbow flicker on top of it. E.g. blacks flicker in all colors where the green ones flicker in all colors with more green in the flickering.

What could be the issue? It’s unlikely the code but probably hardware. Can someone point me to the next check point, I’m running out of ideas.

below my last code, the initial one is more complex (using MQTT etc) but even the simple one flickers in rainbow which is nowhere in the code :frowning:

#include "FastLED.h"
 
// How many leds in your strip?
#define NUM_LEDS 146
#define COLOR_ORDER GRB //RGB
 
#define DATA_PIN D3

#define TWO_HUNDRED_PI 628
 
CRGB leds[NUM_LEDS];
 
int element = 0;
int last_element = 0;
 
void setup() 
{ 
    FastLED.addLeds<WS2812, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
    fill_solid(leds, NUM_LEDS, CRGB(0,0,0)); // off all LED before start
    FastLED.show();
    delay (2000); //wait two seconds to settle in // just in case
}
 
void loop() 
{
for(int i=0; i<TWO_HUNDRED_PI; i++)
  {
  element = round((NUM_LEDS-1)/2*(sin(i/100.0)+1));
  leds[element].g = 64;
  FastLED.show();
  delay(1);
  if(element < last_element)
    {
    leds[element].g = 0;
    FastLED.show();
    }
  last_element = element;
  }
}

Hardware wise:

RBG strip: +5V and Ground is connect to the power supply
Wemos D1: on breadboard is supplied by PC power (via USB jack)
Data pin on D3 is connected straight to LED strip

Would running the Wemos of the same power supply change anything? It’s my next step but I would loose the programming capability. Therefore I planned to keep this for the last step :slight_smile:

Appreciate pointers to my solution. I’m running out of ideas :confused:

What happens if you move the FastLED.show() out of the for loop and only call it after the for loop ?

First thing to try is a resistor 330R~1K in the data line to the strip. Also a large cap, eg.1000uF across the power connection to the strip. These should always be used, even if adding them does not seem to help.

If the problem remains, it could be that the 3.3V data signal from the Wemos is not being received accurately by the strip, which is expecting 5V data signal. Try using a 75hc14 or 74hct14 as a level shifter. Connect 2 gates in series (to avoid inverting the signal). Power the chip with 5V from the external PSU. Don't forget a 0.1uF bypass cap for the chip.

UKHeliBob:
What happens if you move the FastLED.show() out of the for loop and only call it after the for loop ?

The behaviour does not change. The green is updated less (instead one by one, seems all in one) but this is expected behaviour.

The flickering due to less number of calls remains, even when I add a long delay in each loop.

conclusion: did no help on the issue, sorry

PaulRB:
First thing to try is a resistor 330R~1K in the data line to the strip. Also a large cap, eg.1000uF across the power connection to the strip. These should always be used, even if adding them does not seem to help.

If the problem remains, it could be that the 3.3V data signal from the Wemos is not being received accurately by the strip, which is expecting 5V data signal. Try using a 75hc14 or 74hct14 as a level shifter. Connect 2 gates in series (to avoid inverting the signal). Power the chip with 5V from the external PSU. Don't forget a 0.1uF bypass cap for the chip.

ok, to try this out I need to go shopping, the 1000uF transistor is missing in my toolbox (or any similar one).
Since I go shopping I'll try to find the level shifter as well.

Judging on a similar thread: https://forum.arduino.cc/index.php?topic=594165.0
is that how the wiring is meant to be connected? I noticed I did not solder the end of the strip back to my circuit.
In my previous reads nobody ever mentioned it. What is the reason behind closing the strip back to the power?
Unfortunately the end of my LED strip is "far away" and pulling the cables back would be a bit of a hassle.

What is the reason behind closing the strip back to the power?

It helps to reduce voltage drop at the far end of the strip

If you don't have a 1000uF cap, try 470uF instead. If you have them, try 2 x 470uF in parallel.

VascoW:
Hi Sifus

I am working on a project to connect my 146 LED long WS2812 strip to a Wemos D1 Mini.
Unfortunately I have some struggles to display the colors correct and a flickering in the LEDs itself.

When I e.g. set all to green they come up in a variance of colors, when I set them to black they flicker in rainbow, …

At first I suspected the length is (certainly) too much for my USB port. But today I hooked it up to a 10amp power supply and yet the symptoms remain.

I tried all kind of codes and decided today “start simple”.
Below sketch is used and somehow sets the colors. However it looks like there is rainbow flicker on top of it. E.g. blacks flicker in all colors where the green ones flicker in all colors with more green in the flickering.

What could be the issue? It’s unlikely the code but probably hardware. Can someone point me to the next check point, I’m running out of ideas.

below my last code, the initial one is more complex (using MQTT etc) but even the simple one flickers in rainbow which is nowhere in the code :frowning:

#include "FastLED.h"

// How many leds in your strip?
#define NUM_LEDS 146
#define COLOR_ORDER GRB //RGB

#define DATA_PIN D3

#define TWO_HUNDRED_PI 628

CRGB leds[NUM_LEDS];

int element = 0;
int last_element = 0;

void setup()
{
    FastLED.addLeds<WS2812, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
    fill_solid(leds, NUM_LEDS, CRGB(0,0,0)); // off all LED before start
    FastLED.show();
    delay (2000); //wait two seconds to settle in // just in case
}

void loop()
{
for(int i=0; i<TWO_HUNDRED_PI; i++)
  {
  element = round((NUM_LEDS-1)/2*(sin(i/100.0)+1));
  leds[element].g = 64;
  FastLED.show();
  delay(1);
  if(element < last_element)
    {
    leds[element].g = 0;
    FastLED.show();
    }
  last_element = element;
  }
}




Hardware wise:

RBG strip: +5V and Ground is connect to the power supply
Wemos D1: on breadboard is supplied by PC power (via USB jack)
Data pin on D3 is connected straight to LED strip

Would running the Wemos of the same power supply change anything? It's my next step but I would loose the programming capability. Therefore I planned to keep this for the last step :)

Appreciate pointers to my solution. I'm running out of ideas :confused:

you need to connect the ground of the power supply to the ground of the microcontroller…

1 Like

Qdeathstar:
you need to connect the ground of the power supply to the ground of the microcontroller....

For those who are coming here for the solution. The common grounding solved my issue.
However I also like to thank the other contributions as it made me reading a lot more and will implement the voltage step up on the data line for general improvement (parts coming from China and seem to swim here at the moment, uncommonly slow). However for now the common ground solved it and I can continue working on my script :slight_smile: .

1 Like

VascoW:
parts coming from China and seem to swim here at the moment, uncommonly slow

Do you follow the news?

Qdeathstar:
you need to connect the ground of the power supply to the ground of the microcontroller....

More specifically, you need to connect the ground at the LED strip back to the ground of the microcontroller and run this together with the data line as a pair. Similarly the 5 V and ground to the LED strip should run together from the power supply. If you are powering the WeMOS from the same 5 V (which is most sensible), then that 5 V should also run from the LED strip back to the microcontroller with the data and ground.

The 330 or 470 Ohm resistor connected in series with the data at the LED strip will not affect normal operation or flickering but is a protective measure against surges and power imbalances. The 470 µF or 1 mF capacitor connected at the LED strip will improve general reliability, as will a 74HCT14 or 74HC04 level converter on the data from a 3.3 V microcontroller.