Articles › Electronics

Powering an ESP32: USB, the 5V pin, the 3V3 pin and battery-life math

USB 5 V versus the 3V3 pin, why the LDO needs headroom, the current budget when Wi-Fi transmits, and battery life with deep sleep worked out step by step.

Intermediate 6 min read October 22, 2026 Maker electronics for beginners · lesson 5/10

What you will learn
  • An ESP32 board takes power one of three ways (USB, the 5V pin or the 3V3 pin), and only one at a time.
  • The 3V3 pin needs a regulated 3.0–3.6 V. Never wire a lithium cell straight to it: a full cell is 4.2 V.
  • The chip draws up to about 240 mA while transmitting Wi-Fi, so the supply should deliver at least 500 mA.
  • Battery life depends on sleep current more than awake current. A dev board's LED and support chips can drain a battery in days.

An ESP32 board can be powered three ways: the USB port, the 5V pin or the 3V3 pin. Each has its own rules, and you use one at a time. On a battery, what decides how many days you get is not the time the board is working but the time it is asleep. This article follows the power path on the board, sets a current budget and works out battery life step by step.

Chip figures come from Espressif’s ESP32 Series Datasheet. The examples assume an ESP32-DevKitC style board (ESP32-WROOM-32 module). For an ESP32-C3 or S3, check that chip’s datasheet.

How power travels on the board

The ESP32 chip runs on 2.3–3.6 V. Espressif recommends 3.3 V from a supply that can deliver 500 mA or more. USB gives 5 V, so the board carries an LDO (low-dropout regulator) that brings 5 V down to 3.3 V.

InputVoltage it expectsThrough the LDO?When to use it
USB port5 V from a computer or chargerYesCoding and testing on the bench
5V pin5 V from an external supplyYesInstalled builds on a 5 V adapter
3V3 pinRegulated 3.3 V (no more than 3.6 V)NoYou already have your own regulator

The ESP32-DevKitC guide is explicit: these three are mutually exclusive. Use more than one and the board or the supply can be damaged.

Nothing sits between the 3V3 pin and the chip. Put more than 3.6 V on it and you exceed the chip’s rating directly.

USB 5 V or the 5V pinpower comes in hereLDOdrops it to 3.3 VESP32 chipruns on 3.3 V3V3 pinstraight to the chip, no LDO
USB and the 5V pin go through the LDO; the 3V3 pin feeds the chip directly. Use one at a time

The LDO needs headroom (dropout)

An LDO only regulates when its input is higher than its output by a certain margin, the dropout voltage. Many budget boards use a 1117-family part; the AMS1117 datasheet gives about 1.1 V dropout (1.3 V maximum) at 800 mA.

Two cases:

  1. USB 5 V in: 5.0 − 1.3 = 3.7 V, above the 3.3 V we need. The LDO regulates normally.
  2. One lithium cell into the 5V pin: a full cell is 4.2 V, giving 4.2 − 1.1 = 3.1 V. Once the cell sags to 3.7 V, you are down to about 2.6 V, well under 3.3 V.

In case 2 the board may still boot, but when Wi-Fi pulls a burst of current the voltage dips and the board resets itself (brownout). The symptom: it reboots in a loop while connecting to Wi-Fi, yet works fine on USB. Fixes: a regulator with genuinely low dropout, a buck-boost converter, or a board designed for a lithium cell (battery connector and charger on board).

Heat is the other cost. An LDO burns the excess voltage as heat. At 5 V in and 250 mA: (5.0 − 3.3) × 0.25 ≈ 0.43 W, which is why that little part gets warm under load. If you power sensors or modules from the 3V3 pin, count their current too.

Current budget: how much, and when

From the ESP32 chip datasheet (other parts on the board not included):

StateApproximate current
Wi-Fi transmit, 802.11b at +19.5 dBm240 mA
Wi-Fi transmit, 802.11n MCS7 at +14 dBm180 mA
Wi-Fi receive95–100 mA
Light-sleep0.8 mA
Deep-sleep (RTC timer + RTC memory)10 µA

The 240 mA figure is a short burst during transmission, not an average, but the supply must ride through it without sagging. That is why Espressif asks for 500 mA, with room for everything else. A computer’s USB 2.0 port gives about 500 mA: fine for a bare board and a small sensor, not for a string of LEDs or a motor.

What deep sleep is

In deep sleep the CPUs, most RAM and Wi-Fi are off. Only the RTC circuitry and RTC memory stay powered. A timer or certain GPIO pins can wake the chip. The point people miss: waking restarts the program from setup(). It does not carry on from the line that put it to sleep.

An Arduino-ESP32 sketch that wakes every 10 minutes, reads, sends and sleeps again:

RTC_DATA_ATTR int bootCount = 0;   // lives in RTC memory, survives sleep

void setup() {
  bootCount++;
  // read the sensor, connect Wi-Fi, send data here
  esp_sleep_enable_timer_wakeup(600ULL * 1000000ULL);  // 600 seconds, in microseconds
  esp_deep_sleep_start();
}

void loop() {}  // never reached: the chip sleeps first

Deeper low-power programming, such as the ULP coprocessor or cutting Wi-Fi connect time, is a programming topic of its own. Here we stay with the power supply.

Battery life, step by step

The job: a weather node wakes every 600 seconds, stays awake 4 seconds to connect and send, and runs from a 2,000 mAh cell.

The currents below are example assumptions. Measure your own board for real numbers.

  • Awake: 150 mA average (receive, transmit and waiting mixed together)
  • Asleep, board A: a stripped-down board measured at 0.05 mA
  • Asleep, board B: a dev board with a power LED, USB-serial chip and an LDO with its own draw, measured at 6 mA

Step 1: charge used per cycle (mA·s)

  • Awake: 150 × 4 = 600
  • Asleep, A: 0.05 × 596 = 29.8, total 629.8
  • Asleep, B: 6 × 596 = 3,576, total 4,176

Step 2: average current over the 600-second cycle

  • A: 629.8 ÷ 600 ≈ 1.05 mA
  • B: 4,176 ÷ 600 ≈ 6.96 mA

Step 3: battery life, counting only 80% of capacity as usable = 1,600 mAh

  • A: 1,600 ÷ 1.05 ≈ 1,524 hours ≈ 63 days
  • B: 1,600 ÷ 6.96 ≈ 230 hours ≈ 9.6 days

Same code, different board, almost 7 times the battery life. The datasheet’s 10 µA is the chip alone. The board’s LED, its USB-serial chip and the LDO (the AMS1117 datasheet lists roughly 5 mA of its own quiescent current) do not go to sleep with it.

On battery, measure sleep current before anything else. That one number decides battery life more than any line of code.

Common mistakes

  • A lithium cell straight on the 3V3 pin. A full cell is 4.2 V, over the chip’s 3.6 V limit.
  • An undersized supply. Some chargers and power banks cannot keep up with the current bursts, and the board resets while joining Wi-Fi.
  • Two supplies at once. USB left plugged in while the 5V pin is fed from somewhere else.
  • Trusting 10 µA and computing battery life from it without measuring the real board.
  • Forgetting that waking is a restart. A counter in an ordinary variable never goes up.
  • Thin, long wires. Voltage drops along them during bursts. Keep leads short and put a capacitor near the board (Espressif suggests at least 10 µF at the power input).

If calculating current with Ohm’s law is new, start with wiring an LED to an ESP32.

Sources

FAQ

Can I leave USB plugged in and also feed a battery into the 5V pin?

Better not. The ESP32-DevKitC guide says to use one power source only, or the board or the source can be damaged. If you want USB and a battery, use a board with a built-in charger and power switching.

My variables reset after deep sleep. Why?

Waking from deep sleep restarts the program from setup(). Declare anything you want to keep with RTC_DATA_ATTR so it lives in RTC memory, which stays powered while the chip sleeps.

How do I measure sleep current?

Put a multimeter in current mode in series with the battery's positive lead. Start on the mA range and switch to µA only after the board is asleep, because the boot current can be too much for the µA range.

Circuits and code were tested on sample boards. Boards differ in pin layout, so check your board's pinout before you power anything.