Tank PH

For info on what I’m using to make these charts, see the bottom of this page.
———————-





———————
PH data is sampled via an Aquacontroller III Pro. I’m using a dumb shell script to gather the web page with status, and using rrdtool to save the data/create the graphs.

To create the rrd database, would be something like this:

rrdtool create ph.rrd --start N --step 300 DS:ph:GAUGE:600:1:14 RRA:MIN:0.5
:12:1440 RRA:MAX:0.5:12:1440 RRA:AVERAGE:0.5:1:1440

Get page, parse – like this

wget http://username:password@ip.address.of.aquacontroller/status.cgi
tankph=`sed '3q;d' status.cgi | awk -F\> '{print $3}' | awk -F\ '{print $2}'`

Then, update the rrdtool database like you would normally.


rrdtool update ph.rrd N:$tankph

I got a little fancy with the graph – I wanted it to show a PH of 8.2 as norm, and show above it as hot and below as cold.

So what I do (in reverse order) is I take the ph number and graph that.
Then I create a new variable called ‘baseline’. Baseline is the value for PH, minus 8.2. So if PH is 8.3, baseline is .1.
Then I create two more variables called hot and cold and IF them against zero. If the baseline number is higher than zero, hot equals the baseline number – otherwise it equal zero. If the baseline number is lower than zero, cold equals the baseline number, otherwise cold equals zero. Then I create a line called ‘average’ and put it on 8.2, and stack areas of cold and hot against that.

# PH Graph
rrdtool graph ph.png --title="PH Daily Stats" \
--vertical-label "PH" \
-w 600 -h 200 \
--lower-limit 7.9 \
--upper-limit 8.6 \
--rigid \
DEF:ph=ph.rrd:ph:AVERAGE \
CDEF:baseline=ph,8.2,- \
CDEF:hot=baseline,0,GT,baseline,0,IF \
CDEF:cold=baseline,0,LT,baseline,0,IF \
LINE2:8.2#00FF00:normal \
AREA:cold#0000ff44::STACK \
AREA:hot#ff000044::STACK \
LINE1:ph#ff0000: \
'GPRINT:ph:LAST:PH Last\: %21lf \j' \
> /dev/null

Leave a Reply