pin 10 follows 13 (bug in arduino-0015?)
[svn42.git] / sensor_graph / sample_sensor.lua
1 #!/usr/bin/lua
2 require('os')
3 require('string')
4 require('io')
5
6 function parse_value(str)
7   last_temp = 0.0
8   last_light = 0
9   if string.find(str,"temp0: Temp C:") then
10     last_temp = tonumber(string.sub(str,15))
11     os.execute(string.format("rrdtool update /home/sensortemp.rrd -t temp N:%f", last_temp))
12     --print(string.format("t: %f Grad Celsius",last_temp))
13   end
14   if string.find(str,"photo0: Photo:") then
15     last_light = tonumber(string.sub(str,15))
16     os.execute(string.format("rrdtool update /home/sensorlight.rrd -t light N:%d", last_light))
17     --print(string.format("p: %d",last_light))
18   end
19 end
20
21 while 1 do
22    local line = io.read("*line")
23     if line then 
24       parse_value(line) 
25     else
26       break
27     end
28 end