pastebin - collaborative debugging tool
kpaste.net RSS


temperature script
Posted by Anonymous on Sat 23rd Nov 2013 10:02
raw | new post

  1. jones@home:~$ cat rrdtemperature/rrdupdate.sh
  2. #!/bin/sh
  3. ##rrdtool create temperature.rrd --start n --step 300 DS:in1:GAUGE:500:40:110 DS:out:GAUGE:500:20:110 DS:in2:GAUGE:500:40:110 RRA:MIN:0.5:288:1440 RRA:LAST:0.5:1:14400 RRA:AVERAGE:0.5:5:14400
  4.  
  5.  
  6. #get temperature
  7. head -n 1 /dev/ttyUSB0 >/dev/null 2>&1
  8. temp=`head -n 1 /dev/ttyUSB0`
  9. in1=`echo "$temp" | cut  -d "^" -f 1-1 | python -c "print round(float(raw_input()), 1)"`
  10. out=`echo "$temp" | cut  -d "^" -f 2-2 | python -c "print round(float(raw_input()), 1)"`
  11. in2=`echo "$temp" | cut  -d "^" -f 3-3 | python -c "print round(float(raw_input()), 1)"`
  12. #update rrdtool
  13. rrdtool update /home/jones/rrdtemperature/temperature.rrd N:$in1:$out:$in2
  14.  
  15.  
  16. #update webpage
  17.  
  18. rrdtool graph /var/www/temperature/temp.png -F -E --legend-position=south --alt-autoscale --height=700 --width=1000 --color=BACK#FFFFFF --start end-2d --vertical-label "°F" --border 0 --font DEFAULT:11:sans-serif --disable-rrdtool-tag DEF:in1=/home/jones/rrdtemperature/temperature.rrd:in1:AVERAGE LINE1:in1#ff0000 DEF:out=/home/jones/rrdtemperature/temperature.rrd:out:AVERAGE LINE1:out#008000 DEF:in2=/home/jones/rrdtemperature/temperature.rrd:in2:AVERAGE LINE1:in2#4169E1
  19.  
  20. cp /home/jones/rrdtemperature/index /var/www/temperature/index.html
  21.  
  22. #sed -i "/hour/ s,SIXTYFOUR,$graph," /var/www/temperature/index.html
  23.  
  24. sed -i "/in1/ s/INTERIOR/$in1/" /var/www/temperature/index.html
  25. sed -i "/out/ s/EXTERIOR/$out/" /var/www/temperature/index.html
  26. sed -i "/in2/ s/ROOM/$in2/" /var/www/temperature/index.html

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at