[rrd-users] Summarize minute values into hourly values

Simon Hobson linux at thehobsons.co.uk
Fri Feb 18 20:30:31 CET 2011

JoeSpam8 wrote:

>I am monitoring my power meter in my house and it is good fun to track the
>usage. I have create a RRD database in where I put the amount of watts used
>the last minute - this could be everything from 20 to 60 watt per minute
>But... I would also really like to see a summarized "kW/h" value for the
>last hour,

OK, I think part of your problem is that you don't appear to 
understand the units in use - or you are just sloppy in your use of 
units. Either way, that is a recipe for problems.

I assume you mean, your power meter will show you between 20 and 60 
watts. Watts/minute doesn't make sense as watts is a unit of power 
(energy/time) so dividing by time again would give you energy/time^2 
or rate of change of power.

Similarly, do you mean KwH ? kW/h is similarly a rate of change of 
power, not a measure of energy used.

So to clarify, EXACTLY what is your meter telling you ? Is it telling 
you the instantaneous power used - eg 20 to 60 watts ? Or is it 
telling you an accumulated amount of energy used - eg <something> kWH.

The answer to that will determine what you put in. In either case, 
RRD Tool stores a rate - and it would make sense to scale your input 
values so that the rate stored is in watts.

So :
If your meter tells you an instantaneous rate (such as 60W) then you 
should use type gauge - and update frequently so as to capture 
changes in the value.
If your meter tells you accumulated energy (eg kWh) then you should 
use type counter - and it's not as critical to update so often since 
the meter is capturing all those fluctuations and adding up the total.

Now, having got an rrd database which holds power usage in watts, you 
can get values out. You can graph the data, and scale it as you wish 
- eg divide by 1000 if you want to display kW. Also, you can work out 
totals - so if you want the energy used over the last hour, then you 
can get the average power over the last hour, multiply by 3600 to get 
energy used in Joules (Ws), divide by 3600 to get Wh, and divide by 
another 1000 to get kWh. Eg, if you were running a 60W light bulb, 
then you'd have 60 stored in the database. 60*3600 = 216,000 Ws, 
divide by 3600 to get 60 Wh, and divide by 1000 to get 0.06 kWh.
You could get the same energy consumption by running a 3kW kettle for 
1.2 minutes.

Over a day the same average rate of 60 would get you 60*86400 = 
5,184,000 Ws, divide by 3600 to get 1440 Wh, and divide by another 
1000 to get 1.44 kWh.

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.

More information about the rrd-users mailing list