Test ESP32 Deep Sleep for a Battery Sensor
By admin

An ESP32 sensor that only reports occasionally can save energy by sleeping between readings. Start on the bench and measure the complete wake-and-sample cycle. Development boards include extra circuits, so the current you see at the power input can be higher than a bare-chip figure in a datasheet.
Design the wake cycle
A timer is a practical first wake source. On each wake, initialize the sensor, record a measurement, finish any networking, set the next wake time and enter deep sleep. Deep sleep powers down most of the chip and the program starts through its boot path when it wakes. Use persistent storage or appropriately retained memory for the values you need across cycles. Check the wake cause if you later add a button or another external trigger.
When a manual sleep cycle powers down the radio, the device needs to reconnect on the next wake. Keep a time budget for the connection and the upload. Decide in advance what to do if the service is unavailable, so a temporary outage does not leave a battery-powered device awake indefinitely.
Measure the complete prototype
- Use a safe power source and a meter or power monitor suitable for the expected peak current.
- Record the duration and current of startup, sensor sampling and radio transmission.
- Measure the sleep current with the full sensor circuit attached. Check which peripherals remain powered.
- Repeat the test when the access point is unavailable and check how quickly the firmware returns to sleep.
As an example, a board drawing 120 mA for three seconds and 0.3 mA for the remaining 57 seconds averages about 6.3 mA over a minute. Those figures illustrate the calculation. Use the actual average in each phase of your measured cycle, especially where the radio produces short peaks.
Find the best next change
If a regulator, indicator LED or USB interface dominates the sleep reading, a board designed for battery use may offer a larger improvement than tuning clock settings. If waking and connecting take the most energy, investigate a longer reporting interval or batch measurements when the project allows. Repeat the same measurement after each change. Compare the energy used over an entire cycle and allow for the battery’s actual usable capacity, regulator losses and the environment where the sensor will operate.

