Temperature of Raspi core

on 31 December 2013 in Raspberry Pi

I gambled around with the Raspberry Pi: installed the LAMP stack and gnuplot. For a first test I created a shell script which logs the temperature of the core, logs it into a file, and creates a graph:

#!/bin/bash
LOGFILE=/home/pi/logs/temp.log
OUTFILE=/home/pi/public_html/coretemp.png

T=$(/usr/bin/vcgencmd measure_temp | cut -d'=' -f2 | sed 's/..$//')
D=$(date '+%FT%T')
echo "$D $T" >> $LOGFILE

gnuplot << EOC
set term png small
set output "$OUTFILE"
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set format x "%Y-%m-%dn%H:%M:%S"
set xlabel "date"
set ylabel 'temperature [C]'
set yrange [0:*]
set grid
set title "Raspberry Pi core tempreature"
plot "$LOGFILE" using 1:2 with lines notitle
EOC

The script is called every minute from cron. The resulting graph:

coretemp

Leave a Reply