Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.

com/raspberry-pi/raspberry-pi-zero-2-battery/

We've detected you might be speaking a different


Français Change Language
language. Do you want to change to:

Monitor and Control your Raspberry Pi: Free for up to 5 Pis!


 
 
 

Raspberry Pi Zero 2 battery runtimes, optimization, and


setup
By Xuyun Zeng | January 20, 2022

How to run a Raspberry Pi off a battery


The easiest way for a plug-and-play experience is to run it off a power bank made for recharging phones. They’re the easiest because everything works;
but they are also the least customizable.

If you want a more customizable solution, consider getting the PowerBoost 1000 Basic which will allow you to step up voltages from 1.8V which means
you can use 2x NiMH batteries or one lithium battery to power your Raspberry Pi Zero 2 W.

Examples of battery-powered applications with the Pi Zero 2


Using the Raspberry Pi Zero 2 on a battery makes sense for applications such as,

• Retro gaming emulation: Retroflag GPi case or a custom build with a 7” screen
• IoT/automation devices that are far from a power outlet (weather sensor, pollution detector, animal cameras,
plant watering devices, pet feeders)

1 of 7 09/11/2023 20:11
Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.com/raspberry-pi/raspberry-pi-zero-2-battery/

• ePaper displays: digital name tags, stock tickers, to-do lists

How to log uptime

In order to log your uptime, you should install the package .

Open up a Terminal and run:

sudo apt-get install uptimed

After installation, you need to start and run the service by running:

systemctl enable uptimed

then

systemctl start uptimed

Since we’re trying to establish how long of a battery runtime we can expect, it’s important to ensure uptimed’s config files allow much shorter logging
intervals than what’s default.

By default, uptimed only writes to the logs every hour, and will not record any records shorter than one hour.

In order to change this, you need to change the config file. By default

In Terminal, run:

sudo nano /etc/uptimed.conf

Change the following variables:

By default, both variables are set to one hour (either 3600 seconds or 1h). By setting them to 60 seconds, we can log the battery’s runtime down to the
minute.

Idle Runtime

2 of 7 09/11/2023 20:11
Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.com/raspberry-pi/raspberry-pi-zero-2-battery/

I ran a 5000mA power bank on the Raspberry Pi Zero 2W with no attachments and on the Raspberry Pi OS (2021-10-31). Everything is default.

This represents the best-case battery life that you would get out of a default Raspberry Pi Zero 2 W.

Stress Runtime
In reality, you’re likely to have certain attachments to it such as HDMI or something on the GPIO. So, the next test will be a better way to find out what’s the
worst-case scenario.

In order to run a stress test, I ran the command

stress-ng –cpu 4 –cpu-method fft

The –cpu-method fft and -cpu 4 were used based on a conclusion on the Raspberry Pi forum, which found that it drew one of the higher loads

I immediately noticed the CPU utilization shooting up to 100% upon executing this command.

Optimizations
You can further reduce power consumption by turning off various components of the Raspberry Pi Zero 2 W.

Here are the power savings you can enable:

Turn off LED: 5mA1

Turn off WiFi: 11mA-187mA2

Use legacy drivers + disable HDMI: 21mA + 17mA 2

Turn off LED

3 of 7 09/11/2023 20:11
Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.com/raspberry-pi/raspberry-pi-zero-2-battery/

Before

You can save 5mA by turning off the LED. Here’s how.

If you just want to run it once, you need to run this command in terminal:

echo none | sudo tee /sys/class/leds/led0/trigger

However, if you want the LED to be permanently turned off at reboot, then open up your terminal and type in:

sudo crontab -e

Once you’re in the file, scroll all the way to the bottom and type in these lines:

@reboot echo none | sudo tee /sys/class/leds/led0/trigger &

After your next and subsequent reboots, your Pi Zero 2 W’s green LED will stay lit until it boots the OS up, whereby it’ll be turned off.

Turn off WiFi


By the same token, you can permanently turn off WiFi by running the command

sudo rfkill block wifi

To make this command run on reboot, open up your terminal and type in

sudo crontab -e

Scroll to the bottom and type in this line

@reboot sudo rfkill block wifi &

Once you reboot, you should see that your WiFi is disabled at startup.

4 of 7 09/11/2023 20:11
Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.com/raspberry-pi/raspberry-pi-zero-2-battery/

After

Use legacy drivers + disable HDMI


If you have built a battery-powered device, chances are much higher that you won’t be running a monitor.

Or perhaps you plan to run your Raspberry Pi Zero 2 W in headless mode. That’s also another reason to disable HDMI.

The contradictory thing here is that I had to enable WiFi, hence incurring power drain, in order to disable HDMI so that I could control my Pi Zero 2 via SSH.
So, choose your battles.

Enable legacy GL drivers


Before you disable HDMI, you will need to use the legacy graphics driver.

Open up a terminal and run:

sudo raspi-config

Then, go to

Now that this is done, you can go ahead and disable your HDMI by running the command:

sudo nano /etc/rc.local

Just above the line “exit 0”, type in

5 of 7 09/11/2023 20:11
Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.com/raspberry-pi/raspberry-pi-zero-2-battery/

To re-enable HDMI, just delete this line. I did it via SSH.

Disable cores
While all of the tips above reduce idle power consumption, you can also limit the maximum power consumption by disabling cores.

In order to do this, you’d want to open a terminal and type in:

sudo nano /boot/cmdline.txt

Type in in the first line and save the file by pressing CTRL + X and saving by pressing Y.

Then, reboot.

Upon reboot, you can check if your modification worked by running in terminal.

If you see “Off-line CPU(s) list: 1-3”, then it worked and you’re running on one core.

If you want to learn more about what you can do with your Raspberry Pi Zero 2, check out this article.

tweet share share share

← Raspberry Pi Zero 2 W WiFi chipset, speeds & monitor mode 10 curious Raspberry Pi Pico facts →

Leave a Comment
Comment

Name (required)

6 of 7 09/11/2023 20:11
Raspberry Pi Zero 2 battery runtimes, optimization, and setup | PiCockpit | Monitor... https://picockpit.com/raspberry-pi/raspberry-pi-zero-2-battery/

Email (will not be published) (required)

Website

Save my name, email, and website in this browser for the next time I comment.

Submit Comment

Stay up to date with the PiCockpit Newsletter


PiCockpit sends a weekly newsletter packed with:
Tips to Enhance your Raspberry Pi Experience
New Products & Price Updates
Fun & Exciting Projects
Trivia

Enter your email below �

Email

Your email will be used to send you the PiCockpit Newsletter only. You can unsubscribe anytime. For more details, review our privacy policy and our mailer service's
privacy policy.

SUBSCRIBE

Check out our other articles!


PiCockpit Help & FAQ PiCockpit Terms of Service Impressum (Legal Notice) Datenschutzerklärung (Privacy Policy) Change privacy settings

Privacy settings history Revoke consents

© 2023 pi3g GmbH & Co. KG:


PiCockpit | Monitor and Control your Raspberry Pi: Free for up to 5 Pis!

The Best Raspberry Pi Projects of October Paragon Project: Raspberry Pi Fractal Art
2023 By Adam | October 30, 2023
By Adam | November 2, 2023

7 of 7 09/11/2023 20:11

You might also like