Overview
The new Raspberry Pi Zero 2 W was released just yesterday (and I had to have one)!
Today I will be measuring the power consumption of the Raspberry Pi Zero W (v1.1) against that of the new Raspberry Pi Zero 2 W as well as do some simple benchmarking.
Please see my git repo for the scripts and data collected.
TL;DR
Based on my testing performed:
- Raspberry Pi Zero 2 W is almost 6x faster than Zero W.
- Runs about 1.5x warmer than Zero W.
- Consumes about 270mA (1.4 Watts) more than Zero W.
- Idle current is 2mA more than Zero W.
- Switched off current is 1mA more than Zero W.
- Passive cooling ensure the Pi stays cooler for longer and saves about 14 degrees Celsius.
Here is a comparison of the Raspberry Pi Zero W v1.1 (Top) and Raspberry Pi Zero 2 W (Bottom).
My setup
I will be using a brand new unopened Raspberry Pi Zero W (v1.1) and Raspberry Pi Zero 2 W with no active (fan) or passive (heatsink) cooling and no case or GPIO headers.
The Raspberries will be running headless and only be connected to the USB power supply and my local WiFi network.
The latest Raspberry Pi OS Lite (2021-05-07-raspios-buster-armhf-lite) is installed on a SanDisk Ultra A1 (Class 10) 32GB microSD card.
The Pi is held in place (in the air since I don’t know how hot it will get) using the Third Hand tool and I measure the power consumption using a Uni-T UT658B. I did not know before hand how much current the units will consume so I rigged up a USB charger using a double socket face plate that has a 3.2A USB charger built in. NOTE: Don’t try this at home unless you know what you are doing and take safety precautions.
Running Headless
I have installed Raspberry Pi OS Lite onto a microSD card and configured the Pi to run in headless mode (i.e. without a display, keyboard and mouse) and will be using ssh to control the Pi.
Please see my guide on how to setup a Pi to run in headless mode.
Prerequisite software
- Ensure you have Python 3 & pip3 installed.
$ python3 --version
Python 3.7.3
$ sudo apt-get install python3-pip
- Install sysbench that will be used to benchmark the CPU.
$ sudo apt-get install sysbench
- I will be using tmux to manage multiple terminal sessions.
$ sudo apt-get install tmux
- Install vcgencmd that will be used to report temperature, clock speed etc.
$ pip3 install vcgencmd
Taking measurements
- Create a Python script named
measure.py
that will be used to samplevcgencmd
every second and write the results to a file at/home/pi/measurements.txt
#!/usr/bin/env python3
import sys
import os
import time
from vcgencmd import Vcgencmd
def main():
start_time = time.time()
f = open("/home/pi/measurements.txt","a+")
print("Elapsed Time (s),Temperature (°C),Clock Speed (MHz),Voltage Core (V)")
f.write("Elapsed Time (s),Temperature (°C),Clock Speed (MHz),Voltage Core (V)\n")
vc = Vcgencmd()
while True:
clock = int(vc.measure_clock('arm')/1000000)
string = '%.0f,%s,%s,%s\n' % ((time.time() - start_time),vc.measure_temp(),clock,vc.measure$
print(string, end='')
f.write(string)
time.sleep(1)
if __name__ == '__main__':
main()
- You can either run the program using
python3 measure.py
or make the script executable withchmod +x measure.py
. I will be making the script executable. - Verify the program can take measurements. I am using the Raspberry Pi Zero W v1.1 here.
$ ./measure.py
Elapsed Time (s),Temperature (°C),Clock Speed (MHz),Voltage Core (V)
0,34.7,1000,1.4
1,34.2,700,1.2
2,33.6,700,1.2
3,33.6,700,1.2
# Press Ctrl + c to quit the program
# Check the log file was created
$ cat /home/pi/measurements.txt
Elapsed Time (s),Temperature (°C),Clock Speed (MHz),Voltage Core (V)0,34.7,1000,1.4
1,34.2,700,1.2
2,33.6,700,1.2
3,33.6,700,1.2
Measure a long running task
I will be running sysbench for 30 minutes using 4 threads in order to measure the temperature and power consumption.
Raspberry Pi Zero W v1.1
- The Pi has been idle for some time now and the initial power consumption is: 5.04V and 0.08A = 0.4032W.
- Start a new tmux session and start taking measurements.
$ tmux new -s bench
# Inside tmux session
$ ./measure.py
- I let this run for a few seconds and check the power consumption. The current has gone up to 0.12A now.
- Split the tmux pane using
Ctrl + b %
. - Start running sysbench.
$ sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run
- I am running the test for 30 minutes. After about 30 minutes I stopped the sysbench (using
Ctrl + c
). [Reference: time elapsed was about 2095 seconds] - The power consumption is 5.03V and 0.19A = 0.9557W. I observed that this was the value through most of the test. The voltage would fluctuate between 5.04V and 5.03V.
- I let the Pi cool down and idle for about 10 minutes. [Reference: time elapsed was about 2724 seconds]
- The power consumption is: 5.04V and 0.08A = 0.4032W.
- Stopped the
measure.py
program. To switch panes in tmux useCtrl + b o
. - Renamed the log file to
measurements_30min.txt
and copied it over to my Mac.
Raspberry Pi Zero 2 W
- The Pi has been idle for some time now and the initial power consumption is: 5.04V and 0.10A = 0.504W. That is 2mA more than the Zero W.
- Start a new tmux session and start taking measurements.
$ tmux new -s bench
# Inside tmux session
$ ./measure.py
- I let this run for a few seconds and check the power consumption. The current has gone up to 0.12A now (same as Zero W).
- Split the tmux pane using
Ctrl + b %
. - Start running sysbench.
$ sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run
- I am running the test for 30 minutes. After about 30 minutes I stopped the sysbench (using
Ctrl + c
). [Reference: time elapsed was about 1894 seconds] - The power consumption is 5.02V and 0.46A = 2.3092W (261mA more than the Zero W). I observed that this was the value through most of the test. The current would fluctuate between 0.45A and 0.46A (1mA).
- I let the Pi cool down and idle for about 10 minutes. [Reference: time elapsed was about 2518 seconds]
- The power consumption is: 5.04V and 0.10A = 0.504W.
- Stopped the
measure.py
program. To switch panes in tmux useCtrl + b o
. - Renamed the log file to
measurements_30min.txt
and copied it over to my Mac.
Measure basic performance
After letting the Pi cool down and be idle for at least 10 minutes, it is now time to start collecting some stats for running the same sysbench test 5 times.
NOTE: I am trying to run a like-for-like test and thus both Raspberries will be using 4 threads and calculate a 1000 primes per run.
- Create a shell script named
bench.sh
and make it executable withchmod +x bench.sh
. This script will run sysbench 5 times to calculate the first 1000 prime numbers and write the results to individual files like /home/pi/measurements_N.txt.
#!/bin/bash
for i in {1..5}; do
sysbench --test=cpu --cpu-max-prime=1000 --num-threads=4 run > /home/pi/measurements_${i}.txt
done
Raspberry Pi Zero W v1.1
- Start running the
measure.py
program in one pane of tmux and in the other pane start running thebench.sh
script.
- This took about 1 minute to run.
- I copied the log files over to my Mac.
- Shut the Pi down using
sudo shutdown -h now
and after 2 minutes of being off the power consumption is 5.05V and 0.04A = 0.202W.
Raspberry Pi Zero 2 W
- Start running the
measure.py
program in one pane of tmux and in the other pane start running thebench.sh
script.
- This took less than 20 seconds to run.
- I copied the log files over to my Mac.
- Shut the Pi down using
sudo shutdown -h now
and after 2 minutes of being off the power consumption is 5.05V and 0.05A = 0.2525W (1mA more than the Zero W).
Stick a heatsink on
After running the tests and writing the summary, I was interested in seeing how much heat can be passively sinked from the new Raspberry Pi Zero 2 W using the FLIRC Raspberry Pi Zero Case.
I am running the same long running test from before.
$ rm measurements.txt
$ tmux new -s bench
(tmux 1)$ ./measure.py
# Create new pane: Ctrl + b %
(tmux 2)$ sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run
After 30 minutes I stop the sysbench program [Reference: 1850 seconds]. Then waited another 10 minutes for the Pi to cool down before stopping the measure.py program and collect the measurements.txt file.
The image below shows the results between the Zero 2 with no cooling versus the Zero 2 with passive cooling from the FLIRC aluminium case.
The passive cooling makes quite a difference in the fact that it takes longer to reach the maximum temperature (thus staying cooler for longer) and saves about 14 degrees Celsius compared to not having any cooling. I also noticed that the Pi was consuming 1mA less during the testing.
Summary
Temperature and power consumption
The image below shows the results from running sysbench for 30 minutes and then letting the Pi cool down for 10 minutes. Current and power usage for when the Pi is idle or "switched off" is also indicated. The PDF can be found here.
Sysbench best out of 5 runs
The table below shows the total time in seconds it took to calculate a 1000 primes using 4 threads. The best run is highlighted in green.
Here are the results from the two best runs:
Conclusions
The new Raspberry Pi Zero 2 W is almost 6x faster but also runs about 1.5x warmer during the sysbench CPU test. It also consumes about 270mA more during the test which is about 1.4 more watts than the Raspberry Pi Zero W v1.1.
The idle current is about 2mA more and the "switched" off current is about 1mA more than the Raspberry Pi Zero W v1.1