1

So recently I was interested in CPU and GPU temperatures and did some work displaying the temperatures in real time on a page and also recording the temperatures on a graph using rrdtool (which is very awesome). I've also been logging the temperatures for a while now.

enter image description here

Pop quiz: Can you see where I added the active cooling?

But then I got to wondering if the one temperature affected the other. Makes sense. So I did a (very brief) Google search to find out which chip was the CPU and which the GPU.

enter image description here

Ok, so, wait, they're on the same chip.... So why Am I getting (slightly) different temperatures? enter image description here

And are there really 2 separate temperature sensors on the one chip?

Here's an "close up" of the last 15 minutes (5 minute heartbeat) enter image description here

  • Your graph is on a reeeeeally looooong timescale. Would it be possible to choose one of the sections where you've noticed a significant difference and show a graph of, say, 10 minutes worth of activity, or low enough that single data points can be identified? It's hard to say just from the graph what the specific differences are between the two data sets. – goobering Jan 28 '16 at 15:13
  • What commands you are using to read the temperature? As fas as I am aware there is only one sensor. – joan Jan 28 '16 at 15:16
  • I'll build up shorter time graph tomorrow, but the commands are: cat /sys/class/thermal/thermal_zone0/temp & /opt/vc/bin/vcgencmd measure_temp – Jim Jan 28 '16 at 15:30
  • 1
    I believe they are two different interfaces to the same sensor. – joan Jan 28 '16 at 15:57
  • I've added that last graph as requested @goobering – Jim Jan 29 '16 at 7:24
2

I just took 5000 samples as follows.

time for ((i=0;i<5000;i++)); \
   do \
      cat /sys/class/thermal/thermal_zone0/temp; \
      /opt/vc/bin/vcgencmd measure_temp; \
   done >temp

The 5000 samples were collected in about 150 seconds, or about 33 per second.

real    2m26.588s
user    0m29.090s
sys     0m47.510s

thermal zone

thermal zone


vcgencmd

vcgencmd


They appear to be the same sensor.


As a second experiment I used this script suggested by Jim

#!/bin/bash

T1="cat /sys/class/thermal/thermal_zone0/temp"
T2="/opt/vc/bin/vcgencmd measure_temp"

R1a=$($T1)
R2a=$($T2)
R1b=$($T1)
R2b=$($T2)
R1c=$($T1)
R2c=$($T2)
R1d=$($T1)
R2d=$($T2)

echo ${R1a:0:2}.${R1a:2:1} ${R2a:5:4} ${R1b:0:2}.${R1b:2:1} ${R2b:5:4} ${R1c:0:2}.${R1c:2:1} ${R2c:5:4} ${R1d:0:2}.${R1d:2:1} ${R2d:5:4}

It was run with

for ((i=0;i<100;i++)); do ./1.sh; sleep 0.1; done

A fragment of output

37.9 39.0 39.0 39.0 38.4 39.0 38.4 38.5
38.4 39.0 38.4 39.0 39.0 39.0 39.0 38.5
39.0 39.0 38.4 39.0 39.0 39.0 39.0 39.0
38.4 39.0 39.0 38.5 39.0 39.0 39.0 39.0
38.4 38.5 39.0 38.5 39.0 39.0 39.0 39.0
38.4 38.5 38.4 38.5 39.0 39.0 39.0 39.0

Each line has readings from command 1 and command 2 repeated four times, e.g.

C1 C2 C1 C2 C1 C2 C1 C2

You should be able to see how variable successive readings may be.

  • Nicely done! There are a few outliers here and there, but I'd have thought that could be put down to timing issues rather than physically distinct sensors on the SOC. The 49.8/9 reading in the upper right corner would appear to strongly support only one sensor. – goobering Jan 28 '16 at 17:49
  • 1
    Actually that's not an outlier. I use gnuplot and that's where it puts its key. You can get consecutive readings which differ by a degree even at 33 per second. – joan Jan 28 '16 at 17:57
  • Thanks for the input. Try this though: Create a new file (I called mine 1.sh) with the following content: #!/bin/bash TEMPERATURE="cat /sys/class/thermal/thermal_zone0/temp" TEMPERATURE="echo -n ${TEMPERATURE:0:2};echo -n .; echo ${TEMPERATURE:2:1}" TEMPERATURE2="/opt/vc/bin/vcgencmd measure_temp" TEMPERATURE2="echo -n ${TEMPERATURE2:5:4}" echo $TEMPERATURE echo $TEMPERATURE2 Then chmodit to 755 to make it executable. Then run: watch -n.01 1.sh to run the script every .1 seconds (sorry, tried to format it nicely, but i couldn't get the line-breaks working) – Jim Jan 29 '16 at 7:35
  • @Jim Shall do, may be this afternoon though. – joan Jan 29 '16 at 9:08
  • 1
    @Jim The /sys interface appears to call the vc (video core) mailbox interface to read the same temperature. Using the video core measure_temp function is the most direct. If you look at consecutive readings you can see a lot of jitter on occasion. – joan Feb 1 '16 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.