Skip to content
You Start with one site
Amounts in Start with one site
Embedded Systems & Electronics · Course

ESP32 Battery IoT Node

Lesson 6 of 9 23 min read
Made with KiCad 10checked November 2026Newer version?
Stays the same
  • Schematic first, then the board
  • Footprints, nets and design rules
  • Ground planes, return paths and clearances
  • Gerbers and a drill file for the maker
May look different
  • Menu places and hotkeys
  • The look of the plugin and library managers
  • Default design rules
  • Dialog fields (KiCad 10 gave rectangles a corner radius)
  • The Python module: SWIG pcbnew is deprecated in favour of kicad-cli and the IPC API

A step looks different? Most commands have a hotkey listed in Help, then the list of hotkeys.

The ideas in this lesson do not depend on the version. Where a click moved, the lesson still names the command.

Found this useful?

A development board running an ESP32 draws 40 to 80 mA even in idle, which drains a small lithium cell in a day or two. For a sensor node deployed outdoors or in a hard-to-reach location, you need a purpose-built board where every component is chosen for minimal quiescent current: a low-Iq LDO instead of a dev board’s wasteful regulator, a charging IC that can top up from a solar panel, and a layout that keeps leakage paths short. In this lesson you will design that board around the ESP32-C3-MINI-1, with TP4056 lithium charging, solar input, battery protection, and a power budget targeting months of operation on a single cell. #KiCad #ESP32 #IoT

Power System Block DiagramSolar Panel(5V, 200mA)USB-C (5V)TP4056DW01A + 8205A(charger)(battery protection)Li-Po Battery (3.7V, 1000mAh)ME6211 LDO3.3V rail(Iq ~40uA)ESP32-C3BME280Deep sleep: ESP32 ~5uA + LDO ~40uA= ~45uA total board current

What We Are Building

Battery-Powered ESP32-C3 IoT Sensor Node

A compact wireless sensor node that monitors temperature, humidity, and barometric pressure using a BME280. The ESP32-C3 wakes from deep sleep every 10 minutes, reads the sensor, transmits data over WiFi or BLE, and returns to sleep. A TP4056 charges the lithium battery from USB-C or a small solar panel. The entire board targets under 10 µA sleep current for months of autonomous operation.

Board specifications:

ParameterValue
MCUESP32-C3-MINI-1 (RISC-V, 160 MHz, WiFi, BLE 5.0)
SensorBME280 (temperature, humidity, pressure)
Battery3.7V Li-Po/Li-Ion via JST-PH 2-pin connector
ChargingTP4056 linear charger, 4.2V, 500 mA max
Solar Input5V solar panel via JST-PH 2-pin connector
ProtectionDW01A + 8205A (overcurrent, overdischarge, overcharge)
RegulatorME6211 3.3V LDO (500 mA, ~40 µA quiescent)
USBUSB-C (charging + native USB programming)
Deep SleepTarget under 10 µA total board current
Size~45 x 30 mm

Bill of Materials

RefComponentPackageQtyNotes
U1ESP32-C3-MINI-1Module (13.2 x 16.6 mm)1PCB antenna, RISC-V core
U2TP4056SOP-81Linear Li-Ion/Li-Po charger
U3DW01ASOT-23-61Battery protection IC
U4ME6211C33M5GSOT-23-513.3V 500 mA LDO
U5BME280LGA-8 (2.5 x 2.5 mm)1Environmental sensor
Q18205ATSSOP-81Dual N-MOSFET for battery protection
BME280sensorDW01A +8205ATP4056chargerUSB-C+ ESDComponent Placement Zones (top view)ESP32-C3-MINI(WiFi/BLE)AntennaKEEPOUTaway fromheatsourcesJST battery conn
ReferenceValuePackageQtyFunction
Q2SI2301SOT-231P-MOSFET for sensor power switching
J1USB-C receptacleUSB-C 6-pin1Charging and programming
J2JST-PH 2-pinThrough-hole1Battery connector
J3JST-PH 2-pinThrough-hole1Solar panel connector
D1SS14SMA1Schottky diode, solar input
D2SS14SMA1Schottky diode, USB input
LED1Red LED06031Charging indicator
LED2Green LED06031Standby indicator
R1, R25.1 kΩ04022USB-C CC1, CC2 pull-downs
R32 kΩ04021TP4056 PROG (500 mA charge)
R41 kΩ04022LED current limiting
R510 kΩ04021ESP32-C3 EN pull-up
R6, R710 kΩ04022I2C pull-ups (SDA, SCL)
R8100 kΩ04021DW01A pull-down
R9100 kΩ04021Sensor power MOSFET gate pull-up
C1, C210 µF08052LDO input and output
C3100 nF04021LDO output
C4-C6100 nF04023Decoupling (ESP32, BME280, TP4056)
C710 µF08051ESP32-C3 bulk decoupling
C8100 nF04021BME280 decoupling
SW1Tactile switchSMD 3x6mm1Reset (EN)
SW2Tactile switchSMD 3x6mm1Boot (GPIO9)

Power System Design



The power system is the heart of any battery-operated design. A poorly designed power path can drain a battery in days. This section covers each stage of the power chain, from charging through regulation, and explains how each component contributes to the total sleep current budget.

Battery Charging: TP4056

The TP4056 is a complete constant-current, constant-voltage linear charger for single-cell lithium batteries. It charges to 4.2V and automatically terminates when the charge current drops below a threshold (typically 1/10 of the programmed current).

Key connections:

  • PROG pin: A resistor from PROG to GND sets the charge current. For 500 mA charging, use a 2 kΩ resistor. For solar charging with a small panel (100 mA), you might use a 10 kΩ resistor instead.
  • VIN: Connect to the USB-C VBUS or solar panel output through the diode-OR network.
  • BAT: Connect to the battery through the DW01A protection circuit.
  • CHRG and STDBY: Open-drain outputs that drive the charging and standby indicator LEDs.

Charge current reference:

PROG ResistorCharge Current
10 kΩ130 mA
5 kΩ250 mA
2 kΩ500 mA
1.2 kΩ830 mA
1 kΩ1000 mA

Solar and USB Input: Diode-OR

The board accepts power from either USB-C or a solar panel. A diode-OR network using two Schottky diodes (SS14) connects both sources to the TP4056 VIN pin. Whichever source has the higher voltage forward-biases its diode and supplies current. The Schottky diodes have low forward voltage drop (~0.3V), minimizing power loss.

The circuit is straightforward:

  • USB VBUS connects through D2 (SS14) to TP4056 VIN.
  • Solar panel output connects through D1 (SS14) to TP4056 VIN.
  • A 10 µF capacitor on VIN smooths the input.

When both sources are present, USB typically wins because the solar panel open-circuit voltage is usually around 5 to 6V and drops under load, while USB provides a stable 5V.

Battery Protection: DW01A + 8205A

The DW01A is a lithium battery protection IC that monitors the cell voltage and current. It controls the 8205A, a dual N-channel MOSFET that sits in the battery’s ground path. Together they protect against three failure modes.

ProtectionThresholdAction
Overcharge~4.3VDisconnects charge path
Overdischarge~2.4VDisconnects load
Overcurrent~3ADisconnects load

The DW01A connects between B+ and B- of the battery. Its OD and OC pins drive the gates of the two MOSFETs in the 8205A. The 8205A sits between the battery negative terminal and system ground. When a fault is detected, the appropriate MOSFET turns off, disconnecting the battery.

Voltage Regulation: ME6211 LDO

The ME6211C33M5G provides a stable 3.3V output from the battery voltage (3.0V to 4.2V). Its key advantage for battery applications is the very low quiescent current, approximately 40 µA. This is the current the regulator itself consumes even when the load draws nothing. For a broader look at LDO selection, switching regulators, and power rail design, see Analog Electronics: Power Supply Design.

  • Input: Battery voltage (3.0V to 4.2V from the protected output)
  • Output: 3.3V, up to 500 mA
  • Dropout voltage: ~100 mV at light loads
  • Input capacitor: 10 µF ceramic
  • Output capacitors: 10 µF ceramic + 100 nF ceramic

Power Budget Calculation

Understanding your total sleep current is critical for estimating battery life. Every component that remains powered during deep sleep contributes to the total.

ComponentSleep CurrentNotes
ESP32-C3 deep sleep~5 µARTC memory retained
BME280 sleep mode~0.1 µAPowered off via MOSFET: 0 µA
ME6211 quiescent~40 µAAlways on
TP4056 standby~2 µABattery full, no input
DW01A + 8205A~3 µAProtection circuit
Pull-up/pull-down resistors~1 µADepends on values chosen
Total sleep current~51 µAConservative estimate

Battery life estimate with a 500 mAh cell:

  • Sleep current: ~51 µA
  • Wake current: ~80 mA for WiFi TX, ~5 mA for sensor read
  • Wake duration: ~5 seconds every 10 minutes (0.83% duty cycle)
  • Average current: 51 µA + (80 mA x 0.0083) ≈ 51 µA + 664 µA ≈ 715 µA
  • Battery life: 500 mAh / 0.715 mA ≈ 699 hours ≈ 29 days with WiFi

For BLE-only transmission (peak ~15 mA, wake ~2 seconds):

  • Average current: 51 µA + (15 mA x 0.0033) ≈ 51 µA + 50 µA ≈ 101 µA
  • Battery life: 500 mAh / 0.101 mA ≈ 4950 hours ≈ 206 days

With a small solar panel providing even modest charging on sunny days, the system can run indefinitely.

Deep Sleep Considerations for PCB Design



Designing for low sleep current is not just a firmware problem. The PCB itself can waste microamps through pull-up resistors, indicator LEDs, and always-on peripherals. This section covers the hardware design choices that make deep sleep effective.

Resistor Values Matter

Every pull-up or pull-down resistor that connects a voltage rail to ground (through a GPIO or other node) creates a constant current leak. For a 3.3V rail:

Resistor ValueLeak Current
4.7 kΩ702 µA
10 kΩ330 µA
47 kΩ70 µA
100 kΩ33 µA

Rules for battery-powered designs:

  • Use 100 kΩ or higher for pull-ups/pull-downs where possible
  • I2C pull-ups: use 10 kΩ instead of the common 4.7 kΩ. At 100 kHz I2C clock speed, 10 kΩ works reliably for short bus lengths (under 10 cm on a PCB)
  • The EN pin pull-up on the ESP32-C3 can be 100 kΩ with a 1 µF capacitor for slow rise time

LED Power Waste

A typical indicator LED draws 5 to 20 mA. If a power LED stays on during deep sleep, it dominates the entire current budget. Solutions:

  • Remove the power LED entirely (simplest approach for deployed sensor nodes)
  • Add a solder jumper in series with the LED, so you can cut the trace after debugging
  • Gate the LED with a MOSFET controlled by a GPIO (only illuminate when the processor is awake)

In this design, the TP4056 CHRG and STDBY LEDs only illuminate during charging, so they do not affect sleep current when running on battery alone.

Switchable Sensor Power

The BME280 draws about 0.1 µA in sleep mode, which is negligible. However, for sensors that draw more idle current, or to ensure a clean sensor startup, you can switch the sensor’s power rail using a P-channel MOSFET controlled by a GPIO.

The circuit uses a SI2301 P-MOSFET:

  • Source: 3.3V rail
  • Drain: Sensor VCC (BME280 VDD)
  • Gate: GPIO pin through a 100 kΩ pull-up to 3.3V

When the GPIO drives LOW, the MOSFET turns on and powers the sensor. When the GPIO is HIGH (or floating during deep sleep with the pull-up), the MOSFET turns off and the sensor draws zero current.

USB-UART Bridge Current

Many ESP32 development boards include a CP2102 or CH340 USB-to-UART bridge chip. These draw 5 to 15 mA even when idle, which destroys battery life. The ESP32-C3 has native USB support built into the chip, eliminating the need for an external bridge. This saves board space, BOM cost, and significant sleep current.

Schematic Capture



Open KiCad 9 and create a new project named “esp32c3-iot-sensor”. The schematic has five functional blocks: USB-C input, battery charging and protection, voltage regulation, ESP32-C3 module, and the BME280 sensor with switchable power. Lay out each block in its own area of the schematic sheet.

Download Schematic PDF

USB-C Connector

  1. Place the USB-C connector (6-pin simplified)

    For a power and programming connection, you only need VBUS, GND, D+, D-, CC1, and CC2. Place two 5.1 kΩ resistors from CC1 and CC2 to GND. These tell the USB host that this is a device requesting default USB power (5V, up to 500 mA).

    Connect VBUS through Schottky diode D2 to the TP4056 VIN net.

  2. Connect the USB data lines

    The ESP32-C3 native USB pins are GPIO18 (D-) and GPIO19 (D+). Route these directly from the USB-C connector to the module pins. No external components are needed; the ESP32-C3 handles USB internally.

TP4056 Charging Circuit

  1. Place the TP4056 IC

    Connect VIN to the diode-OR output from USB and solar. Place a 10 µF input capacitor close to the VIN pin.

  2. Set the charge current

    Place a 2 kΩ resistor from the PROG pin to GND. This programs a 500 mA charge current. If using a small solar panel as the primary source, consider 10 kΩ (130 mA) to match the panel’s output capability.

  3. Add status LEDs

    Connect CHRG to LED1 (red) through a 1 kΩ resistor to VIN. Connect STDBY to LED2 (green) through a 1 kΩ resistor to VIN. Both pins are open-drain, so they sink current through the LEDs.

  4. Connect BAT to the protection circuit

    The TP4056 BAT pin connects to the positive terminal of the DW01A protection circuit (B+ net).

Solar Panel Input

  1. Place the solar panel connector (J3)

    Use a JST-PH 2-pin connector. Connect the positive pin through Schottky diode D1 to the TP4056 VIN net (same net as the USB diode output).

  2. Add reverse polarity protection

    The Schottky diode D1 also prevents current from flowing back into the solar panel when USB is connected or the battery voltage exceeds the panel voltage.

Battery Protection Circuit

  1. Place the DW01A

    Connect VCC to B+ (battery positive). Connect VSS to the drain of the low-side MOSFET in the 8205A. The OD (overdischarge) and OC (overcharge/overcurrent) pins connect to the gates of the two MOSFETs in the 8205A.

  2. Place the 8205A dual MOSFET

    The 8205A contains two N-channel MOSFETs in series. Connect the source of one MOSFET to the battery negative terminal (B-). Connect the drain of the other MOSFET to system ground (GND). The gates connect to the DW01A OD and OC pins.

  3. Add the current sense resistor path

    Place a 100 kΩ resistor from the DW01A CS pin to the junction between the two MOSFETs. This is the current sense input for overcurrent detection.

Battery Connector

Place a JST-PH 2-pin connector (J2) for the battery. Connect the positive pin to B+ (feeding into the DW01A protection). Connect the negative pin to B- (battery ground, before the protection MOSFETs).

ME6211 LDO

  1. Place the ME6211C33M5G

    Connect VIN to the protected battery output (the system side of the 8205A, which is the node between the TP4056 BAT pin and the load). Place a 10 µF input capacitor close to VIN.

  2. Add output capacitors

    Place a 10 µF ceramic and a 100 nF ceramic on the 3.3V output, close to the VOUT pin. The ME6211 requires at least 1 µF output capacitance for stability.

  3. Connect EN

    Tie the enable pin directly to VIN so the regulator is always on when battery voltage is present.

ESP32-C3-MINI-1 Module

  1. Place the module

    The ESP32-C3-MINI-1 has castellated pads around its edges and a large ground pad underneath. Connect VCC (pin 2) to the 3.3V rail. Connect all GND pins and the exposed pad to GND.

  2. Add decoupling

    Place a 10 µF bulk capacitor and a 100 nF capacitor close to the VCC pin.

  3. EN (enable) circuit

    Connect a 100 kΩ pull-up resistor from EN to 3.3V. Add a 1 µF capacitor from EN to GND for a slow rise time, which ensures reliable startup. Connect the reset button (SW1) between EN and GND.

  4. Boot button

    Connect SW2 between GPIO9 and GND. Holding GPIO9 low during reset puts the ESP32-C3 into download mode for flashing firmware over USB.

  5. I2C pins for BME280

    Assign GPIO4 as SDA and GPIO5 as SCL. Place 10 kΩ pull-up resistors from each to the 3.3V rail.

  6. Sensor power control

    Assign GPIO3 as the sensor power control pin. Connect it to the gate of the P-MOSFET (Q2) through a 100 Ω gate resistor for EMI damping.

BME280 Sensor

  1. Place the BME280

    The BME280 comes in a tiny LGA-8 package (2.5 x 2.5 mm). Connect VDD to the switched 3.3V rail (drain of Q2). Connect GND to ground. Place a 100 nF decoupling capacitor close to VDD.

  2. Set the I2C address

    Connect the SDO pin to GND for I2C address 0x76, or to VDD for address 0x77. GND is the more common choice.

  3. Connect I2C

    Connect SDA to GPIO4 and SCL to GPIO5 on the ESP32-C3. The pull-up resistors are already on the main 3.3V rail, which means I2C communication works even when the sensor power MOSFET is off (the pull-ups hold the lines high).

  4. CSB pin

    Connect CSB to VDD (the switched rail) to select I2C mode. If CSB is left floating, the BME280 may enter SPI mode.

Run ERC and Assign Footprints

  1. Run Electrical Rules Check

    Fix any unconnected pins, missing power flags, or conflicting outputs. Add power flags on the battery input net and USB VBUS net if KiCad reports them as undriven.

  2. Assign footprints

    Use the footprint assignment tool to map each symbol to its physical package. The ESP32-C3-MINI-1 footprint may need to be downloaded from Espressif’s KiCad library or the SnapEDA/Ultra Librarian services.

  3. Generate the netlist

    Export the netlist and open the PCB editor.

PCB Layout



The PCB layout for a battery-powered IoT node requires careful attention to three areas: antenna clearance for the ESP32-C3, thermal management for the TP4056 charger, and short power paths for low impedance. The target board size is 45 x 30 mm on a 2-layer PCB.

Board Setup

  1. Set the board outline

    Draw a 45 x 30 mm rectangle on the Edge.Cuts layer. Add rounded corners with a 1 mm radius for a cleaner look and easier handling.

  2. Configure design rules

    Set minimum trace width to 0.15 mm, minimum clearance to 0.15 mm. For power traces (VBAT, 3.3V, GND), use 0.4 mm or wider. USB data traces can use 0.25 mm.

  3. Set up the ground pour

    Plan for copper fills on both front and back layers connected to GND. Do not pour them yet; wait until all traces are routed.

Component Placement

  1. Place the ESP32-C3-MINI-1 module

    Position it along one short edge of the board with the antenna extending past the board edge or flush with it. The antenna end must have no copper on any layer within 2 mm of the antenna area.

  2. Place the USB-C connector

    Position it on the opposite short edge from the antenna. This keeps the USB cable away from the antenna, reducing interference.

  3. Place the TP4056 and protection circuit

    Group the TP4056, DW01A, 8205A, and their associated passives near the USB-C connector and battery connector. The TP4056 dissipates heat during charging (up to ~1.5W at 500 mA from 5V to a 3.7V battery), so place it with access to a copper pour for heat spreading.

  4. Place the battery and solar connectors

    Position J2 (battery) and J3 (solar) along one long edge of the board. Through-hole JST connectors need clearance for the housing.

  5. Place the ME6211 LDO

    Position it between the charging/protection section and the ESP32-C3. Keep input and output capacitors within 3 mm of the IC.

  6. Place the BME280

    Position it away from the TP4056 and LDO to avoid heat from those components affecting temperature readings. The ideal location is near the board edge, far from heat sources. Consider adding a routed slot or thermal relief cutout in the PCB between the sensor and the power section.

  7. Place buttons and LEDs

    Position the reset and boot buttons where they are accessible. Place the charging LEDs near the USB connector.

Antenna Keepout Zone

In KiCad, draw a keepout area on both copper layers covering the antenna region. Set the keepout to prohibit copper fills and tracks. The Espressif datasheet specifies the exact dimensions.

Thermal Management for TP4056

The TP4056 in SOP-8 package does not have an exposed thermal pad, so it relies on the PCB copper for heat dissipation. During charging at 500 mA from a 5V source into a 3.7V battery, the IC dissipates approximately:

P = (5V - 3.7V) x 0.5A = 0.65W

This is manageable, but the copper area around the thermal pad and GND pins should be as large as practical. Connect the GND pad to a wide copper pour on both layers with multiple vias.

Routing Guidelines

  1. Route power traces first

    Start with VBAT, 3.3V, and GND. Use 0.4 mm or wider traces. Keep the path from the LDO output to the ESP32-C3 VCC short and direct.

  2. Route USB data lines

    Keep D+ and D- as a parallel pair with consistent spacing. Match their lengths to within 0.5 mm. Avoid routing them near switching signals or the antenna.

  3. Route I2C lines

    SDA and SCL to the BME280. These are low-speed signals, so routing is straightforward. Keep them reasonably short and away from the antenna area.

  4. Fill copper zones

    Pour ground fills on both front and back layers. Add vias to stitch the ground planes together, especially near the ESP32 module ground pad and the TP4056 ground area.

  5. Run DRC

    Check for clearance violations, unrouted nets, and minimum width errors. Fix any issues before generating Gerbers.

Manufacturing



Export Gerbers and drill files from KiCad using File, then Plot. Select all copper layers (F.Cu, B.Cu), silkscreen layers, mask layers, and Edge.Cuts. Generate the drill file in Excellon format. Compress all files into a single ZIP.

Upload to JLCPCB or your preferred fabricator. For this 2-layer board, standard settings work well:

ParameterSetting
Layers2
PCB thickness1.6 mm
Surface finishHASL (lead-free) or ENIG
Copper weight1 oz
Solder maskGreen (or your preference)
Min trace/space6/6 mil (0.15/0.15 mm)

Order a stencil for the top layer if you plan to reflow solder the QFN and LGA components. The BME280 in LGA-8 and the 8205A in TSSOP-8 are much easier to solder with paste and hot air or a reflow oven than by hand.

Firmware: Deep Sleep Sensor Reading



The firmware demonstrates the core IoT sensor pattern: wake up, read sensors, transmit data, go back to sleep. This example uses the Arduino framework for the ESP32-C3, reads the BME280 over I2C, prints the data to USB serial, and enters deep sleep for 10 minutes.

Arduino Setup

Install the ESP32 board package in Arduino IDE (or PlatformIO). Select “ESP32C3 Dev Module” as the board. Install the Adafruit BME280 library and the Adafruit Unified Sensor library from the Library Manager.

Complete Sketch

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// Pin definitions
#define SDA_PIN 4
#define SCL_PIN 5
#define SENSOR_POWER_PIN 3
// Deep sleep duration: 10 minutes in microseconds
#define SLEEP_DURATION_US 600000000ULL
// BME280 I2C address (SDO to GND = 0x76)
#define BME280_ADDR 0x76
Adafruit_BME280 bme;
void setup() {
// Initialize USB serial
Serial.begin(115200);
delay(100);
// Power on the BME280 sensor
pinMode(SENSOR_POWER_PIN, OUTPUT);
digitalWrite(SENSOR_POWER_PIN, LOW); // P-MOSFET: LOW = ON
// Wait for sensor power to stabilize
delay(50);
// Initialize I2C
Wire.begin(SDA_PIN, SCL_PIN);
// Initialize BME280
if (!bme.begin(BME280_ADDR, &Wire)) {
Serial.println("BME280 not found. Check wiring.");
goToSleep();
return;
}
// Set BME280 to forced mode for single reading
bme.setSampling(
Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, // temperature
Adafruit_BME280::SAMPLING_X1, // pressure
Adafruit_BME280::SAMPLING_X1, // humidity
Adafruit_BME280::FILTER_OFF,
Adafruit_BME280::STANDBY_MS_0_5
);
// Take a forced measurement
bme.takeForcedMeasurement();
// Read sensor data
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F; // hPa
// Print data
Serial.println("=== IoT Sensor Reading ===");
Serial.print("Temperature: ");
Serial.print(temperature, 1);
Serial.println(" C");
Serial.print("Humidity: ");
Serial.print(humidity, 1);
Serial.println(" %");
Serial.print("Pressure: ");
Serial.print(pressure, 1);
Serial.println(" hPa");
Serial.println("==========================");
Serial.flush();
// Power off the sensor
digitalWrite(SENSOR_POWER_PIN, HIGH); // P-MOSFET: HIGH = OFF
// Go to deep sleep
goToSleep();
}
void goToSleep() {
Serial.println("Entering deep sleep for 10 minutes...");
Serial.flush();
// Configure deep sleep timer
esp_sleep_enable_timer_wakeup(SLEEP_DURATION_US);
// Enter deep sleep
esp_deep_sleep_start();
}
void loop() {
// This never executes. After deep sleep,
// the ESP32-C3 resets and runs setup() again.
}

How It Works

The ESP32-C3 deep sleep mechanism resets the processor on wake. Execution always starts from setup(), not from where it left off. The RTC memory retains a small amount of data across sleep cycles if needed (for example, a boot counter or accumulated readings).

The firmware flow:

  1. Wake from deep sleep (or initial power-on)
  2. Drive GPIO3 LOW to turn on the sensor power MOSFET
  3. Wait 50 ms for the sensor power rail to stabilize
  4. Initialize I2C and the BME280
  5. Take a forced measurement (single reading, lowest power)
  6. Read temperature, humidity, and pressure
  7. Print the data over USB serial
  8. Drive GPIO3 HIGH to turn off the sensor
  9. Enter deep sleep for 10 minutes

To add WiFi transmission, insert a WiFi connect and HTTP POST (or MQTT publish) between step 7 and step 8. WiFi adds approximately 3 to 5 seconds of wake time and 80 to 150 mA of current draw.

PlatformIO Alternative

If you prefer PlatformIO, create a project with the following platformio.ini:

[env:esp32c3]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
lib_deps =
adafruit/Adafruit BME280 Library@^2.2.2
adafruit/Adafruit Unified Sensor@^1.1.9

The source code is identical. Place it in src/main.cpp.

What You Have Learned



Lesson 6 Complete

KiCad skills:

  • Designed a multi-source power input with diode-OR topology
  • Placed and connected a lithium battery charging circuit (TP4056) with protection (DW01A + 8205A)
  • Managed antenna keepout zones for the ESP32-C3 WiFi/BLE module
  • Applied thermal management techniques for power dissipation in the TP4056
  • Routed a compact 2-layer board with ground pours on both sides

Electronics skills:

  • Lithium battery charging, protection, and safety circuit design
  • Solar panel input integration with USB charging
  • Low-quiescent-current LDO selection for battery applications
  • Power budget analysis for deep sleep IoT devices
  • Switchable sensor power using P-channel MOSFETs

Firmware skills:

  • ESP32-C3 deep sleep with timer wakeup
  • BME280 forced mode measurement for lowest power consumption
  • GPIO-controlled sensor power switching
  • Arduino framework for ESP32-C3 with native USB serial

Comments

Loading comments...


© 2021-2026 SiliconWit®. All rights reserved.
Predict first

A sensor node sleeps at 51 µA. Every 10 minutes it wakes for 5 seconds and takes 80 mA to send a reading over WiFi. Where does most of the battery's energy go?

See it: battery life against the reporting interval

Average current
Used while awake
Battery life

The cell is 500 mAh. The curve uses the formula above: average current = sleep current + wake current × wake time / interval. The dashed line is the life the node would have if it never woke. The figure does not round the fraction 5 / 600, so it shows 718 µA where the text has 715 µA. A real cell also loses some charge by itself, so read the long lives as upper limits.

Check yourself

Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.

1. The WiFi node of the lesson (51 µA asleep, 80 mA for 5 s when awake, 500 mAh cell) lasts 29 days when it reports every 10 minutes. The owner changes it to report every 60 minutes. About how long does it last now?

2. You build the same board for a small 200 mAh cell. Its maker allows a charge current of 100 mA at most. Which PROG resistor do you fit?

3. A new cell arrives with the same type of 2-pin plug as the board, but from another seller. The board has the DW01A protection circuit. What do you do first?

80 mA for 5 s51 µA for 595 severy 10 min 93 % awakeasleep 7 %
whole board asleepone 10 kΩ pull-up, pin held low 51 µA330 µA WiFi node: 29 days becomes 20 days
Watch it build: the power path
TP4056 cell 2.4 kΩ USB solar DW01A8205A ME6211 ESP32 3.3 V constant current, then 4.2 V 1200 ÷ 2400 = 0.5 A each diode loses about 0.3 V cuts at 4.3 V, 2.4 V, 3 A 3.3 V out, 40 µA for itself
  1. The TP4056 charges the cell at constant current, then holds 4.2 V while the current falls.
  2. The PROG resistor sets the current: 1200 ÷ 2400 Ω = 0.5 A for a 500 mAh cell.
  3. USB and the solar panel each reach VIN through an SS14 diode, about 0.3 V lost.
  4. The DW01A and the 8205A switches sit in the negative line and disconnect the cell on a fault.
  5. The ME6211 makes 3.3 V for the ESP32-C3 and takes about 40 µA itself.
Solar panel 5 V USB-C 5 V TP4056 charger protection DW01A + 8205A + lithium cell 3.7 V, 500 mAh ME6211 LDO regulator 3.3 V ESP32-C3 BME280
USB-C TP4056 (warm) ESP32-C3 module antenna KEEP-OUT no copper protection LDO battery J2 solar J3 BME280 45 mm Board 45 x 30 mm, 2 layers, corners 1 mm round.
Outline to scale; part sizes and positions are an example.
The finished board in 3D, seen from above: a green board with the ESP32-C3 module's metal can at the right, its antenna standing past the board edge. At the left the USB-C socket, above it the charge diode, the charger chip and two small LEDs. Along the bottom edge the two white sockets for the solar panel and the cell, the protection chip and its MOSFET pair, and at the bottom right corner the small BME280 sensor. Two buttons at the top edge.
The board you will make (50 × 30 mm), made in KiCad 10.
ESP32-C3-WROOM-02 18 x 20 mm, edge pads 1.5 mm apart TP4056 ESOP-8, heat pad underneath 8205A TSSOP-8, pins 0.65 mm apart BME280 LGA-8, 2.5 x 2.5 mm USB-C 16 pins DW01A SOT-23-6 0402 1.0 x 0.5 mm Cell socket JST PH, 2 mm pitch 5 mm. All drawn at the same scale, copper pads from the KiCad 10 footprints.
The parts at true scale. The module's pads run along its edges, where an iron reaches them. The BME280 is the smallest part, 2.5 mm square with its pads underneath: it needs paste and hot air, or the factory.
Coming here first?

This board uses skills taught on the earlier boards. Each one is here, at the part that teaches it:

Words used here, each with a five-minute page:

What the finished board changes, and why
  • The module is the ESP32-C3-WROOM-02. KiCad 10 has no symbol or footprint for the MINI-1; it has both for the WROOM-02, the same chip in an 18 × 20 mm module with its pads on the edges, where an iron can reach them. The GPIO numbers stay the same; its pin numbers differ from the steps below (3V3 is pin 1, EN pin 2, GPIO9 pin 8).
  • 50 × 30 mm. The module is larger, and its antenna stands past the right edge, so no copper is near it.
  • GPIO2 and GPIO8 have 10 kΩ pull-ups (R12, R13). They are strapping pins: Espressif's table needs both high for the USB download that the BOOT button starts. At rest they take no current.
  • The DW01A's supply has 100 Ω and 100 nF (R10, C13), as in its data sheet: the filter keeps the cell's load steps from tripping it.
  • Parts the text names now have references: C9 and C10 (10 µF at the charger's input and BAT pin), C11 (1 µF on EN), R16 (100 Ω to the gate), R14, R15 and C12 (the cell voltage to GPIO1), R11 (the second LED resistor; the table gives R4 twice).
  • TEMP goes to GND, CE to the charger's input. TEMP to GND turns the cell thermistor input off (this cell has none); CE high turns the charger on.
  • SW1 and SW2 are the C&K PTS810 (4.2 × 3.2 mm); the "3 × 6 mm" in the table is another switch. Buy the one whose footprint you placed.

esp32-battery-bom.csv is the full list with part numbers.

This board's budget

Asleep: ESP32-C3 5 µA, ME6211 40 µA, TP4056 2 µA (its data sheet: under 2 µA with no input), DW01A 3 µA, the cell divider 3.7 V / 2 MΩ = 1.9 µA. About 52 µA. The pull-ups take nothing at rest: their pins stay high.

WiFi: 52 + 80 000 × 5 / 600 = 719 µA, 29 days. BLE: 52 + 15 000 × 2 / 600 = 102 µA, 204 days.

The regulator is 40 of the 52 µA. A 3.3 V regulator with about 1 µA for itself gives 63 µA with BLE: 331 days. Check its dropout and its 500 mA rating before you change it.

The 2.4 kΩ row is in the TP4056's table of characteristics: 450 to 550 mA, 500 mA typical.

On the finished board the module is the ESP32-C3-WROOM-02 (KiCad: RF_Module:ESP32-C3-WROOM-02, symbol and footprint). The steps hold with its pin numbers: 3V3 pin 1, EN pin 2, GND pins 9 and 19 (the centre pad), GPIO4 pin 3, GPIO5 pin 4, GPIO8 pin 7, GPIO9 pin 8, GPIO18 pin 13, GPIO19 pin 14, GPIO3 pin 15, GPIO2 pin 16, GPIO1 pin 17. Add 10 kΩ from GPIO2 and from GPIO8 to 3.3 V.

Check it

The finished schematic, in KiCad 10.0.8: ERC 0 errors, 0 warnings. Seven titled boxes, joined by net labels. PWR_FLAG sits on the nets that only passive parts feed: VBUS, the charger input VCHG, GND, BAT-, the DW01A's filtered supply and the sensor rail VSENS.

SDO to GND (address 0x76) gives a warning: the symbol marks SDO bidirectional, since it sends data in SPI mode. The tie is right. This project allows that pair in File > Schematic Setup > Pin Conflicts Map (Bidirectional against Power output: green).

KiCad has no 8205A. The project draws one symbol: drain on pins 1 and 8, S1 on 2 and 3, G1 on 4, G2 on 5, S2 on 6 and 7 (the TSSOP-8 data sheet), with the TSSOP-8_4.4x3mm_P0.65mm footprint.

The whole schematic on one A3 sheet in seven titled boxes joined by net labels: USB-C in (the socket, the two 5.1 k CC resistors, the USB diode); solar panel in (the socket and its diode); the TP4056 charger with its 2.4 k PROG resistor, two LEDs and two capacitors; cell protection (the cell socket, the DW01A with its filter and the 8205A pair); 3.3 V (the ME6211 and its capacitors); the ESP32-C3 module with EN, the two buttons, the strapping pull-ups and the cell divider; and the BME280 behind its P-MOSFET switch, with the I2C pull-ups on the switched rail.
The schematic as a PDF.
The board from above, as its printed outlines show it: the module at the right, its antenna past the edge; the USB-C socket at the left edge with the diode and the charger above it and the charge LEDs in the top left corner; the solar and cell sockets along the bottom edge with the protection parts between and beside them; the regulator in the middle; the two buttons at the top edge; the BME280 at the bottom right corner.
The finished placement. Check: DRC reports no Courtyards overlap.

KiCad's module footprint draws its courtyard 28.5 mm wide over the whole module: the width of the antenna keep-out. On this board the antenna is off the edge, so the finished project draws the courtyard round the module's body (0.25 mm out) and keeps the full width only past the edge. Parts can then sit beside the module's pins: C4 and C7 at pin 1, the BME280 below the module. DRC then reports footprint does not match the library for U1, as expected.

Check it: the finished board
The top copper: wide tracks from the USB socket through the diode to the charger, and from the cell socket to the regulator; the USB pair across the board to the module; ground pour in the space between, none past the right edge.
F.Cu, the top copper
The bottom copper seen from above: an unbroken ground pour under the module and tracks only on the left part of the board.
B.Cu, the bottom copper, seen from above

DRC in KiCad 10.0.8, with schematic parity and every severity: 0 errors, 0 unconnected items, 0 parity issues, and 6 warnings (4 silkscreen clipped by board edge: the outlines of the USB socket and of the module reach past the edge, where the socket's mouth and the antenna stand; the factory trims them; 1 Footprint 'ESP32-C3-WROOM-02' does not match copy in library 'RF_Module': the module's holes made 0.3 mm and its courtyard drawn round the body; 1 Footprint 'SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm_ThermalVias' does not match copy in library 'Package_SO': the charger's heat-pad holes made 0.3 mm).

The USB pair runs from the socket to GPIO18 and GPIO19: D- 48 mm, D+ 43 mm. The 5 mm between them is about 0.03 ns; one bit at 12 Mbit/s lasts 83 ns, so the 0.5 mm matching above is for faster pairs. No signal crosses the back under the module: there it is one sheet of ground, joined to the front by ground vias. Supply tracks are 0.5 mm (the cell, the charger input, the negative line through Q1) and 0.4 mm (3.3 V); 146 vias in all. Beside the pins and round the edges, 85 ground vias join the two pours.

Ours, to compare
  • esp32-battery-gerbers.zip: 9 .gbr files, -NPTH.drl, -PTH.drl and a .gbrjob.
  • esp32-battery-bom-jlcpcb.csv, columns Comment, Designator, Footprint, LCSC. The LCSC column is empty: choose each part on the order page and check its stock.
  • esp32-battery-cpl-jlcpcb.csv, columns Designator, Mid X, Mid Y, Rotation, Layer, from the bottom left corner. U1 is at 42.90, 15.00 mm, rotation -90 (the same as 270 degrees): in the factory's preview its antenna must point past the right edge.
The finished board from below in 3D: the ground pour over most of the back, unbroken under the module, the legs of the two sockets and the text siliconwit.com.
Check it. From below: one sheet of ground under the module, and the socket legs you solder.
Found this useful?

Discussion

    Comments show your name. Be kind, stay on the topic.