Reliable temperature monitoring

56 59343
Edited by tkaiser at Fri Jan 30, 2015 05:09

EDIT: Before you trust in the CPU's/SoC's temperature values jump directly to the final conclusions later in this thread!

When using RPi-Monitor to do some lightweight monitoring on the Banana Pi I realized that under heavy load both SoC/CPU temperature as well as SSD temps couldn't be read always and were therefore missing on the graphs.

To prevent this and to ensure RPi-Monitor's abilities to collect thermal data in its RRDs (round robin databases) I created a quick&ugly daemon that tries to read out thermal values from SoC/CPU and HDD/SDD and if that fails simply do a fallback to the value queried 5 seconds ago.

Save the following code to /usr/local/bin/ and make it executable (chmod 755 /usr/local/bin/

You have to ensure that the sunxi_dbgreg.ko module is available to read out the registers of the A20 SoC. In case you want to measure the internal thermal sensor of a HDD/SSD connected via SATA you must install the hddtemp package and have to setup hddtemp accordingly

Ensure that /usr/local/bin/ will be called at startup eg. by adding
  1. nohup /usr/local/bin/ &
Copy the Code
to the end of /etc/rc.local. The daemon will update every few seconds the contents of /run/soc-temp and /run/hdd-temp (you might want to adjust these paths to eg. /var/run/ if they don't exist or the target filesystem isn't RAM based)

Then you have to install RPi-Monitor (2.9 or above for the gauge graphs) according to the official simple tutorial (if you do it this way it will be automatically updated afterwards via the package management).

And then it's time to configure RPi-Monitor since RasPi's 'sensors' are somewhat different compared to those available on the Banana Pi (applies to other A20/AXP209 based boards identically, eg. Cubietruck, A20-OLinuXino-Lime2)

1) Create the following files after installation of RPi-Monitor:


2) Fetch, scale it down to 64x64 pixels and store it as /usr/share/rpimonitor/web/img/pmu.png

3) Delete /etc/rpimonitor/data.conf and create a new symlink to /etc/rpimonitor/template/bananian.conf:
  1. cd /etc/rpimonitor && rm data.conf && ln -s /etc/rpimonitor/template/bananian.conf data.conf
Copy the Code
4) restart RPi-Monitor:
  1. service rpimonitor restart
Copy the Code
A few final words:

The stuff outlined above works on Bananian and Igor's great Wheezy image out of the box. No idea what has to be adjusted on other Distros -- feedback welcome.

You can use the aforementioned quick&dirty daemon with any other monitoring/RRD solution since you can read out SoC/disk temperatures from /run/soc-temp and /run/hdd-temp afterwards.

Running such a daemon means creating some load (might increase by 0.1) so as usual: Measuring something itself changes the values you get. You have been warned

The temperature read out from the A20's registers is uncalibrated. Therefore a correction value is necessary (read/understand the comments in this thread). I used "SoCTempAdjustment=1447" in the daemon as suggested and this seems to work on my Banana Pi. On my A20-OLinuXino-Lime2 I had to decrease $SoCTempAdjustment so don't trust the values you get unless you can verify them with a suitable thermometer. As a rough check you can carefully touch the A20 SoC while running --> temperature must decrease immediately by a few degrees but shouldn't be below 38°C. Beware of destroying your Pi when you're touching it while running.

This is what you get:

(10:15-10:20 iozone disk test, 10:39-10:46 "apt-get update/upgrade", 11:17-11:23 both iozone and "stress -c 2 -m 2 -i 2", 11:30-11:36 just "stress -c 2 -m 2 -i 2")



View Rating Log

Edited by tkaiser at Tue Jul 28, 2015 16:15

Here's a new archive ready to be extracted after installation of RPi-Monitor:

It contains:

  1. /etc/rpimonitor/template/cpu_pmu_sunxi.conf
  2. /etc/rpimonitor/template/temperature_axp209.conf
  3. /etc/rpimonitor/template/sunxi_axp209.conf
  4. /etc/rpimonitor/data.conf
  5. /usr/share/rpimonitor/scripts//
  6. /usr/share/rpimonitor/scripts/sunxi_tp_temp
Copy the Code

It contains a simplified configuration that's also suitable for Lamobo R1 when powered through the LiPo battery connector, should work regardless whether one powers the board right (power-in) or wrong (USB OTG) and works partially with mainline kernel (there most of the sysfs entries we're relying on disappeared).

The sunxi_tp_temp binary is also included and is rewritten from scratch: Safe temp file handling, changed location of the intermediate file from /run/ to /tmp/ (since good distros keep /tmp in RAM) and simplified some stuff.

All that's necessary is unpacking the tar archiv from / and ensuring that the is running, eg. through

  1. /usr/share/rpimonitor/scripts/ &
Copy the Code

in /etc/rc.local

Awesome work!

The only thing I've changed is from mW to W, looks nicer.

Thanks for sharing.

really like but please make a .deb file to install with easy steps, I install Psensor from lubuntu software center I think this work nice but only have 1 sensor

Edited by tkaiser at 2014-10-24 02:25

Just a small follow-up regarding enclosures (good ones and bad ones).

On the Banana Pi everything that gets hot is on the bottom side of the PCB. So what happens if you put the Banana Pi horizontally into an enclosure without airflow? It get's unnecessarily hot.

Below the simulation of an enclosure with wrong thermal design: I put the Banana Pi with heatsinks applied to CPU/SoC, PMU and DRAM flat into a small box. No airflow possible so even when the Banana is completely idle the temperatures rise to 47/37/29 °C (CPU/PMU/SSD) and the heatsinks are nearly useless:

At 8:43 I openend the box and put the BananaPi into a vertical position to allow optimal airflow (otherwise 'passive cooling' is active fooling yourself): The temperatures drop down to 41/28/24 °C (CPU/PMU/SSD -- the thermal sensor in the SSD is normally an indicator for ambient temperature when being outside of an enclosure)

9:03 back in the box and 9:09 I started 2 times "stress -t300 -c 2 -m 2 -i 2 -d 2": Temperatures are rising and rising up to 55/49/36 °C (CPU/PMU/SSD).

At 9:33 I opened the box, put the Banana Pi into vertical position (minor convection effect) and at 9:35 I ran the stress test again (2 x 5 minutes). As you can see temperatures do not increase permanently but instead don't exceed 50/40/33 °C (CPU/PMU/SSD). You might see higher values for the PMU when the BananaPi has to power stuff via USB/GPIO. But if no heat dissipation is possible in an enclosure temperatures will continually increase, CPU/PMU will dynamically clock down to prevent overheating when the system gets busy or it will become unstable/crash if you didn't set correct limits (cpufreq stuff)

BTW: The aforementioned stuff applies even more to a situation without heatsinks. Ensuring enough airflow and using thermal effects (hot air always ascends) helps with keeping the stuff cool or operating the Banana Pi at higher speeds (the aforementioned 'stress' tests happened at 1.2 GHz).

Edited by deenbee at 2014-10-24 20:34

How to run rpimonitord ? I have installed from all.deb file downloaded from github .deb packages but can't open

I use Lubuntu

hi tkaiser:
your config file doesn't work in lubuntu, I installed rpimonitor,but after i used your tutorial, the page bacame like this20141102092026.jpg)
do you have any suggestions?

deenbee replied at Fri Oct 24, 2014 16:33
How to run rpimonitord ? I have installed from all.deb file downloaded from github .deb packages but ...

use this
it works

Edited by tkaiser at Sun Nov 2, 2014 03:44
mouse replied at Sat Nov 1, 2014 19:16
do you have any suggestions?

Sorry, no idea what got messed up

I bundled all the config stuff together and outlined the necessary steps here again ... amp;page=1#pid38582 again (and tested it myself twice since I'm currently playing with another Banana Pi and an A20-OLinuXino-Lime2). Worked as expected -- at least for me (using Bananian and Igor's image)

I followed your how-to last night and it worked perfectly thanks

Edited by T.S. at Sun Nov 2, 2014 12:25

One other way to monitor HDD temperature is using hddtemp directly. This is my config:
  2. dynamic.21.source=/usr/sbin/hddtemp -n /dev/sda1
  3. dynamic.21.regexp=(.*)
  4. dynamic.21.postprocess=
  5. dynamic.21.rrd=GAUGE
Copy the Code
It returns 0 if in idle state or sleeping. That makes it easy to see how long and often the drive is going to sleep.


You have to log in before you can reply Login | Sign Up

Points Rules