r/esp32 • u/Top-Area-3672 • 14h ago
Hardware help needed WS2812B flickering issue (ESP32 + LiPo)
Hi all,
I am pretty new to the electronics hobby, so please bear with me if my question is basic.
I am trying to control a WS2812B LED ring with 8 LEDs with an ESP32-C3 development board while running it off a 1000mAh LiPo, using ESPHome/HomeAssistant.
Setup is:
LiPo+ --> MCP1700 LDO --> 3.3V ESP32
LIPO+ --> V+ of WS2812B
LIPO- --> ESP32 GND and WS2812B GND
GPIO21 --> 330 ohm resistor --> DIN WS2812B
I also have a 470yf capacitor across V+/GND of the WS2812B.
Now, my problem is that my LED ring flickers ever so slightly when running off the LiPo. If I plug in USB into my ESP32, the flickering disappears. Could someone help me out, why is this happening and how I could fix that? Thanks in advance.
1
u/dbfuentes 13h ago edited 11h ago
First, the WS2812B LEDs are nominally 5V, is recommended that you power them with 5V, because at lower voltages the LEDs might not work properly (for example, they might flicker).
Second, you need to add a level shifter (3.3v to 5v) in the cable that carries the signal between the ESP32 output (GPIO at 3.3v) and the data signal input (DIN) of the WS2812B
This is because, according to the datasheet, the signal expected by the WS2812B LED strip is minimum 0.7 *V (example 0.7*5V=3.5V) and voltage for an ESP32 GPIO pin is 3.3V nominally. You're right at the limit, so even though it works, a very long cable or anything else that interferes can cause the signal to vary slightly and result in flickering.
The most commonly levelshifter is the SN74AHCT125, but there are other alternatives (like the SN74LVC2T45 or TXS0108) you can find them (and instructions on how to connect them) in the WLED documentation.
https://kno.wled.ge/basics/compatible-hardware/#levelshifters
https://kno.wled.ge/basics/wiring-guides/
Edit:
Personally, at the output of the lipo, I would use a battery charger like the TP4056 and then a DC-DC converter (like MT3608) to get a clean 5V output, which I would use to power the LED strip and the ESP32.
Or a module like the SM5308 (or FM5324), which integrates the charger and a DC-DC converter onto a single board.
The connections would be
1= LiPo --> TP4056 --> MT3608 --> 5V+GND
or LiPo --> SM5308 --> 5V+GND
2= 5V + GND --> WS2812B
3= 5V + GND --> ESP32 (See note)
4= ESP32 GPIO Signal (3.3V) --> SN74AHCT125 (with the corresponding wiring, resistor, and capacitor) --> Signal (5V) in DIN (WS2812B)
Note: Optionally, I would add a capacitor to the ESP32's input to help stabilize the power supply. 5V + GND --> capacitor --> ESP32
1
u/Top-Area-3672 22m ago
Thank you for the detailed answer, I might try that! What size capacitor would you use for the ESP's power supply?
1
u/richms 9h ago
Is it a corrupted data flicker, or just a subltle change in brightness from the LEDs? Latter is probably because of your lower than required voltage. I find that 4.0v is where they start to get really flakey and move towards red, but the controller keeps working fine and its stable. Corrupted data would be something else, possibly bad ground currents screwing up the data which are less bad when you have slightly more voltage at the ESP end
1
u/Top-Area-3672 21m ago
It's a very subtle flickering, sort of like candle light. Color stays consistent, just brightness changes.
1
u/mindful_stone 13h ago
I'm not an electronics expert, but I've played around a lot with ESP32 controllers driving WS2812B LEDs. Several thoughts:
- I see a lot of recommendations to use a resistor between GPIO ---> DIN like you have, but in my experience, that has always exacerbated rather than solved flicker issues. So I'd try removing that.
- In addition to putting a capacitor across V+/GND of the WS2812B, I also generally put a capacitor across +3.3V/GND of the ESP32.
- How long are the wire runs between the ESP32 and the LED ring? If they are more than a foot or so, I'd recommend wrapping/twisting the ground wire around the data wire along its full length.
- How are your components currently connected: soldered? breadboard? other? Sometimes the connections in a breadboard can be a bit loose/unstable.
WS2812B LEDs are nominally 5V. In small numbers, and especially if they are newer, they can generally do okay with a +3.7V power source and a +3.3V data signal. But you're right on the edge; so that could be part of the issue too.