Temperature Sensor Setup LM35 take one

From Federal Burro of Information
Revision as of 03:12, 10 March 2010 by David (talk | contribs)
Jump to navigationJump to search

k8055 connected to an lm35 with a1k resistor at 5v.

here's how I get the data into an rrd and graphed:

rrdtool create 1k_5v.rrd           \
            --start `date +%s`     \
            DS:speed:GAUGE:600:U:U \
            RRA:AVERAGE:0.5:1:24   \
            RRA:AVERAGE:0.5:6:10

new more robust rrd:

rrdtool create 1k_5v.rrd --step 300 \
  DS:temp:GAUGE:600:0:256 \
  RRA:AVERAGE:0.5:1:2592000 \ # Two months of 5 minute average data
  RRA:MIN:0.5:12:2400 \ # 100 days of 1 hour MAX data
  RRA:MAX:0.5:12:2400 \ # 100 days of 1 hour MIN data
  RRA:AVERAGE:0.5:12:2400 # 100 days of 1 hour AVERAGE data

drop this in a 5 minute while loop:

rrdtool update 1k_5v.rrd `date +%s`:`/usr/local/projects/k8055/src/k8055 -q -num:10 -delay:1000 2>/dev/null | cut -d ";" -f 3 | awk '{sum=sum+$1}END{print sum/NR}'`
rrdtool fetch 1k_5v.rrd AVERAGE --start `date --date='1 hour ago' +%s` --end `date +%s`
rrdtool graph 1k_5v.png                                          \
         --start `date --date='3 days ago' +%s` --end `date +%s` \
         DEF:myavg=1k_5v.rrd:temp:AVERAGE                      \
         LINE2:myavg#FF0000                                      \
         DEF:mymin=1k_5v.rrd:temp:MIN                      \
         LINE2:mymin#00FF00                                   \
         DEF:mymax=1k_5v.rrd:temp:MAX                      \
         LINE2:mymax#0000FF

and first prize for ugly mutt goes to.....

http://www.quadratic.net/1k_5v.png