Search by Tags

Temperature Sensor (Linux)

 

Article updated at 24 Nov 2020
Compare with Revision




Subscribe for this article updates

Introduction

The SoCs often have one or more internal temperature sensors. From Linux userspace, it is possible to read the temperature values on /sys.

To better understand how things work on NXP i.MX SoCs, one can read section 2.7 - Thermal of the i.MX Reference Manual

NXP/Freescale i.MX 6 Based Modules

The i.MX 6 provides a temperature reading of the SoC's internal temperature plus the board temperature is available via ADC/touch chip albeit with much worse accuracy. The output is in millidegrees Celsius aka 1000ths of degrees Celsius. Therefore it must be divided by 1000 to obtain regular degrees.

root@colibri-imx6:~# cat /sys/devices/virtual/thermal/thermal_zone0/temp
54325
root@colibri-imx6:~# cat /sys/bus/iio/devices/iio\:device0/in_temp8_raw
35318

NXP/Freescale i.MX 6ULL and i.MX 7 based modules

Both i.MX 6ULL and i.MX 7 based modules have an integrated sensor for monitoring the temperature of the CPU. The output is in millidegrees Celsius aka 1000ths of degrees Celsius. Therefore it must be divided by 1000 to obtain regular degrees.

root@colibri-imx6ull:~# cat /sys/devices/virtual/thermal/thermal_zone0/temp 
57140

NXP/Freescale i.MX 8/8X Based Modules

On i.MX 8/8X, power management and temperature monitoring are entirely handled by the SCFW.

The internal temperature sensors of i.MX 8QuadMax/8QuadPlus and i.MX 8QuadXPlus/8DualX are split into zones, accessible through /sys/devices/virtual/thermal/thermal_zoneX:

apalis-imx8-06543292:~$ ls /sys/devices/virtual/thermal/
cooling_device0  cooling_device1  cooling_device2  cooling_device3  cooling_device4  cooling_device5  cooling_device6  cooling_device7  cooling_device8  thermal_zone0  thermal_zone1  thermal_zone2  thermal_zone3  thermal_zone4  thermal_zone5

You can read the temperature from a thermal zone as follows:

apalis-imx8-06543292:~$ cat /sys/devices/virtual/thermal/thermal_zone0/temp 
33800

The zones are described as follows:

  • zone 0 represents the temperature of the 4 A53 CPU cores.
  • zone 1 represents the temperature of the 2 A72 CPU cores.
  • zone 2 represents the temperature from one of the GPUs.
  • zone 3 represents the temperature from the other GPU.
  • zone 4 represents the temperature for the PMIC (Power management integrated circuit).
  • zone 5 just defaults to 70 degree Celsius as nothing is assigned there.

NVIDIA Tegra 2 and 3 based modules

The temperature sensor is able to report the PCB's temperature as temp1 and the NVIDIA Tegra T20/T30 chip's internal temperature as temp2. The output is provided in millidegrees Celsius aka 1000ths of degrees Celsius (Colibri T20 V1.x BSPs provided it in degrees Celsius). Therefore it must be divided by 1000 to obtain regular degrees.

root@colibri_t20:~# cat /sys/bus/i2c/devices/4-004c/temp1_input
29625
root@colibri_t20:~# cat /sys/bus/i2c/devices/4-004c/temp2_input
31125
root@colibri-t30:~# cat /sys/bus/i2c/devices/4-004c/temp1_input
52468
root@colibri-t30:~# cat /sys/bus/i2c/devices/4-004c/temp2_input
45625

NVIDIA Tegra K1 based modules

The Apalis TK1 module comes with 2 temperature sensors, one which measures the temperature of the CPU die and another on the Apalis PCB. To read these temperatures, the hwmon subsystem is consulted. The output is provided in millidegrees Celsius aka 1000ths of degrees Celsius. Therefore it must be divided by 1000 to obtain regular degrees.

watch cat /sys/class/hwmon/hwmon?/temp1_input

Every 2.0s: cat /sys/class/hwmon/hwmon0/temp1_input /sys/class/hwmon/hwmon1/temp1_input /sys/class/hwmon/hwmo...  apalis-tk1: Thu Mar  8 13:45:59 2018

47500
49500
45000
46500
35000
46000

To verify where temperatures are being measured

root@apalis-tk1:~# cat /sys/class/hwmon/hwmon?/name
CPU-therm
GPU-therm
MEM-therm
PLL-therm
Tboard_tegra
Tdiode_tegra

The last two refer to the sensors previously mentioned.

NXP/Freescale Vybrid based modules

The Vybrid's internal temperature sensor is connected internally to its ADC module's analogue input channel, the readout of temperature is given by in_temp_input. The output is in millidegrees Celsius aka 1000ths of degrees Celsius. Therefore it must be divided by 1000 to obtain regular degrees.

root@colibri-vf:~# cat /sys/bus/iio/devices/iio:device1/in_temp_input
40760