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 constant | Pin | What it is |
|---|---|---|
PIN_SENSE | 34 | Sensor — analog output, 3.3 V maximum |
PIN_STATUS_LED | 4 | Status 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
- Build the 1:2 divider across the cell and take it to a pin that can read it.
- Set WAKE_SECONDS, flash, and read the boot counter and voltage in the log.
- Watch the awake time — it should be a few seconds, not a minute; that number is the battery cost.
- 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
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
- ESP32 Captive Portal Wi-Fi Manager — Boot the ESP32 with no credentials and configure its network from a phone, with the portal saved to flash.
- ESP8266 Config Portal — The same idea on the cheapest board that can do it: an ESP8266 that configures itself from a browser.
- ESP8266 Sensor Portal Logger — A battery-minded sensor node you configure in the field, with the reading shown on its own setup page.