Sensor Charts

So, I’ve got a very basic datalogger working with some sensors I have (LM35 for the temperature and PT550 for the lighting). Will have to do more work with RRD to get the hang of the charting, etc. but first effort is up anyway

Charts

Temperature Chart
Temperature Chart
Temperature Chart
Ambient Light Chart

RRD Setup

Details on the backend RRD database – I’ll update this as sensors are added and I adjust it to suit my requirements.

Database

rrdtool create database.rrd --step 60  \
DS:temp:GAUGE:120:0:100 \
DS:voltage:GAUGE:120:0:5 \
DS:env-light:GAUGE:120:0:6000 \
RRA:AVERAGE:0.5:5:288 \
RRA:MAX:0.5:5:288 \
RRA:MIN:0.5:5:288 \
RRA:AVERAGE:0.5:60:168 \
RRA:MAX:0.5:60:168 \
RRA:MIN:0.5:60:168

Image Creation

This runs as a cronjob every 5 mins to update the charts. The other option is to call it from a PHP page and trigger a generation upon page click.

rrdtool graph temp-24.png -a PNG -w 550 -h 240 -v "Degrees (C)" \
'DEF:ds1=database.rrd:temp:AVERAGE' \
'LINE1:ds1#FF0000:Temperature' \
GPRINT:ds1:MAX:"Max %6.2lf %s" \
GPRINT:ds1:MIN:"Min %6.2lf %s" \
GPRINT:ds1:AVERAGE:"Avg %6.2lf %s" \
GPRINT:ds1:LAST:"Curr %6.2lf %s\n" \
-t "24 Hour Temperatures"

rrdtool graph light-24.png -a PNG -w 550 -h 240 -v "Lux" \
'DEF:ds1=database.rrd:env-light:AVERAGE' \
'LINE1:ds1#00FF00:Light' \
GPRINT:ds1:MAX:"Max %6.2lf %s" \
GPRINT:ds1:MIN:"Min %6.2lf %s" \
GPRINT:ds1:AVERAGE:"Avg %6.2lf %s" \
GPRINT:ds1:LAST:"Curr %6.2lf %s\n" \
-t "24 Hour Ambient Light"

Leave a Reply

Your email address will not be published. Required fields are marked *

Please prove you are human, or at least not a very simple bot :) *