-rrdtool create sensordata.rrd --step 30 DS:temp:GAUGE:1800:-20:60 DS:light:GAUGE:300:0:1023 DS:movement:ABSOLUTE:604800:0:U RRA:LAST:0.5:2:2048
-rrdtool update sensordata.rrd -t temp N:26.0
-rrdtool update sensordata.rrd -t light N:200
-rrdtool update sensordata.rrd -t movement N:0
+rrdtool create sensorlight.rrd --step 30 DS:light:GAUGE:300:0:1023 RRA:LAST:0.5:2:2048
+rrdtool create sensortemp.rrd --step 30 DS:temp:GAUGE:1800:-20:60 RRA:LAST:0.5:2:2048
+rrdtool create sensormovement.rrd --step 30 DS:movement:ABSOLUTE:604800:0:U RRA:LAST:0.5:2:2048
+rrdtool update sensorlight.rrd -t temp N:26.0
+rrdtool update sensortemp.rrd -t light N:200
+rrdtool update sensormovement.rrd -t movement N:0
--- /dev/null
+#!/usr/bin/lua
+require('os')
+require('string')
+require('io')
+--require('socket')
+
+function parse_value(str)
+ last_temp = 0.0
+ last_light = 0
+ if string.find(str,"Sensor T: Temp C:") then
+ last_temp = tonumber(string.sub(str,18))
+ os.execute(string.format("rrdtool update /home/sensortemp.rrd -t temp N:%f", last_temp))
+ print(string.format("t: %f Grad Celsius",last_temp))
+ end
+ if string.find(str,"Sensor P: Photo:") then
+ last_light = tonumber(string.sub(str,17))
+ os.execute(string.format("rrdtool update /home/sensorlight.rrd -t light N:%d", last_light))
+ print(string.format("p: %d",last_light))
+ end
+ if string.find(str,"movement") then
+ --last_movement=1
+ os.execute(string.format("rrdtool update /home/sensormovement.rrd -t movement N:%d", 1))
+ end
+end
+
+
+
+while 1 do
+ local line = io.read("*line")
+ if line then
+ parse_value(line)
+ else
+ break
+ end
+end
<RRD::GRAPH ../light0.png
--lazy --imginfo '<IMG SRC="/%s" WIDTH="%lu" HEIGHT="%lu" >'
--title="Room Illumination"
- DEF:cel=/home/sensordata.rrd:light:LAST
+ DEF:cel=/home/sensorlight.rrd:light:LAST
LINE2:cel#00a000:"0 dark to 1023 bright">
</P>
<P>
<RRD::GRAPH ../temp0.png
--lazy --imginfo '<IMG SRC="/%s" WIDTH="%lu" HEIGHT="%lu" >'
--title="Temperatures"
- DEF:cel=/home/sensordata.rrd:temp:LAST
+ DEF:cel=/home/sensortemp.rrd:temp:LAST
LINE2:cel#00a000:"D. Celsius">
</P>
<RRD::GRAPH ../movement.png
--lazy --imginfo '<IMG SRC="/%s" WIDTH="%lu" HEIGHT="%lu" >'
--title="Graph of Movement Sensor"
- DEF:cel=/home/sensordata.rrd:movement:LAST
+ DEF:cel=/home/sensormovement.rrd:movement:LAST
LINE2:cel#00a000:"1 Movement, 0 No Movement">
</P>
</BODY>