Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
TEMPer cron + gnuplot
*.dat
*.png
*.txt
pcsensor-temper
#!/bin/bash
# crontab -e
# * * * * * /home/pi/cron.sh
cd /home/pi
TIME=$(date -u +%s)
TEMP=$(./pcsensor-temper/pcsensor)
[[ "$TEMP" == "" ]] && exit
if [[ -f temp.dat ]]; then
LAST_TIME=$(tail -1 temp.dat | cut -d' ' -f1)
if (( $LAST_TIME+300 < $TIME )); then
echo >> temp.dat
fi
fi
echo "$TIME $TEMP" >> temp.dat
#!/usr/bin/env gnuplot
set terminal png size 1800, 800
set xdata time
set timefmt "%s"
set grid
set xtics 3600
set ytics
set y2tics
set key outside
set title "Temp"
#set format x "%Y-%m-%d\n%H:%M"
#set format x "%dth\n%H:%M"
set format x "%H\n%d"
#set format x "%b %d"
set xlabel "Time"
set ylabel "Temp"
set output "temp-celsius.png"
plot "temp.dat" using ($1+(-8*3600)):2 title "celsius" with lines
set output "temp-fahrenheit.png"
plot "temp.dat" using ($1+(-8*3600)):($2*9/5+32) title "fahrenheit" with lines
set terminal dumb size 150, 30
set output "temp-celsius.txt"
plot "temp.dat" using ($1+(-8*3600)):2 title "celsius" with lines
set output "temp-fahrenheit.txt"
plot "temp.dat" using ($1+(-8*3600)):($2*9/5+32) title "fahrenheit" with lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment