First: is it flickering or dimming unevenly?
- Flickering β rapid on/off, often at low brightness. Almost always PWM or power related.
- Dimming at the far end β the classic voltage-drop problem on long strips.
- Random colours on WS2812/SK6812 β a data signal or ground problem.
- Whole strip pulses with music or bass β the power supply is sagging under transient load.
Identify which one you have, because the fixes overlap but are not identical.
1\. Power budget: do the maths before buying
An addressable LED (WS2812B) draws up to 60 mA per pixel at full white. A 1-metre strip of 60 LEDs can pull 3.6 A. A 5-metre strip of 300 LEDs can pull 18 A. That is far more than any USB port and more than many bench supplies.
Rule of thumb:
- Count LEDs Γ 60 mA = worst-case amps at full white.
- Add 20% headroom for the supply.
- Choose a 5 V supply that can deliver that continuously, not peak.
A 5 m strip of 300 WS2812B needs a 5 V 20 A supply β not a 5 V 2 A phone charger.
2\. Voltage drop and power injection
Copper traces inside a strip have resistance. Over 5 metres, the voltage at the far end can drop below 4 V even with a perfect supply. LEDs near the end dim, and WS2812 data becomes unreliable because the logic threshold is referenced to the local 5 V.
Fix it with power injection:
- Run a pair of thick wires (18 AWG or thicker) alongside the strip.
- Inject 5 V and GND every 1β2 metres, and always at both ends.
- Keep the injection wires the same length to avoid ground loops.
- Never inject through the strip's thin traces β always to the copper pads.
A 5 m strip with injections at 0 m, 2.5 m and 5 m will look uniform from end to end.
3\. Level shifting the data line
WS2812B expects a data high of at least 0.7 Γ VDD = 3.5 V. An ESP32 outputs 3.3 V. In most short runs this works, but with a long data wire or a strip powered slightly above 5 V, the margin disappears and you get flickering or random colours.
Fix it with one of:
- A 74HCT245 or 74AHCT125 level shifter powered from 5 V.
- A single NPN transistor with a 10 kΞ© pull-up to 5 V (works but slower).
- A dedicated "level shifter" breakout designed for WS2812.
Do not use a simple resistor divider β it will slow the edges too much for the 800 kHz data rate.
4\. Series resistor and capacitor on the data line
Even with a level shifter, ringing on the data line can cause the first pixel to misread. Two passive parts fix it:
- 330 Ξ© resistor in series with the data line, as close to the first LED as possible.
- 1000 Β΅F electrolytic capacitor across 5 V and GND at the strip input, to absorb inrush and smooth transients.
These two parts cost less than a euro and solve a surprising number of "random flicker" reports.
5\. PWM for analog strips
Analog RGB strips (with 4 wires) are dimmed with PWM. If the PWM frequency is too low, you see flicker with a phone camera or with fast eye movement. If it is too high, the MOSFET driver may not switch cleanly.
- Use 1β2 kHz PWM for visible-light applications. Above 2 kHz most people cannot see flicker, and the MOSFET driver can still keep up.
- Use a logic-level MOSFET (same advice as the DC motor article) β one per colour channel.
- Never drive a strip directly from an ESP32 pin. Even 1 A per channel will destroy the pin.
6\. Ground: the most common silent killer
If the LED strip and the ESP32 have separate power supplies and only the data line is connected, the data signal has no reference. The strip will flicker or show random colours. Always connect the grounds of every supply together, and use thick wire for the ground path β it carries the same current as the +5 V line.
ESP32 GND ββββ Strip GND ββββ 5V PSU GND
ESP32 GPIO ββ 330Ξ© ββ Level shifter ββ Strip DIN
5V PSU +5V βββββββββββ Strip +5V
βββ 1000Β΅F to GND
Diagnosing in five minutes
- Measure the voltage at the strip's input and output with a multimeter under load. A drop of more than 0.3 V means you need power injection.
- Set the strip to full white. If the supply voltage sags below 4.8 V, the supply is undersized.
- Touch the data line wire. If it is longer than 20 cm and unshielded, add the 330 Ξ© resistor and shorten it.
- Measure between ESP32 GND and strip GND. If it is not 0 V, connect them with a thick wire.
Summary
LED strip flicker is a power and signal integrity problem, not a firmware problem. Size the supply for worst-case current, inject power along long strips, level-shift the data, add the 330 Ξ© + 1000 Β΅F at the strip input, and always share grounds. Do those five things and your installation will look as good as a commercial product.
Comments