How To Find Board Temperature Sensor Readings

Linux temperatures at exposed to userspace through the thermal class. You will find virtual files called temp within the sysfs thermal class directories:

cat /sys/class/thermal/thermal_zone0/temp

Some boards and chips will have multiple temperature sensors enumerated in multiple directories under /sys/class/thermal/ eg thermal_zone1, thermal_zone2, etc.

1 Like


When runing

cat /sys/class/thermal/thermal_zone0/temp


sudo cat /sys/class/thermal/thermal_zone0/temp

it returns:

cat: /sys/class/thermal/thermal_zone0/temp: No such file or directory

on a fresh install of 2022-09-22-raspbian-bullseye-arm64-lite+aml-s905x-cc.0.img on a LePotato

What could be wrong?

Thank you.

This was a kernel bug. It’s been fixed.

When 'cat’ing these files, I get 5-digit numbers such as 58523 or 61144. How to convert this to C degrees?

Take the number and divide by 1000.

You can also use a quick bash script like this one if you need the results on a regular basis like I do.
This one relies on the standard bc command to perform the degC to degF conversion for you.


# check_cpu_temp
# Bill deWindt 10-08-2020
# script to query the CPU temp from /sys and display
# it in degC and degF.
if [ ! -f /sys/class/thermal/thermal_zone0/temp ]; 
        echo "ERROR: Thermal data not present."

if [[ $(which bc | wc -c) -ne 0 ]];
        CPUOUT=`cat /sys/class/thermal/thermal_zone0/temp`
        CPUC=`cut -c1-2 <<< $CPUOUT`.`cut -c3-5 <<< $CPUOUT`
        # formula: Temp F=(9/5)*Temp C + 32
        CPUF=$(echo "scale=2;((9/5) * $CPUC) + 32" | bc)
        echo "Current CPU Temp:"
        echo 'C:'$CPUC '     F:'$CPUF
        echo "ERROR: bc not found in PATH"

I like to add this to .bashrc:

alias cputemp=“watch cat /sys/class/thermal/thermal_zone0/temp”

There is also a panel widget in both Mate and xfce I sometimes use.

On the ALL-H3-CC board running the latest Raspbian Lite ( 2023-05-03-raspbian-bullseye-arm64-lite+all-h3-cc-h5.img.xz) the /sys/class/thermal/thermal_zone0 directory does not exist.

/sys/class/thermal contains the following:

ls /sys/class/thermal  -la
total 0
drwxr-xr-x  2 root root 0 Sep 14 13:51 .
drwxr-xr-x 89 root root 0 Sep 14 13:51 ..
lrwxrwxrwx  1 root root 0 Sep 14 13:51 cooling_device0 -> ../../devices/virtual/thermal/cooling_device0

Which points to a virtual device but does not seem to contain thermal data.

How can I get the CPU temperature(s) on this board?


This has been fixed in the latest bootloader. Please use the libretech-flash-tool to update your existing system.

sudo ./ bl-flash all-h3-cc-h5 mmc1 force #assume MicroSD card