Last active
November 18, 2017 04:04
-
-
Save stefansundin/22aea48348e03edd48cd96b00e054751 to your computer and use it in GitHub Desktop.
TEMPer cron + gnuplot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.dat | |
*.png | |
*.txt | |
pcsensor-temper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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