It sends one line with the radiation value (in mR/h) measured during each sampling period (111.11s).
create.sh:
#!/bin/sh
# create.sh - create rrd for storing radiation measurement values (run once)
RRD=rad.rrd
rrdtool create $RRD \
--start 1301511639 --step 111 \
DS:mR-h:GAUGE:333:0:10000.0 \
RRA:AVERAGE:0.5:1:6000 \
RRA:AVERAGE:0.5:6:3000 \
RRA:AVERAGE:0.5:16:3000
sc.sh:
#!/bin/sh
# sc - simple serialport capture script
SERIAL=/dev/ttyS0
# run loop forever:
while true ; do
read a < $SERIAL
N="`date +%s`"
echo "rrdtool update rad.rrd $N:$a" >> data.log
rrdtool update rad.rrd $N:$a
echo $a >> geiger.log
sh graph.sh
done
graph.sh
#!/bin/sh
# graph.sh - generate graphs from rrd
# mR (milliRoentgen) to Roentgen: CDEF:value=mR,1000,/ \
# mR (milliRoentgen) to Sievert: CDEF:value=mR,100000,/ \
rrdtool graph radday.png -s -24h -e now \
-l 0 -r \
--alt-y-grid \
--units-length 5 \
--units-exponent -6 \
--width 800 --height 500 \
-t "Beta+Gamma Radiation last 24h - `date`" \
--vertical-label "Sievert/h -------->" \
--right-axis 100:0 \
--right-axis-label "R/h ------->" \
--color FONT#000000 -R light --font "DEFAULT:0:DejaVuSansMono" \
DEF:mR=rad.rrd:mR-h:AVERAGE \
CDEF:value=mR,100000,/ \
CDEF:smoothed=value,3333,TRENDNAN \
VDEF:rad5max=value,MAXIMUM \
VDEF:rad5min=value,MINIMUM \
VDEF:rad5avg=value,AVERAGE \
VDEF:slope=value,LSLSLOPE \
VDEF:int=value,LSLINT \
CDEF:trend=value,POP,slope,COUNT,*,int,+ \
AREA:smoothed#0000ff40: \
LINE1.5:smoothed#0000ff:" Radiation (avg) " \
LINE1:value#ff000080:" Radiation (raw) " \
LINE1:trend#000000:"--- trend\c":dashes \
VDEF:rad5las=value,LAST \
COMMENT:" " \
COMMENT:"Maximum " \
COMMENT:"Minimum " \
COMMENT:"Average " \
COMMENT:"Last \n" \
COMMENT:" " \
GPRINT:rad5max:"%6.2lf %SSv/h" \
GPRINT:rad5min:"%6.2lf %SSv/h" \
GPRINT:rad5avg:"%6.2lf %SSv/h" \
GPRINT:rad5las:"%6.2lf %SSv/h \l" \