WS2812B NeoPixel flickers or shows wrong colours

WS2812B strips need a solid 5 V supply, a common ground and a clean data signal. Most faults come from one of those three.

What the message means

Each LED is a small chip with a data input. A 3.3 V data signal from an ESP32 is often too weak for a 5 V strip, and a long thin supply wire drops voltage.

Fix it in this order

  1. Join the grounds of the strip supply and the microcontroller first.
  2. Power the strip from its own 5 V supply sized for the LED count. Each LED can draw up to about 60 mA at full white.
  3. Add a resistor of about 300 to 470 ohm in series with the data line, and a capacitor of about 1000 uF across the strip supply.
  4. From a 3.3 V board use a level shifter for the data line, or keep the data wire very short.
  5. If red and green are swapped, change the colour order from GRB to RGB in the library setting.
  6. Connect the strip at the DIN end, in the arrow direction.

Why it happens

Each WS2812B LED contains a small controller that reads a precisely timed data signal and passes the rest down the chain. Those controllers need a steady 5 V supply. Many LEDs drawing current at once can pull the voltage down, and thin or long supply wires make it worse. When the supply sags or the grounds differ, the data timing breaks and the colours flicker or change.

Data signal quality is the other half. Many microcontrollers drive the data line at 3.3 V, and a level shifter gives a stronger high level that matches the 5 V strip. A series resistor damps ringing on long leads, and a large capacitor across the supply smooths sudden current steps. Colour order also differs between LED types, so swapped red and green points to a library setting rather than a fault.

If you see this, do this

You seeDo this
First LED wrong, rest randomData signal or ground problem.
Colours swappedColour order setting.

Confirm the fix

  1. Measure voltage at the strip’s first LED at full brightness. It should stay near 5 V and not sag when colours change.
  2. Set only the first LED to red, then to green, in a test sketch. A swap between them points to the colour order setting.
  3. Connect the grounds, add the resistor and capacitor, then repeat the same pattern. A stable first LED confirms the signal chain.

Common mistake: Most readers assume that flickering LEDs have a code bug, when a shared ground or weak 5 V supply often causes the data timing to break.

ESP32 brownout, wiring checker.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.