ESP32 & ESP8266 Connectivity · Intermediate · Low power

ESP32 Deep-Sleep Battery Node

A node that wakes, reports and sleeps, and can run for weeks on one cell.

Firmware status: Generated from this project's own pin map and compiled with arduino-cli for esp32:esp32:esp32 before publication; bench validation on your hardware is still required.

Board: ESP32 DevKit (ESP32-WROOM-32, 30 or 38 pin) · ESP32 dual core @ 240 MHz · 3.3 V logic · build for esp32:esp32:esp32.

What you will build

An ESP32 that samples, connects only for the length of the report, then sleeps — with the time asleep printed and the battery voltage monitored.

Components

  • ESP32 board
  • Analog sensor
  • 18650 cell and holder (or a 3.7 V LiPo)
  • 10 kΩ + 10 kΩ divider for the battery sense
  • USB cable

Pin map for this build

Sketch constantPinWhat it is
PIN_SENSE34Sensor — analog output, 3.3 V maximum
PIN_STATUS_LED4Status LED — with 220 Ω series resistor

Tools

  • USB programming cable
  • Multimeter
  • Current-limited bench supply (for anything that switches a load)
  • Small screwdriver and wire cutters

Build sequence

  1. Build the 1:2 divider across the cell and take it to a pin that can read it.
  2. Set WAKE_SECONDS, flash, and read the boot counter and voltage in the log.
  3. Watch the awake time — it should be a few seconds, not a minute; that number is the battery cost.
  4. Confirm the counter increments on each wake, which proves the RTC memory survives sleep.

Test and expected result

The board wakes on schedule, the boot counter survives every sleep, and the awake time is a small fraction of the cycle.

Acceptance checks

timer wake works, counter persists, awake time under five seconds, voltage reported

Safety and limits

A lithium cell needs a protection board and the right charger. Measure the divider on the bench before connecting a cell to a 3.3 V pin.

Hardware scope

Timer wake, RTC-retained counter, battery divider, radio on only during the report.

Connection diagram

Connection diagram for ESP32 Deep-Sleep Battery Node

Download the connection diagram (SVG)

Download the Arduino sketch (E15_esp32_deep_sleep_battery_node.ino)

Guide source: the sketch on this page was generated from the pin map above and compiled for esp32:esp32:esp32 before publication.

Related projects

Back to all project guides · Study the course