[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rrd-users
Subject:    Re: [rrd-users] rrdtool and calculations
From:       Simon Hobson <linux () thehobsons ! co ! uk>
Date:       2012-06-23 16:41:48
Message-ID: p06240895cc0b9efbf86b () simon ! thehobsons ! co ! uk
[Download RAW message or body]

Steve Sykes wrote:
>I am working on using rrdtool to log my water heater use.  I have a
>one-wire sensor measuring current and wish to calculate the wattage and
>eventually the KWH used.  The sensor reads from 0.09 for off and 3.36
>for 18 amps.  I am reading the data into the logging screen but don't
>know how to scale it up so that it reads amps instead of volts.

RRD just stores <stuff>

I would suggest calculating power and then storing that. In <your 
preferred flavour of shell> it would be as simple as :

>offset=0.09
>scale_in=3.36
>scale_actual=18
>volts=240
>
>reading=<some method by which you get the value>
>
>span=`echo "scale=3 ; ${scale_in} - ${offset}" | bc 2>/dev/null`
>
>current=`echo "scale=3 ; ${reading} - ${offset} / ${span} * 
>${scale_actual}" | bc 2>/dev/null`
>
>power=`echo "scale=3 ; ${current} * ${volts}" | bc 2>/dev/null`
>
>rrdtool update <some file> n:${power}


And you can of course combine all the maths into one formula and one 
call to bc - I've shown it as separate calls to make it clearer how 
you work out the power. Of course, you'll notice that power depends 
on voltage, and that varies - so your power calculation will be a 
little out, basically as accurate as your best estimate of an average 
supply voltage.

At least with a heater you can ignore power factor - I'm assuming 
it's just one or more immersion heaters and hence a resistive load. 
These clip on "energy monitors" that lecky suppliers seems to be 
giving away are even worse - not only do they not account for voltage 
variations, but they cannot measure power factor which can lead to 
some whacky results from them.

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.

_______________________________________________
rrd-users mailing list
rrd-users@lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic