Reliable temperature monitoring

56 24119
Edited by tkaiser at Tue Nov 25, 2014 04:48
FPeter replied at Mon Nov 24, 2014 16:38
do You have any other idea?

Yes, translation into Klingon is still missing!

No, everything's perfekt. Maybe I will take your code as a template and strip it down to a more user friendly output (containing the word "approximately" since relying on these values is worthless) and parametrisation. Thank you

tkaiser replied at Tue Nov 25, 2014 04:48
Yes, translation into Klingon is still missing!  

No, everything's perfekt. Maybe I will take y ...

feel free to modify it!

Nice! Thanks for posting this sunxi_tp_temp package!

Could you please explain what the 1447 parameter is though?

My system is currently at 51.5 degrees. What is the maximum safe temperature?
  1. root@appliance:~/utils/sunxi_tp_temp# ./sunxi_tp_temp  1447
  2. 51.5
  3. root@appliance:~/utils/sunxi_tp_temp#
Copy the Code

Edited by tkaiser at Thu Feb 5, 2015 05:47

You should better read out the PMU's temperature. In your case with the BPi-R1 the AXP209 is on the lower part of the PCB. In case you've put it into the standard enclosure and you create higher loads and power up other peripherals from the BPi-R1 it might get too hot.

The basics regarding thermal stuff should be outlined here: ... 2&fromuid=33332

Really appreciate the trouble you have gone to with all of this, great information and guide.

Rpi-Monitor for Arch Linux

  • Install rpimonitor from AUR
  • 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

  • Arch Linux uses systemd, so we don't have syslog but journal. An easy (and dirty!) way to read the SOC/CPU temp value is from dmesg, so edit line 29 from file /usr/share/rpimonitor/scripts/
    1. nano +29 /usr/share/rpimonitor/scripts/
    Copy the Code
    and change tail /var/log/syslog to dmesg:
    1. HexVal=$(dmesg | awk -F" 0x" '/ 0x/ {print $2}' | tail -n1 )
    Copy the Code

  • Add a simple systemd service to handle the script:
    1. nano /etc/systemd/system/bpi-temp.service
    Copy the Code
    1. [Unit]
    2. Description=Temperature measurement service for Banana boards

    3. [Service]
    4. ExecStart=/usr/share/rpimonitor/scripts/

    5. [Install]
    Copy the Code

  • It's also needed to set the cpu governor and frequency just like this script. The best way to do this on archlinux, is by using systemd temporary files. For the cpu governor and frequency add:
    1. nano /etc/tmpfiles.d/cpugovernor.conf
    Copy the Code
    1. w /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - - - - ondemand
    2. w /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq - - - - 600000
    3. w /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq - - - - 1008000
    4. w /sys/devices/system/cpu/cpufreq/ondemand/up_threshold - - - - 25
    5. w /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor - - - - 10
    6. w /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy - - - - 1
    Copy the Code
    The same goes for the green led etc (of course you can put all your configs in one file):
    1. nano /etc/tmpfiles.d/greenled.conf
    Copy the Code
    1. w /sys/class/leds/green\:ph24\:led1/trigger - - - - none
    Copy the Code
    To adjust the network parameters for LAN usage, please read Sysctl
  • [Optional] Load sunxi-dbgreg module on boot (the 'right' way). Module is loaded from script, but here's another way to do it. Create a config file under /etc/modules-load.d/sunxi-dbgreg.conf and add the module we need:
    1. nano /etc/modules-load.d/sunxi-dbgreg.conf
    Copy the Code
    1. #Load sunxi-dbgreg needed by rpimonitor
    2. sunxi-dbgreg
    Copy the Code

  • Our final step is to start all the services (systemd service for rpimonitor gives me a "400 Bad request", so i started it from command line):
    1. /usr/bin/rpimonitord &
    2. systemctl enable bpi-temp.service
    Copy the Code

  • Enjoy your Rpi Monitor on http://your_banana_local_ip:8888/

Things todo:
- Check why rpimonitor doesn't work from systemd service,
- Check HDD/SSD with sata (don't have a cable yet),
- On my system "Memory" and "/boot partition" show NaN values,
- You tell me!

Edited by tkaiser at Tue Jul 28, 2015 12:33

A better approach is to use FPeter's sunxi_tp_temp command to read out the SoC's temperature (no need for the sunxi-dbgreg module that might disappear rather sooner than later from kernels used on Banana).
The other 'problem' with my script is that it writes constantly to two files below /var/run (so if you have a really bad SD card you might fear wear-out -- I won't but many people do).

I created a few hours ago some fixes. You can download them here: bpi-monitor-fix.tgz

The archive contains the following, but you might only need the first 4 files (the aforementioned sunxi_tp_temp binary), two scripts to read out SoC's and /dev/sda's temp (with sanity checks and sane return values so your graphs won't get 'damaged' by wrong return values) and an adjusted temperature_bananian.conf that doesn't rely on the temporary files creates but on the output of the 2 included scripts:

  1. ​/usr/local/bin/sunxi_tp_temp
  2. /usr/local/bin/disktemp
  3. /usr/local/bin/soctemp
  4. /etc/rpimonitor/template/temperature_bananian.conf
  5. /var/lib/rpimonitor/stat/hddtemp.rrd
  6. /var/lib/rpimonitor/stat/soctemp.rrd
Copy the Code

The attempt using is due to RPi-monitor not being able to read out SoC and disk temperature under heavy load (since the timeslots for external commands to be called are too small. So I decided to grab the temperature values inside a loop in the daemon script and let RPi-Monitor simply read out the files where the values have been writte in before). If you do not plan to use RPi-Monitor on a totally utilised machine (eg. running "stress -t 900 -c 2 -m 2 -i 2 -d2") the other approach relying on these 2 scripts would be better.

Currently I'm thinking about reworking the whole thing since the name is misleading (bananian -- this should work on every A20/AXP209 device) and the methodology (daemon and temp files on SD card)

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

Great! Could you please push the changes to Rpi Monitor github? The developer added your previous configs (version 2.10 - Add BananaPi configuration files (found in BananaPi forum)), so it would be nice to have these files upstream.

I'll also create a wiki page for archlinux and rpimonitor, as it seems i can't edit my post (and most of these are now obsolete).

Edited by tkaiser at Wed Jul 29, 2015 02:13
pikitsan replied at Wed Jul 29, 2015 00:35
Great! Could you please push the changes to Rpi Monitor github? The developer added your previous co ...

I will forward the stuff to Xavier but I want to collect some feedback from testers (and especially you running the thing on Arch Linux which uses systemd -- maybe it's necessary to also include some sort of readme since RPi-Monitor has been designed for Raspbian and so everything's great as long as the basis is a Debian/SysV system)

BTW: I once again simplified stuff and integrated all A20/AXP209 stuff in one single config (axp209_cpu_pmu_temp.conf) so it's now also possible to graph consumption together with temperatures without creating too much RRD databases. The archive now contains:
  1. /etc/rpimonitor/data.conf
  2. /etc/rpimonitor/template/sunxi_axp209.conf
  3. /etc/rpimonitor/template/axp209_cpu_pmu_temp.conf
  4. /usr/share/rpimonitor/scripts/sunxi_tp_temp
  5. /usr/share/rpimonitor/scripts/
Copy the Code
And to get thermal values it's necessary to let /usr/share/rpimonitor/scripts/ running as daemon (eg. started from /etc/rc.local with " &"). (MD5: cc34cf154de1b6ead3b76971ea1b39ea)

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

Points Rules