Monitoring Raspberry Pi temperatures

Cool Running

Retrofitting a Raspberry Pi with a cooling element does not cost much; however, does the Rasp Pi really need one?

The noise accompanying classic PCs originates from the continuously whirring and humming fans moving hot air generated by the CPU out of the computer housing. In contrast, the Raspberry Pi does not need a cooling system. In fact, you will not find any place for a fan or passive cooling element on the Rasp Pi board. In this article, I use monitoring software to determine if and when your Rasp Pi needs help keeping cool.

Rasp Pi SoC

With standard settings, the ARM processor for the Broadcom BCM2835 system on a chip (SoC) found on classic Raspberry Pis works at a constant 700MHz, even though manufacturer guidelines permit a clock frequency of up to 1GHz [1]. This means the Rasp Pi has roughly the computing power of a 300MHz fast Pentium II from 1997. The integrated VideoCore IV GPU makes it possible to run graphical interfaces like the LXDE environment at an adequate speed.

For some time now, the official position of the Raspberry Pi Foundation has been to permit overclocking and overvolting [2]. The developers have approved raising the voltage and the clock rate to 1GHz as long as the core temperature in the CPU of the BCM2835 SoC does not exceed 85°C (185°F).

The clock rate for Turbo mode (Figure 1), which is activated by going to the Rasp Pi configuration toolkit, increases only as needed. As a consequence, the CPU remains cool when the computer is idle, even in Turbo mode.

Figure 1: The CPU of the Rasp Pi can reach a clock rate of up to 1GHz under heavy load. The operating system will also increase the supply voltage.

Typically, the Raspberry Pi works fine without a cooling function, because even after hours of handling heavy loads of data, the CPU does not reach the maximum permitted temperature of 85°C. Nonetheless, many online dealers offer passive cooling elements made of aluminum or even copper that can be glued on to the Rasp Pi.

Munin for the Raspberry Pi

Before accessorizing a Pi with a cooling element, you need to have the means for recording temperatures and system loads, such as Munin [3] monitoring software. Typically, Munin collects output from the open source Lm_sensors application [4] to measure temperatures and voltage in the system. However, Munin won't find any sensors on a Rasp Pi running with Raspbian "wheezy." Instead, the desired information is found in the /sys/class/thermal/thermal_zone0/temp file or by inspecting output from the vcgencmd [5] command (Listing 1). The Munin plugin Pisense [6] allows you to integrate the information accessed by vcgencmd into Munin.

Listing 1


$ cat /sys/class/thermal/thermal_zone0/temp
$ vcgencmd measure_temp
$ vcgencmd measure_volts
$ vcgencmd measure_clock arm

To install Munin on the Raspberry Pi, you need to load the service together with a web server from the package sources and then link the data generated by Munin to the Internet directory of the web server:

$ sudo apt-get install munin munin-node lighttpd
$ sudo ln -s /var/cache/munin/www/ /var/www/munin

"Lighty" is a good choice for a slim and resource-efficient web server that can work well with the none too powerful Rasp Pi [7]. If you already have a Munin server on the Internet, then all you need to do is install the Munin node and configure the instance on the main computer so that it retrieves data from the Rasp Pi node. In this project, I keep everything on the Rasp Pi.

After installing Munin, you need to load the Pisense module (Listing 2) from GitHub; then, you should assign the module to the root user and make it executable. Typically though, the user will not have the necessary rights to read temperatures. Open a new file for editing and add two lines that tell Munin to execute Pisense with root rights:

$ nano /etc/munin/plugin-conf.d/pisense
user root

Press Ctrl+O to write the lines to the file, press Enter to accept the file name, and press Ctrl+X to exit Nano.

Listing 2

Loading Pisense Module

$ cd /usr/share/munin/plugins
$ sudo wget
$ sudo chown root:root pisense_
$ sudo chmod 755 pisense_

The final step is to activate Pisense. This works much the same way that it does when you activate an Apache web server. You should link the respective module from /usr/share/munin/plugins to /etc/munin/plugins (Listing 3). Pisense is a wildcard module, as is evident by the underscore at the end of the module name. The suffixes clock, volt, and temp instruct Munin to read the clock rate, voltage, and temperature as detected by the CPU. The last line in Listing 3 restarts the service so that it is recognized by Munin.

Listing 3

Activating the Pisense Module

$ sudo ln -s /usr/share/munin/plugins/pisense_ /etc/munin/plugins/pisense_temp
$ sudo ln -s /usr/share/munin/plugins/pisense_ /etc/munin/plugins/pisense_clock
$ sudo ln -s /usr/share/munin/plugins/pisense_ /etc/munin/plugins/pisense_volt
$ sudo service munin-node restart

Munin creates web reports in the Sensors category of http://localhost/munin or http://<Rasp Pi-IP>/munin. These reports comprise charts that contain the progression of voltage, clock rates, and core temperatures in the Rasp Pi CPU. Entering munin-run in the terminal window displays the latest data, so you don't have to wait for the Munin cron job (Listing 4). In this way, you can catch configuration errors right away.

Listing 4

Running Munin

$ sudo munin-run pisense_temp
temp.value 32.6
$ sudo munin-run pisense_clock
clockarm.value 1000000000
clockcore.value 500000000
$ sudo munin-run pisense_volt
voltcore.value 1.350
voltsdram_c.value 1.200
voltsdram_i.value 1.200
voltsdram_p.value 1.225

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content