{"id":492,"date":"2021-10-30T10:42:41","date_gmt":"2021-10-30T10:42:41","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=492"},"modified":"2022-04-11T20:22:59","modified_gmt":"2022-04-11T20:22:59","slug":"raspberry-pi-zero-2-w-temperature-and-power-consumption","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/electronics\/raspberry-pi-zero-2-w-temperature-and-power-consumption\/","title":{"rendered":"Raspberry Pi Zero 2 W temperature and power consumption"},"content":{"rendered":"\n
The new Raspberry Pi Zero 2 W<\/a> was released just yesterday (and I had to have one)!<\/p>\n 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.<\/p>\n Please see my git repo<\/a> for the scripts and data collected.<\/p>\n Based on my testing performed:<\/p>\n Here is a comparison of the Raspberry Pi Zero W v1.1 (Top) and Raspberry Pi Zero 2 W (Bottom).<\/p>\n <\/p>\n <\/p>\n 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.<\/p>\n The Raspberries will be running headless and only be connected to the USB power supply and my local WiFi network.<\/p>\n The latest Raspberry Pi OS Lite<\/a> (2021-05-07-raspios-buster-armhf-lite) is installed on a SanDisk Ultra A1 (Class 10) 32GB microSD card.<\/p>\n 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<\/strong> unless you know what you are doing and take safety precautions.<\/p>\n <\/p>\n 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.<\/p>\n Please see my guide<\/a> on how to setup a Pi to run in headless mode.<\/p>\n I will be running sysbench for 30 minutes using 4 threads in order to measure the temperature and power consumption.<\/p>\n <\/p>\n <\/p>\n <\/p>\n <\/p>\n <\/p>\n <\/p>\n 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.<\/p>\n NOTE:<\/strong> 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.<\/p>\n <\/p>\n <\/p>\n <\/p>\n <\/p>\n 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<\/a>.<\/p>\n <\/p>\n <\/p>\n I am running the same long running test from before.<\/p>\n 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.<\/p>\n 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.<\/p>\n <\/p>\n 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.<\/p>\n 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<\/a>.<\/p>\n <\/p>\n 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.<\/p>\n <\/p>\n Here are the results from the two best runs:<\/p>\n <\/p>\n 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.<\/p>\n The idle current is about 2mA more and the "switched" off current is about 1mA more than the Raspberry Pi Zero W v1.1<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" […]<\/p>\nTL;DR<\/h3>\n
\n
My setup<\/h2>\n
Running Headless<\/h2>\n
Prerequisite software<\/h2>\n
\n
$ python3 --version\nPython 3.7.3\n\n$ sudo apt-get install python3-pip\n<\/code><\/pre>\n
\n
$ sudo apt-get install sysbench\n<\/code><\/pre>\n
\n
$ sudo apt-get install tmux\n<\/code><\/pre>\n
\n
$ pip3 install vcgencmd\n<\/code><\/pre>\n
Taking measurements<\/h2>\n
\n
measure.py<\/code> that will be used to sample
vcgencmd<\/code> every second and write the results to a file at
\/home\/pi\/measurements.txt<\/code><\/li>\n<\/ul>\n
#!\/usr\/bin\/env python3\n\nimport sys\nimport os\nimport time\nfrom vcgencmd import Vcgencmd\n\ndef main():\n start_time = time.time()\n f = open("\/home\/pi\/measurements.txt","a+")\n print("Elapsed Time (s),Temperature (\u00b0C),Clock Speed (MHz),Voltage Core (V)")\n f.write("Elapsed Time (s),Temperature (\u00b0C),Clock Speed (MHz),Voltage Core (V)\\n")\n vc = Vcgencmd()\n while True:\n clock = int(vc.measure_clock('arm')\/1000000)\n string = '%.0f,%s,%s,%s\\n' % ((time.time() - start_time),vc.measure_temp(),clock,vc.measure$\n print(string, end='')\n f.write(string)\n time.sleep(1)\n\nif __name__ == '__main__':\n main()\n<\/code><\/pre>\n
\n
python3 measure.py<\/code> or make the script executable with
chmod +x measure.py<\/code>. I will be making the script executable.<\/li>\n
$ .\/measure.py\nElapsed Time (s),Temperature (\u00b0C),Clock Speed (MHz),Voltage Core (V)\n0,34.7,1000,1.4\n1,34.2,700,1.2\n2,33.6,700,1.2\n3,33.6,700,1.2\n# Press Ctrl + c to quit the program\n\n# Check the log file was created\n$ cat \/home\/pi\/measurements.txt\nElapsed Time (s),Temperature (\u00b0C),Clock Speed (MHz),Voltage Core (V)0,34.7,1000,1.4\n1,34.2,700,1.2\n2,33.6,700,1.2\n3,33.6,700,1.2\n<\/code><\/pre>\n
Measure a long running task<\/h2>\n
Raspberry Pi Zero W v1.1<\/h3>\n
\n
\n
$ tmux new -s bench\n\n# Inside tmux session\n$ .\/measure.py\n<\/code><\/pre>\n
\n
Ctrl + b %<\/code>.<\/li>\n
$ sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run\n<\/code><\/pre>\n
\n
Ctrl + c<\/code>). [Reference: time elapsed was about 2095 seconds]<\/li>\n
\n
measure.py<\/code> program. To switch panes in tmux use
Ctrl + b o<\/code>.<\/li>\n
measurements_30min.txt<\/code> and copied it over to my Mac.<\/li>\n<\/ul>\n
Raspberry Pi Zero 2 W<\/h3>\n
\n
\n
$ tmux new -s bench\n\n# Inside tmux session\n$ .\/measure.py\n<\/code><\/pre>\n
\n
Ctrl + b %<\/code>.<\/li>\n
$ sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run\n<\/code><\/pre>\n
\n
Ctrl + c<\/code>). [Reference: time elapsed was about 1894 seconds]<\/li>\n
\n
measure.py<\/code> program. To switch panes in tmux use
Ctrl + b o<\/code>.<\/li>\n
measurements_30min.txt<\/code> and copied it over to my Mac.<\/li>\n<\/ul>\n
Measure basic performance<\/h2>\n
\n
bench.sh<\/code> and make it executable with
chmod +x bench.sh<\/code>. 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.<\/li>\n<\/ul>\n
#!\/bin\/bash\n\nfor i in {1..5}; do\n sysbench --test=cpu --cpu-max-prime=1000 --num-threads=4 run > \/home\/pi\/measurements_${i}.txt\ndone\n<\/code><\/pre>\n
Raspberry Pi Zero W v1.1<\/h3>\n
\n
measure.py<\/code> program in one pane of tmux and in the other pane start running the
bench.sh<\/code> script.<\/li>\n<\/ul>\n
\n
sudo shutdown -h now<\/code> and after 2 minutes of being off the power consumption is 5.05V and 0.04A = 0.202W.<\/li>\n<\/ul>\n
Raspberry Pi Zero 2 W<\/h3>\n
\n
measure.py<\/code> program in one pane of tmux and in the other pane start running the
bench.sh<\/code> script.<\/li>\n<\/ul>\n
\n
sudo shutdown -h now<\/code> and after 2 minutes of being off the power consumption is 5.05V and 0.05A = 0.2525W (1mA more than the Zero W).<\/li>\n<\/ul>\n
Stick a heatsink on<\/h2>\n
$ rm measurements.txt\n$ tmux new -s bench\n(tmux 1)$ .\/measure.py\n# Create new pane: Ctrl + b %\n(tmux 2)$ sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run\n<\/code><\/pre>\n
Summary<\/h2>\n
Temperature and power consumption<\/h3>\n
Sysbench best out of 5 runs<\/h3>\n
Conclusions<\/h2>\n