A load switch
A microcontroller asleep draws microamps. A bar of WS2812 LEDs beside it, sent dark, still draws a milliamp and a half, because the chip in every LED stays awake. A load switch lets one pin cut that power completely, and while it is off the switch itself draws about two nanoamps.
An ESP32 in deep sleep draws about 10 µA. On a 2000 mAh cell that is over twenty years, on paper. Now wire a bar of WS2812 LEDs to it, like the five on the TK33, and send it a dark frame before sleeping. Every LED goes out, and the bar still draws 1.5 mA. Inside each WS2812 is a chip that stays awake listening on the data line for its next colour, and it costs about 0.3 mA an LED whatever colour it shows. No frame you can send turns it off. At 1.5 mA the same cell lasts fifty-five days. The sleep code was fine; the LEDs still have power.
A load switch is the fix. Put it between the battery and the bar, wire its ON pin to a GPIO, and the microcontroller can take the bar's power away before it sleeps.
The microcontroller is awake, the load switch is not fitted, the LEDs are lit, and the battery supplies 102 mA.
What is inside it
The part here is TI's TPS22919, six pins in an SC-70 package about 2 mm square. Inside it is a MOSFET (see a MOSFET as a switch) and everything it takes to work that MOSFET from a pin:
- ON high, switch closed. 1 V counts as high, so a 1.8 V or 3.3 V pin works it on any rail from 1.6 V to 5.5 V.
- ON low, switch open. Below 0.35 V. The module is disconnected from the battery, not merely told to be quiet.
- It turns on gently. The output ramps up over about a millisecond rather than jumping, so the module's capacitors do not snatch a burst of current from the battery and pull the microcontroller's own rail down with it.
You could build the same switch from a P-channel MOSFET and a resistor. On a 3.3 V rail that works. On a 5 V rail it does not: a 3.3 V pin cannot pull the gate high enough to turn the MOSFET off, and you need a second transistor to do it. The chip works the same way on either rail, and the gentle turn-on comes with it.
What it costs
Almost nothing, which is the point of it. Turn the switch and the microcontroller on and off:
| TPS22919 (data sheet, typical) | |
|---|---|
| Drawn while off | 2 nA |
| Drawn while on | 8 µA |
| Resistance while on | 90 mΩ at 3.6 V |
| Most it will carry | 1.5 A, 1.6 to 5.5 V |
The 8 µA only counts while the board is awake and already drawing tens of milliamps. The 90 mΩ costs 9 mV at 100 mA, which the module will not notice.
The circuit
Two parts are worth buying. The TPS22919DCKR is the one this page is about. The TPS22916CYFPR is the one to use on a board that is assembled by machine. The circuit is the same for both: the supply into the chip with a 1 µF capacitor beside it, as both data sheets recommend, ON from a GPIO, and the output to the module. Switch between them:
| TPS22919DCKR | TPS22916CYFPR | |
|---|---|---|
| Package | SC-70, 6 pins | WCSP, 4 balls, 0.78 mm |
| Solder it by hand | Yes | No, reflow only |
| Supply | 1.6 to 5.5 V | 1 to 5.5 V |
| Most it will carry | 1.5 A | 2 A |
| Resistance at 3.6 V | 90 mΩ | 70 mΩ |
| Drawn while on | 8 µA | 0.5 µA |
| Drawn while off | 2 nA | 10 nA |
| Output discharge | QOD pin, tie to OUT | built in, 150 Ω |
| Blocks current flowing back | Not specified | Yes |
| Turn-on at 3.6 V | 1.75 ms | 1.7 ms |
All typical values, from the two data sheets. For a sleeping board the difference in off current does not matter: 2 nA and 10 nA are both at most a thousandth of the microcontroller's 10 µA. What decides it is whether you can solder the part, and whether the output can ever end up above the input.
On the TPS22919 there are two rules:
Never leave ON floating. Write it LOW before going to sleep. Once it has seen a low, the chip connects its own 530 kΩ pull-down and holds the pin there, so the switch stays open even after the GPIO lets go in deep sleep. The same pull-down keeps the module off at power-up until the firmware turns it on.
Tie QOD to OUT. When the switch opens, QOD drains the output through 24 Ω. Leave it unconnected and the module's own capacitors hold its rail up for a while, so a module you meant to reset comes back without resetting.
// Tools: Board "ESP32 Dev Module" (any ESP32 core 3.x board)
const int MODULE_ON = 4; // to the TPS22919's ON pin
const int LED_DATA = 5; // to the WS2812 bar's DATA
void setup() {
pinMode(MODULE_ON, OUTPUT);
digitalWrite(MODULE_ON, HIGH); // the bar has power
delay(10); // the switch needs under 2 ms
// ... show the colours; the bar comes up dark, so send them every wake ...
pinMode(LED_DATA, OUTPUT);
digitalWrite(LED_DATA, LOW); // nothing feeds the bar through its data pin
digitalWrite(MODULE_ON, LOW); // cut its power before sleeping
esp_sleep_enable_timer_wakeup(10ULL * 60 * 1000000); // ten minutes
esp_deep_sleep_start();
}
void loop() {}When it is the wrong part
- More than 5.5 V or 1.5 A. Choose a bigger switch.
- You need a current limit as well. The SY6280 switches from a pin too, and lets one resistor set the limit.
- The output can end up above the input, as it can between two supplies. The TPS22919's data sheet promises nothing about current flowing backwards. The TPS22916C blocks it; for two supplies feeding one rail, see the ideal diode.
- The module has a sleep mode of its own that gets it down to microamps. Use that first, because the cheapest part is the one you do not fit.
Edit this page — content/fundamentals/power/a-load-switch.mdx
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.