Running a Pi Zero on Battery: Power Options, Runtime and Saving Tips

The Pi Zero family uses less power than any other Linux-capable Raspberry Pi, which is why it appears in so many portable projects: wildlife cameras, handheld gadgets, field data loggers and wearable devices. Running from a battery, however, raises questions a wall adapter never does. How long will it last? How do you avoid SD card corruption when the battery runs flat? Which settings actually reduce consumption?

This tutorial covers the practical answers: the common battery arrangements, how to measure current and calculate runtime properly, the config.txt and system settings that cut power, and a safe shutdown button plus a low-battery shutdown script.

Ways to Power a Zero from a Battery

The Zero needs a regulated 5 V at its micro USB PWR IN port or on the 5 V header pins 2 and 4. A single lithium cell provides between about 3.0 V and 4.2 V, so in almost every design a boost converter raises it to 5 V. Feeding a raw battery straight into the 5 V pins is not safe.

OptionProsCons
USB power bankSimplest; charging and protection built inSome banks switch off when current is low, cutting power to an idle Zero
Single LiPo / 18650 cell with charger-boost moduleCompact; charge while running; many modules give a low-battery signalChoose a module with protection; check its maximum output current
AA or AAA cells with a 5 V boost converterEasily replaced cellsBulky for the energy stored; voltage sags under load
Solar panel, charger and batteryRuns indefinitely outdoors if sized correctlyNeeds careful sizing for cloudy days

Measure, Then Calculate Runtime

Published consumption figures vary with OS version, Wi-Fi activity and attached hardware, so measure your own setup. Put an inexpensive USB power meter between the supply and the Zero, then note the current while idle and while your program does its real work. Battery capacity is quoted at the cell voltage, so convert to energy before dividing.

Battery energy (Wh) = capacity (Ah) x nominal cell voltage (V)
Usable energy (Wh)  = battery energy x boost efficiency
Load power (W)      = 5 V x measured current (A)
Runtime (h)         = usable energy / load power

Example with values you measured yourself:
  2000 mAh cell, 3.7 V nominal          -> 2.0 x 3.7 = 7.4 Wh
  boost converter efficiency 85 %        -> 7.4 x 0.85 = 6.29 Wh
  meter shows 0.20 A at 5 V              -> 1.0 W
  runtime                                -> 6.29 / 1.0 = about 6.3 h

A common mistake is dividing 2000 mAh by 200 mA and expecting 10 hours. That ignores the voltage conversion from 3.7 V to 5 V and the converter losses, and overestimates runtime considerably. Also derate the result for an ageing cell and for cold weather.

Settings That Reduce Power Use

Disable every block of hardware your project does not use. Add the lines below to /boot/firmware/config.txt and reboot, then measure again so you know what each change was worth on your board.

Power-saving additions to /boot/firmware/config.txt (keep only what suits your project)
# Turn off the activity LED (Pi Zero family: the LED is active-low)
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on

# Disable Bluetooth if unused
dtoverlay=disable-bt

# Disable Wi-Fi if the device logs locally and never needs a network
# dtoverlay=disable-wifi

# Change the existing dtparam=audio=on line to off if no audio is used
dtparam=audio=off

# Do not probe for a camera if none is fitted
camera_auto_detect=0
  • Fewer cores on the Zero 2 W: adding maxcpus=1 to the single line in /boot/firmware/cmdline.txt limits Linux to one core, lowering peak current for light workloads.
  • Stop unused services: for example sudo systemctl disable --now bluetooth and any service you installed for testing.
  • Avoid busy loops: use event callbacks, time.sleep() and systemd timers so the CPU stays idle most of the time.
  • Group network activity: collect readings locally and send them in batches rather than keeping a connection constantly busy.
  • Remove USB devices: hubs and adapters on the OTG port draw power even when idle.
  • Wi-Fi power management: check with iw wlan0 get power_save. Turning it on saves power but can delay incoming connections.

Linux on the Zero cannot enter a deep sleep that draws microamps, the way a microcontroller can. For devices that only need to work for a minute every hour, a much bigger saving comes from cutting power completely with an external timer board, such as one based on the TPL5110, that switches the Zero on and cuts the supply when it receives a done signal. The gpio-poweroff overlay can drive a GPIO pin high once Linux has fully halted, which is a convenient source for that signal.

Safe Shutdown Button and Low-Battery Shutdown

Cutting power while Linux is writing can corrupt the SD card. A built-in overlay turns a button on GPIO3 into a shutdown button, and the same button wakes the board from the halted state. Add dtoverlay=gpio-shutdown to config.txt and connect a push button between physical pin 5 (GPIO3) and pin 6 (GND). GPIO3 is also the I2C clock line, so if you use I2C, choose another pin with dtoverlay=gpio-shutdown,gpio_pin=21; only GPIO3 can wake the board.

Many charger-boost modules have a low-battery output that goes low when the cell is nearly empty. The script below, run as root from a systemd service, shuts the Zero down cleanly when that happens. Make sure the signal never exceeds 3.3 V before connecting it to a GPIO.

lowbatt_shutdown.py: shut down cleanly when the charger's low-battery pin goes low
#!/usr/bin/env python3
"""Watch a low-battery signal and shut down safely. Run as root via systemd."""
import subprocess
from signal import pause

from gpiozero import DigitalInputDevice

# GPIO26 (physical pin 37). pull_up=True: the pin reads 'active' when the
# open-drain low-battery output pulls it to GND. bounce_time ignores glitches.
low_batt = DigitalInputDevice(26, pull_up=True, bounce_time=2)

def shutdown():
    print('Low battery detected, shutting down')
    subprocess.run(['shutdown', '-h', 'now'])

low_batt.when_activated = shutdown
if low_batt.is_active:  # battery already low at boot
    shutdown()
pause()

Common Problems

  • Random reboots on battery: voltage dips under load. Run vcgencmd get_throttled; bit 0 set means under-voltage now, bit 16 means it happened since boot. Use a stronger boost module and short, thick cables.
  • Power bank turns off after a while: the load is below its auto-off threshold. Use a bank with an always-on mode or a dedicated LiPo module.
  • Corrupted SD card after the battery died: add the low-battery shutdown, and consider the read-only filesystem described in this series.

Summary

Battery-powering a Pi Zero comes down to a proper 5 V boost supply, runtime calculated from measured current with voltage conversion and losses included, disabling unused hardware in config.txt, and always shutting down cleanly. For very long life with occasional work, switch the Zero off completely between jobs with an external timer.