[solved] CPU temperature readings wrong at cold temperatures

There is a problem with Nanopi Neo temperature readings at colder temperatures. (Currently in freezer at -18 deg. C :slight_smile:

root@DietPi:~# cat /sys/class/thermal/thermal_zone0/temp
-9341

Should this be -9.3 deg. C? That would be about right.


BUT …

root@DietPi:~# cpu

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | -5343’c | Who put me in the freezer! :open_mouth: That is one cold freezer!!!
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 1008 MHz 120 MHz 1008 MHz
CPU1 | 1008 MHz 120 MHz 1008 MHz
CPU2 | 1008 MHz 120 MHz 1008 MHz
CPU3 | 1008 MHz 120 MHz 1008 MHz

Gordon Williams

You actually put this in a freezer? lmao, fair play :smiley:

We run some math on the value to reduce to 1/2 digits. We only check for positive values in the calculations (eg: > 1000), i’ll change that to absolute (bash doesn’t support this, so another check for <= -1000) value.

Hi Gordon,

Please try this updated script with support for negative values:

wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/dietpi/dietpi-cpuinfo -O /DietPi/dietpi/dietpi-cpuinfo
cpu

What about temperatures between -0.999 and +0.999 deg.? Would these be calculated wrong?

I will try a test.

Back soon.

Gordon

Yup, problem with those temps.

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | 1’c | Who put me in the freezer!
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 480 MHz 120 MHz 1008 MHz
CPU1 | 480 MHz 120 MHz 1008 MHz
CPU2 | 480 MHz 120 MHz 1008 MHz
CPU3 | 1008 MHz 120 MHz 1008 MHz

root@DietPi:~# cpu

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | Warning: 716’c | Reducing the life of your device. :rofl: Ouch that is HOT!
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 1008 MHz 120 MHz 1008 MHz
CPU1 | 1008 MHz 120 MHz 1008 MHz
CPU2 | 1008 MHz 120 MHz 1008 MHz
CPU3 | 1008 MHz 120 MHz 1008 MHz

root@DietPi:~# cpu

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | Warning: 594’c | Reducing the life of your device.
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 1008 MHz 120 MHz 1008 MHz
CPU1 | 1008 MHz 120 MHz 1008 MHz
CPU2 | 1008 MHz 120 MHz 1008 MHz
CPU3 | 1008 MHz 120 MHz 1008 MHz

root@DietPi:~# cpu

… and then …

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | -739’c | Who put me in the freezer! :rofl: Running HOT and COLD!
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 624 MHz 120 MHz 1008 MHz
CPU1 | 624 MHz 120 MHz 1008 MHz
CPU2 | 624 MHz 120 MHz 1008 MHz
CPU3 | 624 MHz 120 MHz 1008 MHz


root@DietPi:~# cpu

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | -133’c | Who put me in the freezer!
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 1008 MHz 120 MHz 1008 MHz
CPU1 | 1008 MHz 120 MHz 1008 MHz
CPU2 | 1008 MHz 120 MHz 1008 MHz
CPU3 | 1008 MHz 120 MHz 1008 MHz

root@DietPi:~# cpu

─────────────────────────────────────────────────────
DietPi CPU Info
Use dietpi-config to change CPU / performance options
─────────────────────────────────────────────────────
Architecture | armv7l
Temp | -2’c | Who put me in the freezer!
Governor | ondemand
Throttle up | 50% CPU usage

Current Freq Min Freq Max Freq
CPU0 | 1008 MHz 120 MHz 1008 MHz
CPU1 | 1008 MHz 120 MHz 1008 MHz
CPU2 | 1008 MHz 120 MHz 1008 MHz
CPU3 | 1008 MHz 120 MHz 1008 MHz

Gordon Williams

Thanks Gordon,

Strange. Not unless the CPU thermal sensor is giving invalid values for below <10’c?

If you get another chance, lets check the raw values of a freshly frozen (unpowered) NanoPi Neo (cant believe I just said that lol). Power on, then run this command to monitor temp every 2 seconds. If it breaks the device, let me know and i’ll send you a Neo 2:

watch cat /sys/class/thermal/thermal_zone0/temp

If the values come back valid, i’ll be able to re-check the sourcecode and run further tests (valid being 4/5 digits long, with end result temp = value / 1000).

No, there is no problem with the sensor. Just your math. :open_mouth:

As I noted above the problem is -1 deg< temp< + 1 deg.

for example:

+.5 deg the sensor shows 500

You test for numbers between < -1000 and > +1000. Because 500 sensor reading doesn’t meet the test, it doesn’t get divided by 1000 like it should.

You need to refine your algorithm to decide what is a 2 digit temperature and a 4 digit temperature.

You could do this on a cpu basis.

A hack would be to test between -100 and 100. Therefore the errors would only occur between -0.09 and +0.09 degrees.
Gordon Williams

Hi Gordon,

Yep spot on, not been doing much β€œreal” programming lately (compiles, software additions, forum spammers), so my math is a little β€œoff” lol :slight_smile:

A hack would be to test between -100 and 100 Therefore the errors would only occur between -0.09 and +0.09 degrees.

Good solution, although relies on CPU temps not exceeding 100’c (looks at XU4). Another option is to provide two possible values from a 2/3 digit result?

Another solution is to find and pre-define which boards/results are 4/5 digits (NanoPi Neo), instead of 2 (pine). We could do that one pretty easy with $HW_MODEL index’s, we just need to find which boards (including NR_ 4.x images that may be a switch of 3.x) have those figures.

All because the lady (Man) loves Cadburys milk tray (Freezers) :smiley: lol

Gordon,

SBC in a freezer? made my day :slight_smile::
https://twitter.com/DietPi_/status/852588259779784704

You’ve forgotten but we’ve discussed the freezer before :rofl:

But that was for rPi. Now trying out smaller NanoPi to test clock stability.


We could do that one pretty easy with $HW_MODEL index’s

That would be the preferred way.

Thanks,
Gordon

Hi Gordon,

Ah yes, we did :slight_smile:

I’ve made a ticket for this, see if we can make those changes:
https://github.com/Fourdee/DietPi/issues/884

Gordon,

script updated, ready for testing:

wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/dietpi/dietpi-cpuinfo -O /DietPi/dietpi/dietpi-cpuinfo
cpu

Looks good. Temperature drops through 0 deg smoothly now.

Thanks,
Gordon

Excellent, thanks Gordon :slight_smile:

ahm, i dont know about anyone else, but for me, my Orange Pi, after the 149 update shows me 0 degrees O_O
and i do cat of that temperature variable and it’s not 0, (i did it , because i dont have the orange pi anywhere near me to check manually)
cputemp.png

ahm, i dont know about anyone else, but for me, my Orange Pi, after the 149 update shows me 0 degrees O_O

Thanks for letting us know, we are working on a solution:
https://github.com/Fourdee/DietPi/issues/909

Think we fixed it, any chance you can update script and test for us?

wget > https://github.com/Fourdee/DietPi/raw/testing/dietpi/dietpi-cpuinfo > -O /DietPi/dietpi/dietpi-cpuinfo
cpu

Just tried it again with your revised code and it still works for Nanopi Neo. Linux DietPi 4.10.3-sun8i

Gordon Williams

Thanks Gordon :slight_smile:

It is Mostly Issue at cold temperatures. Here is the guide about maximum average & normal temperatures.
https://getintopc.app/what-are-the-maximum-average-normal-cpu-temperatures/