Measure the Temperature in RetroPie
Measure the Temperature in RetroPie
by Jeff on July 23rd, 2016 No Comments »
 , , ,

I was looking for an easy way to measure the temperature on RetroPie from the command line. I may, eventually, modify this script to log and keep averages. For now, this will simply measure the temperature in RetroPie and output the temp in Celsius and Fahrenheit.

You’ll want to save this script to the home directory for easy access

cd ~

Copy and paste the following Measure the Temperature in RetroPie script

#Measures the CPU temp in RetroPie
#Outputs in Celsius and Fahrenheit
#Written by negeric
#I'm not perl dev, so this could be optimized
sub CtoF {
     my $c = shift;
     my $f;
     $f = (9 * $c/5)+32;
     return $f;
my $tempWithC=`/opt/vc/bin/vcgencmd measure_temp | awk '{split(\$0,a,"="); print a[2]}'`;
my ($tempCelcius,$c)=split(/\'/,$tempWithC);
my $fah = CtoF $tempCelcius;
print $tempCelcius . " C - " . $fah . " F\n";

Create a new Perl file


Paste the code from above, save and quit


Now run it

pi@retropie:~ $perl
54.8 C - 130.64 F

I am no true Perl dev, so feel free to optimize this code and send it back to me.