Your WS2812 LEDs Drain the Battery Even When They're Off
You set every pixel to black, called esp_deep_sleep_start(), and the ESP32-C6 went quiet. Espressif’s datasheet puts that chip’s deep-sleep current in the microamps, so the battery should have lasted months.
It lasted a few days.
The likely culprit is WS2812B quiescent current, and your sleep code is probably fine. “Quiescent” means idle: the current a chip pulls when it’s powered but not doing any visible work. Every pixel on your strip has some, and together they can swamp the microcontroller you worked so hard to put to sleep.
This guide covers why black pixels still eat current, how to build a switch that cuts them off completely, and the two traps that let a first attempt keep leaking anyway.
Why Black Pixels Still Draw Current
A WS2812B is a red, green and blue LED packaged together with a tiny driver IC. That IC watches its data input, keeps the first 24 bits of each frame for itself, and passes the rest down the chain. To do that job it has to stay powered and listening all the time.
Setting a pixel to 0,0,0 turns off the LED dies. The IC keeps running, waiting for the next frame.
Adafruit’s NeoPixels work the same way. strip.clear() changes what the strip shows. The controllers inside each pixel keep drawing the same power.
Each dark pixel’s draw varies by LED type and batch. The WS2812B datasheet lists quiescent current as under 0.6 mA per pixel. Your strip’s figure depends on the parts you bought, so measure it. The next section shows how.
Whatever the figure, it gets multiplied by 30, 60 or 144 pixels, and it keeps flowing the entire time the chip sleeps. On a 60-pixel strip, that’s up to about 36 mA. The ESP32-C6 in deep sleep is down in the microamps.
On a battery-powered build with more than a handful of pixels, the LEDs set your battery life, and the microcontroller barely registers.
(If you’re measuring a dev board, the USB-serial bridge, voltage regulator and power LED add their own draw too. Most ESP32 deep-sleep tutorials stop at the MCU.)
How Much Battery You’re Losing
The arithmetic is simple once you separate the two terms:
battery_life_hours ≈ capacity_mAh / (I_sleep_mA + N_pixels × I_pixel_standby_mA)
capacity_mAh usable battery capacity
I_sleep_mA ESP32 + board draw in deep sleep
N_pixels number of LEDs on the strip
I_pixel_standby_mA current per dark pixelFor scale: every 1 mA of constant draw empties a 2,000 mAh cell in about 2,000 hours, roughly 83 days. A 60-pixel strip at 0.6 mA per pixel (the datasheet’s upper bound) pulls about 36 mA and drains that same cell in about 56 hours. That’s your few days.
The N × I term grows with every pixel you add, while I_sleep stays tiny. That’s why longer strips die faster even when they never light up.
To get your real numbers, put a multimeter in series with the battery’s positive lead:
- Set the meter to its mA range, power the board, and wait until it’s in deep sleep.
- Read the total current. That’s
I_sleep + N × I_pixel_standby. - Disconnect the strip’s 5 V lead and read again. That’s
I_sleepalone. - Subtract, then divide by your pixel count to get
I_pixel_standby.
One catch: a meter on its µA range adds a voltage drop (burden voltage) that can brown out the board when it wakes and draws a burst of current. Take readings while the board is asleep, or bridge the meter with a jumper wire while you change ranges.
The Fix: A P-Channel MOSFET High-Side Switch
You need a transistor that disconnects the strip from the battery while the ESP32 sleeps. Where you put it matters.
High-side means the switch sits between the battery’s positive terminal and the strip. Low-side means it sits between the strip and ground. Low-side switching looks easier, because N-channel MOSFETs are cheap and turn on happily from 3.3 V. But it leaves the strip’s positive rail connected while its ground floats, and the strip will find a ground wherever it can:
LOW-SIDE SWITCH (the mistake)
BATT+ ──► strip 5V (still connected)
│
▼
WS2812B IC
│
▼
DIN input protection diode
│
▼
into the ESP32 data pin ──► out to ESP32 GND ──► BATT−
(strip GND switched off, floating; current sneaks out through DIN)
HIGH-SIDE SWITCH (the fix)
BATT+ ──X── P-FET off ── strip 5V has no source
strip GND tied to common GND, DIN held low
→ no voltage across the strip, no current pathCut the positive line and the strip has no supply, provided the data pin stays low (more on that below).
The circuit
BATT+ / 5V
│
├────────────────────┐
│ │ S
[R1] ┌──┴──┐
47k │ Q1 │ AO3401A (P-FET)
│ GATE │ │
├─────────────────┤G │
│ └──┬──┘
│ C │ D
┌──┴──┐ ├────────► STRIP_5V
GPIO_PWR ─[R2 4.7k]─┤B Q2 │ │
│ NPN │ [C1] bulk cap
└──┬──┘ │
│ E │
GND ───────────────────┴────────────────────┴────────► STRIP_GND
(BATT−, ESP32 GND and strip GND all tied together)
GPIO_DATA ─[R3 330Ω]─────────────────────────────────► DIN (first pixel)- Q1, the P-channel MOSFET, carries the strip current from source (S) to drain (D).
- R1 (10k to 100k) pulls the gate up to the source. With no other input, Q1 stays off, so the strip defaults to dark and unpowered.
- Q2, a 2N3904-class NPN transistor, pulls the gate down to ground when
GPIO_PWRgoes high. A small N-channel MOSFET like a 2N7002 does the same job. - R2 (1k to 10k) limits base current. A 100k resistor from Q2’s base to ground keeps Q2 off while the GPIO floats during boot.
- R3 is the data-line series resistor. Adafruit’s NeoPixel Überguide recommends 300 to 500 Ω.
Why you can’t drive the gate straight from the GPIO
A P-FET is controlled by Vgs, the gate voltage relative to the source. Pull the gate well below the source and it turns on. Bring the gate up to the source voltage and it turns off.
Here’s the problem. Your source sits at the battery voltage, 4.2 to 5 V, and the ESP32-C6’s GPIO tops out at 3.3 V. Wire a “high” GPIO straight to the gate and the gate still sits 0.9 to 1.7 V below the source. Many logic-level P-FETs stay partly on there.
Partly on means leaking.
The NPN stage solves this. The GPIO only switches Q2, and when Q2 lets go, R1 pulls the gate all the way up to the source. Q2 also makes the control active-high: GPIO high turns the strip on.
Choosing the P-FET
Check three things on the datasheet:
- Logic-level gate. It should turn on fully with a few volts of gate drive.
- Rds(on) at your actual Vgs. That’s the on-resistance. Read the row for a gate voltage near your battery voltage. The headline number is usually the best case.
- Current headroom. The Überguide budgets about 60 mA per pixel at full white. Sixty pixels can ask for around 3.6 A.
The AO3401A from Alpha & Omega Semiconductor is a common SOT-23 pick for short strips. It’s rated for about 4 A continuous at 25 °C, and less once it warms up. A 60-pixel strip at full white sits right at that edge, so step up to a bigger package or cap your brightness in firmware.
Keep a bulk capacitor across the strip’s power leads, on the switched side. The Überguide suggests 1000 µF to buffer the strip’s transient demand. That cap also pulls a big inrush spike the moment Q1 turns on. You can soften it by slowing Q1’s turn-on (a series gate resistor plus a small gate-to-source capacitor), or let a load-switch IC with built-in slew control handle it.
Don’t Let the Data Line Power the Strip
With the high-side switch off, one leak path remains. If GPIO_DATA sits high, current flows into the first pixel’s DIN pin, through its input protection diode, and onto the strip’s 5 V rail. That can partially power the first LED, sometimes more. You’ll see a pixel that flickers or glows faintly while the board sleeps, or a sleep current that never drops as low as it should.
The fix is sequencing. Shut down in this order before deep sleep:
// Shutdown
set_all_pixels(0, 0, 0)
show()
wait for the WS2812B reset/latch period
gpio_set_level(DATA_PIN, 0) // data line low
gpio_set_level(LED_PWR_PIN, 0) // Q2 off, R1 turns Q1 off
gpio_hold_en(DATA_PIN)
gpio_hold_en(LED_PWR_PIN)
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
gpio_deep_sleep_hold_en() // only needed on ESP32, S2, S3, C3 and C2
#endif
esp_deep_sleep_start()
// Wake
gpio_hold_dis(DATA_PIN)
gpio_hold_dis(LED_PWR_PIN)
gpio_set_level(LED_PWR_PIN, 1) // strip power on
wait for the supply to settle
show() // send fresh frameWithout the hold calls, GPIO pins can lose their state in deep sleep and float, letting the data line drift high or Q2’s base wander. Espressif’s gpio_hold_en() latches the pin level so it survives deep sleep on the ESP32-C6. Older chips such as the original ESP32, ESP32-S3 and ESP32-C3 also need a chip-wide gpio_deep_sleep_hold_en() call.
Check the ESP-IDF Sleep Modes and GPIO docs for your IDF version to confirm pin behavior on the ESP32-C6.
Alternatives, Briefly
| Option | Parts | Cost | Off-state draw | Notes |
|---|---|---|---|---|
| P-FET high-side switch | AO3401A-class P-FET, NPN, 3 to 4 resistors | Lowest | Near zero, per datasheet leakage | Works with any battery voltage the FET supports; size the FET for your strip |
| Load-switch IC | TI TPS22918, small caps | Higher | Near zero, per datasheet leakage | Takes a logic-level enable directly, built-in slew control; limited to roughly 5.5 V and its rated current |
| Lower-standby LEDs | Replacement strip | Varies | Varies by LED type and batch | Check the datasheet’s standby figure before buying |
Software only (clear()) | None | Free | Full per-pixel standby draw | Leaves every driver IC running |
A load switch like the TPS22918 is the tidiest option if your strip fits its voltage and current limits: one chip, no gate-drive math, and a controlled turn-on that’s gentler on the battery. It costs more per board.
Some newer addressable LEDs advertise reduced idle current. Verify that against a stated standby figure in the datasheet. The data-line back-powering trap still applies to these parts.
Checklist Before You Close the Enclosure
- P-FET sits on the positive line, between Battery+ and strip 5V
- NPN driver stage between the GPIO and the P-FET gate
- Gate pull-up (10k to 100k) from gate to source, so the strip defaults to off
- Data pin driven low before power-off and held low through deep sleep with the GPIO hold functions
- Sleep current measured with a multimeter in series on the battery lead, with the strip connected
If that last reading lands close to your board’s sleep current without the strip, you’re done.
Once your sleep current is down to microamps, Hubble Network can connect the device from anywhere using standard Bluetooth chips, without a power-hungry cellular modem eating the battery you just saved. See how it works →