วันพุธที่ 26 มิถุนายน พ.ศ. 2556

Reading CPU Temperature of Raspberry Pi

Standard



Reading CPU Temperature of Raspberry Pi in file
/sys/class/thermal/thermal_zone0/temp
this file show in milli celsius (m˚C) unit,  divide 1000 convert to ˚C
for example
44388 ÷ 1000 = 44.388 ˚C

Script for caculate in celsius unit

#!/bin/bash

temp=`cat /sys/class/thermal/thermal_zone0/temp`
real_temp=`bc <<< "scale = 3; ($temp/1000)"`
echo "CPU Temperature $real_temp ˚C"

Note : please install bc first.
           #apt-get install bc

0 ความคิดเห็น:

แสดงความคิดเห็น