Power and protection/Switching a rail/A load switch

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.

A sleeping board, in 3D
102 mA · lasts 19 hours
Lit: 62 mA in the bar. Five LEDs at one colour each. Now turn them off and watch what the bar still draws.

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:

What a sleeping board still draws
2000 mAh cell
Load switch
Microcontroller
MCU
10 µA
WS2812 bar
1.5 mA
Switch
—
Battery lasts
55 days
The microcontroller is asleep and the LEDs are dark, but the battery lasts only 55 days. The microcontroller is down to 10 µA. Each WS2812 still draws 0.3 mA, because the chip inside it stays awake listening for data: 1.5 mA for the bar, a hundred and fifty times as much. Fit the switch.
TPS22919 (data sheet, typical)
Drawn while off2 nA
Drawn while on8 µA
Resistance while on90 mΩ at 3.6 V
Most it will carry1.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:

The circuit to copy
TPS22919DCKR
Part
One chip, one 1 µF, and a wire from QOD to OUT. SC-70, six pins at 0.65 mm, which an iron can solder. Pin 4 connects to nothing. Put the 1 µF right beside pin 1, and nothing needs to go on ON: the chip’s own 530 kΩ holds it low once it has been low.
TPS22919DCKRTPS22916CYFPR
PackageSC-70, 6 pinsWCSP, 4 balls, 0.78 mm
Solder it by handYesNo, reflow only
Supply1.6 to 5.5 V1 to 5.5 V
Most it will carry1.5 A2 A
Resistance at 3.6 V90 mΩ70 mΩ
Drawn while on8 µA0.5 µA
Drawn while off2 nA10 nA
Output dischargeQOD pin, tie to OUTbuilt in, 150 Ω
Blocks current flowing backNot specifiedYes
Turn-on at 3.6 V1.75 ms1.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.

Browse Fundamentals on the forum →