← All posts

Build log · Low power

The ESP32 number that decides your battery life

6 Sep 20263 min read

Every ESP32 power spec you'll read is true, and also somewhat useless, because it's measured on a dev board plugged into USB.

The number that actually decides whether your battery product lasts three days or three months is the sleep current. And that's the number nobody notices during development, because the mains supply doesn't care about microamps.

A 30,000× difference

Active Wi-Fi TX can spike past 300 mA. Deep sleep on the same chip can sit around 10 µA. That's a 30,000× difference, and it means one forgotten wlan.active(False) before a light sleep or a wait loop in the MicroPython code can quietly cost you weeks of runtime.

machine.deepsleep() switches the radio off for you. The trap is everywhere else: lightsleep(), time.sleep(), or the device hanging around with Wi-Fi up while it waits on an MQTT reply or retries a connection.

The vineyard soil sensor

I ran the numbers on a soil sensor I recently built for a vineyard. It wakes every 15 minutes, publishes over MQTT, and sleeps the rest of the time. That one line took it from an estimated 3-week battery life to over 6 months!

That means a smaller solar module, with headroom left over for low insolation during winter. Win = win!

# End of each wake cycle: radio off as soon as the data is sent
client.disconnect()              # close MQTT cleanly
wlan.disconnect()
wlan.active(False)             # radio off before any waiting
machine.deepsleep(15 * 60 * 1000)   # 15 minutes

The fix

The fix isn't complicated:

#EmbeddedSystems#ESP32#LowPowerDesign#MicroPython