## How much did I spend on electricity to do that?

ðŸ™‚

This time… working out the electricity used (and the cost) of doing… well, something in particular.

We already have live graphs (Switch something on and watch the graph shoot up. Switch it off and watch the line drop.)

And we’ve already got graphs with hourly, daily, or monthly totals.

But if I boil a kettle, how do I know how much that cost?

The live graph shows you the shape of the usage curve for a particular appliance.

What I wanted was to be able to start the live graph running, switch something on, then after it’s finished, go back to the live graph, see the bump in the graph for when I did that, and measure the area under it – giving me my total energy usage for that time.

A quick bit of Python-tinkering later, and here we go

Click-and-drag to highlight a span of the graph, and the Python script calculates the area (more-or-less) under that part of the curve, using this to calculate how much energy I used during this time.

I’ll tidy this up and share this update in the next day or so.

### 2 Responses to “How much did I spend on electricity to do that?”

Wow Dale, that is very, very smart!

Are you relying on the presence of the graph to calculate the total cost (i.e. counting the pixels), or is that simply a front end to some more complex calculation under the hood with the original data?

Chris

2. dale says:

Hi Chris

Thanks very much!

That said, I think “complex” would be massively overstating my quick hack last night ðŸ™‚

I’m basically treating it like a histogram – adding up every value between the min and max points in the selected range, and using the interval between each point and the next one to determine the width of that bar.

see code.google.com for the code…. but be kind – I was just playing with it! ðŸ˜‰

It’s a rough approximation, but with readings every six seconds or so, I think it’s close enough for a first pass.

I did look to see if matplotlib would give me some nice way to measure the area under a line, but haven’t had any luck finding an API for that so far.

D