2

I have been looking on the internet and found nothing for getting readings of the temperatures of the CPU on the Raspberry Pi.

Im using Raspbian (Wheezy).

Any help would be great for everyone!

Alex
  • 233
  • 1
  • 3
  • 10
  • asked and answered multiple times: http://raspberrypi.stackexchange.com/a/8690/7274 – lenik Aug 20 '13 at 06:55
  • i didnt want to do jQuery or graphs. – Alex Aug 20 '13 at 07:37
  • 2
    reading /sys/class/thermal_zone0/temp does not require no graphs nor jquery – lenik Aug 20 '13 at 08:03
  • but the 2 answers in the question you linked talked about using jQuery or output with graphs. and python. – Alex Aug 20 '13 at 08:04
  • 1
    please, read the question, the quote starting from "# read the temperature and convert..." and the next 2 lines. – lenik Aug 20 '13 at 08:06
  • notice how mine doesnt say "convert". mine is nothing like the one you linked. i just wanted a simple solution. not a html output or a png file of a graph.. the answer i checked is the correct answer. or is the correct output method "CLI". – Alex Aug 20 '13 at 08:10
  • If you read the bash example carefully enough, the "conversion" is necessary if you want the temperature in degrees, notice your excepted answer performs this "conversion" as well, it just is not labelled as such (the change is merely to put the decimal point in the right place, a raw reading returns thousands, e.g. 47615 means 47.615 °C) – PiBorg Aug 20 '13 at 08:36
  • remember not everyone knows how to read bash script. – Alex Aug 20 '13 at 08:48
  • lenik told you which lines to look at, you could have just tried them rather than announcing notice how mine doesnt say "convert". mine is nothing like the one you linked., you make it sound like lenik is wrong and gurcanozturk is right, both examples basically do the same thing. – PiBorg Aug 20 '13 at 12:32
  • This doesnt work. the answer i checked works first time. TEMPERATURE=cat /sys/class/thermal/thermal_zone0/temp TEMPERATURE=echo -n ${TEMPERATURE:0:2}; echo -n .; echo -n ${TEMPERATURE:2} – Alex Aug 20 '13 at 23:12

1 Answers1

15

I found an answer at http://www.raspberrypi.org forums. You can read the CPU temp via bash script. Save this script as getTemp.sh in /usr/local/bin folder and give execute permission with chmod +x /usr/local/bin/getTemp.sh command. Then run it, you will get temp values.

#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

echo CPU temp"="$cpuTemp1"."$cpuTempM"'C"
echo GPU $(/opt/vc/bin/vcgencmd measure_temp)
gurcanozturk
  • 3,748
  • 1
  • 19
  • 17