Category Archives: php

Raspberry Pi GnuPlot Temperature

So, I have a raspberry Pi, and I wanted to chart it’s CPU temp

Ex: temp log hosted on RPI itself   | backup if the the RPI is down

To do this I needed to do a few things:

  1. Log the CPU temp (I’m doing every 5 minutes)
  2. Prepare the data
  3. Chart
  4. Show it to the world

1) Log data via 5 minute cron:

$ cat 
temp=` cat /sys/class/thermal/thermal_zone0/temp| awk -v FS=" " '{print $1/1000""}'` 
echo "$temp | `date` ">>~/temp.log

Then a cronjob as normal user

*/5 * * * * bash ~/

now a gnuplot script (

set nokey
plot "/home/pi/temp500" u 0:1
f(x) = mean_y
fit f(x) '/home/pi/temp500'  u 0:1 via mean_y
set label 1 gprintf("Min = %g", min_y) at 52, 21 tc rgb "#00FFFF"
set label 2 gprintf("Max = %g", max_y) at 0, 21  tc rgb "#FF0000"
set label 3 gprintf("Mean = %g", mean_y) at 102, 21 tc lt 2
set terminal png size 1400,400
set style data linespoints
set yrange [20:MAX+(MAX*.1)]
set grid
set style line 1 lt 1 lw 3 pt 3 linecolor rgb "blue"
set object 1 rectangle from graph 0,0 to graph 1,1 behind fc rgbcolor "#10000f" lw 0
set pointsize .5
plot  \
"/home/pi/temp500" using 0:1 title "cpu temp" pt 5 ps .5  lc rgb "#FF0000" , \
min_y with filledcurves y1=min_y lt 1 lw 2 lc rgb "#00FFFF"  , \
max_y with filledcurves y1=max_y lt 2 lw 2 lc rgb "#FF0000", \
mean_y with filledcurves y1=mean_y lt 3 lw 2 lc 2,\
 "/home/pi/temp500" using 0:1 title "cpu temp" pt 5 ps .10  lc rgb "#0FfFFF"

now a script to run it all: (

cat /home/pi/temp.log|tail -n 500 > /home/pi/temp500A
sed '/-/d'  /home/pi/temp500A  > /home/pi/temp500
chown pi:pi /home/pi * 
/root/ > /var/www/temp.png

Theme SimpleX Edit

So the theme I use, SimpleX didn’t have comments enabled for wordpress pages, only the posts
to fix this…

under Appearance>Editor on Page Template (page.php) you need to find this line:

Under that line add this (which I grabbed from: Single Post (single.php))

		This entry was posted
		post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?&gt;
		on  at
		and is filed under .
		You can follow any responses to this entry through the  feed.
		 comment_status) &amp;&amp; ('open' == $post-&gt;ping_status)) {
			// Both Comments and Pings are open ?&gt;
			You can <a href="#respond">leave a response</a>, or <a rel="trackback" href="&lt;?php trackback_url(); ?&gt;">trackback</a> from your own site.
		 comment_status) &amp;&amp; ('open' == $post-&gt;ping_status)) {
			// Only Pings are Open ?&gt;
			Responses are currently closed, but you can <a rel="trackback" href="&lt;?php trackback_url(); ?&gt; ">trackback</a> from your own site.
		 comment_status) &amp;&amp; !('open' == $post-&gt;ping_status)) {
			// Comments are open, Pings are not ?&gt;
			You can skip to the end and leave a response. Pinging is currently not allowed.
		 comment_status) &amp;&amp; !('open' == $post-&gt;ping_status)) {
			// Neither Comments, nor Pings are open ?&gt;
			Both comments and pings are currently closed.