# \[solved\] CPU temperature readings wrong at cold temperatures

**URL:** <https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184>\
**Category:** Troubleshooting\
**Created:** [12 April 2017 16:26 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184 "2017-04-12T16:26:08Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [12 April 2017 16:26 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/1 "2017-04-12T16:26:08Z")

</div>

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

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! 😮 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

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [13 April 2017 14:43 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/2 "2017-04-13T14:43:02Z")

</div>

> [@Gord\_W](#):
>
> root@DietPi:~# cat /sys/class/thermal/thermal\_zone0/temp  
> -9341
> 
> Should this be -9.3 deg. C? That would be about right.  
>   
>   
> Gordon Williams

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

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.

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [13 April 2017 14:45 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/3 "2017-04-13T14:45:12Z")

</div>

Hi Gordon,

Please try this updated script with support for negative values:

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

```

---

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [13 April 2017 15:10 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/4 "2017-04-13T15:10:05Z")

</div>

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

I will try a test.

Back soon.

Gordon

---

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [13 April 2017 15:15 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/5 "2017-04-13T15:15:22Z")

</div>

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. 🤣 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! 🤣 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

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [13 April 2017 16:38 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/6 "2017-04-13T16:38:21Z")

</div>

> [@Gord\_W](#):
>
> Temp | Warning: 716’c

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:

```plaintext
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).

---

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [13 April 2017 17:32 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/7 "2017-04-13T17:32:26Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [13 April 2017 18:15 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/8 "2017-04-13T18:15:17Z")

</div>

> [@Gord\_W](#):
>
> Just your math.  
> 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.

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 🙂

> 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) 😃 lol_

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [13 April 2017 18:25 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/9 "2017-04-13T18:25:43Z")

</div>

Gordon,

SBC in a freezer? made my day 🙂:  
[https://twitter.com/DietPi\_/status/852588259779784704](https://twitter.com/DietPi_/status/852588259779784704)

---

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [13 April 2017 18:49 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/10 "2017-04-13T18:49:26Z")

</div>

You’ve forgotten but we’ve discussed the freezer before 🤣

> [@ntpd setup](https://dietpi.com/forum/t/ntpd-setup/188/21):
>
> Just to wrap things up. These are the measured drifts of the clock at different temperatures. Even without the unit connected to the internet and ntp running the clock is still very stable over a wide temperature range, much to my surprise. Summary of results ntpdate -q time.nrc.ca used to measure offset change over hours with linear line fit rpi in cheap plastic case Location Ambient T CPU temp Drift ppm Room 20 45 -42.288 Fridge 3 30 -44.256 Freezer -20 …

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

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [14 April 2017 10:27 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/11 "2017-04-14T10:27:51Z")

</div>

> [@Gord\_W](#):
>
> You’ve forgotten but we’ve discussed the freezer before 🤣  
> [ntpd setup - #21 by Gord\_W](https://dietpi.com/forum/t/ntpd-setup/188/21)  
> 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 🙂

I’ve made a ticket for this, see if we can make those changes:

> <https://github.com/MichaIng/DietPi/issues/884>
>
> \> http://dietpi.com/phpbb/viewtopic.php?f=11&t=1677#p6790

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [16 April 2017 11:30 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/12 "2017-04-16T11:30:49Z")

</div>

Gordon,

script updated, ready for testing:

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

```

---

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [19 April 2017 19:00 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/13 "2017-04-19T19:00:49Z")

</div>

Looks good. Temperature drops through 0 deg smoothly now.

Thanks,  
Gordon

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [20 April 2017 10:17 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/14 "2017-04-20T10:17:36Z")

</div>

> [@Gord\_W](#):
>
> Looks good. Temperature drops through 0 deg smoothly now.
> 
> Thanks,  
> Gordon

Excellent, thanks Gordon 🙂

---

<div class="post-metadata">

**Author:** ![syl3nt](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@syl3nt](https://dietpi.com/forum/u/syl3nt)\
**Post date:** [29 April 2017 22:28 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/15 "2017-04-29T22:28:58Z")

</div>

> [@Fourdee](#):
>
> > [@Gord\_W](#):
> >
> > Looks good. Temperature drops through 0 deg smoothly now.
> > 
> > Thanks,  
> > Gordon
> 
> Excellent, thanks Gordon 🙂

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](https://dietpi.com/forum/uploads/default/original/1X/336b26ba7eb28159f89ddf8032fa47f342d9739c.png)

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [30 April 2017 17:29 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/16 "2017-04-30T17:29:26Z")

</div>

> 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](https://github.com/Fourdee/DietPi/issues/909)

---

<div class="post-metadata">

**Author:** ![Gord\_W](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@Gord\_W](https://dietpi.com/forum/u/Gord_W)\
**Post date:** [30 April 2017 17:48 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/17 "2017-04-30T17:48:56Z")

</div>

> 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](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

---

<div class="post-metadata">

**Author:** ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)\
**Post date:** [1 May 2017 11:25 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/18 "2017-05-01T11:25:00Z")

</div>

> [@Gord\_W](#):
>
> 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 🙂

---

<div class="post-metadata">

**Author:** ![untitleone2020](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/u/8797f3/32.png) [@untitleone2020](https://dietpi.com/forum/u/untitleone2020)\
**Post date:** [15 April 2020 07:18 UTC](https://dietpi.com/forum/t/solved-cpu-temperature-readings-wrong-at-cold-temperatures/1184/19 "2020-04-15T07:18:59Z")

</div>

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/](https://getintopc.app/what-are-the-maximum-average-normal-cpu-temperatures/)
