Check out the new project site for Light Attack (IR Paintball) http://www.project.lightattack.com.au

Saturday, January 22, 2011

Pandaboard: How to read the temperature sensor

From the IRC chat logs, user mru provided userland code to read the internal bandgap temperature sensor in the OMAP4 used in the Pandaboard. Code can be found at:

5 comments:

David Sanz Kirbis said...

Thank you!

ed said...

It seems stuck in an infinite loop on my pandaboard ES. What gives? And... where did you get the info to do this in the first place?

ale said...

i have the same problem!!

maybe it does not work on ES

Ciao

Dingo_aus said...

Unfortunately I have not tested it on a PandaBoard ES.

ale said...

#!/bin/bash

c=32
TS_1=45000
TS_2=50000
mille=1000
_exit="q"

while true; do

var=`cat /sys/bus/platform/devices/temp_sensor_hwmon.0/temp1_input`

temp=$(echo "scale=2; $var/$mille" | bc)

if [ "$var" -le "$TS_1" ] ; then
c=32
elif [ "$var" -gt "$TS_1" ] && [ "$var" -le "$TS_2" ]; then
c=33
else
c=31
fi

clear
echo "Press q anytime to stop"
echo
echo -n -e '\r' "CPU temperature" "\033["$c";40;1m $temp "C°" \033[0m"

sleep 0.5

stty -echo
read -s -n1 -t0.01 tasto

if [ "$tasto" = "$_exit" ] ; then
echo
stty echo
clear
exit
fi
[ Read 41 lines ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text^T To Spell