A daily CurrentCost “bill”

As I’ve finally got my home server capturing the electric meter readings from the CurrentCost, I thought it’d be good to try doing something with it.

I want to start with something a bit different to graphs, because there’s already been a lot of cool work done in different graphing approaches.

As I wrote yesterday, I’ve got a MySQL database that is storing the watt reading from the electric meter captured once every six seconds.

I wondered whether it makes sense to try and turn these figures into a financial cost. It might be interesting (and useful as a behaviour-altering thing) if we could get a “bill” from the CurrentCost meter each day that told us how much we spent on electricity the last day.

+=============================================+
  Your CurrentCost bill for 2008-5-27

     Electricity usage   4.9802 units
      Cost ==           £0.4874

     Standing charge    £0.1582
   ---------------------------------------
     TOTAL COST FOR 2008-5-27 : £  0.65
+=============================================+

I’m not entirely sure of my maths here, but I thought it could be interesting to give it a try.

Turning a watt reading into a cost

Consider a single reading (set articificially high, to make the numbers easier to read!):
$watts = *75000* watts

Turn it into kW:
$kWatts = $watts / 1000 = 75

Take the unit cost from my bill:
$unitcost = 0.0932

Add VAT:
$unitcostIncVAT = $unitcost * 1.05 = 0.09786

How many hours in a year:
$hoursInYear = 365 * 24 = 8760

kW hours over a year:
$kWHInYear = $kWatts * $hoursInYear = 657000

Calculate the cost of staying at this rate all year:
$costPerYear = $kWHInYear * $unitcostIncVAT = 64294.02

Compare this with the values reported by the CurrentCost meter:
$costPerMonth = $costPerYear / 12 = 5357.835
$costPerDay = $costPerYear / 365 = 176.148

If I put in watt values I see on the CurrentCost meter, the ‘Cost per day’ and ‘Cost per month’ figures agree with what I get from these sums.

So, if I assume that a reading is valid for 6 seconds, I can work out a cost for the period of time covered by the reading:
$costPerHour = $costPerDay / 24 = 7.3395
$costPerMinute = $costPerHour / 60 = 0.122325
$costPerSecond = $costPerMinute / 60 = 0.00203875

$costPerUpdate = $costPerSecond * 6 = 0.0122325

This can be simplified down a bit to:
$costPerUpdate =(($watts/1000) * $unitcostIncVAT) / 600

Getting the readings for a single day

This is simple – I can get the total for all readings in a single day from MySQL with a query like:

mysql> select DATE(time) as "Bill Date",
    ->        COUNT(power) as "Number of updates",
    ->        SUM(power)
    -> from currentcostdl
    -> where (DATEDIFF(time, '2008-05-27') = 0)
    -> GROUP BY DATE(time);
+------------+-------------------+------------+
| Bill Date  | Number of updates | SUM(power) |
+------------+-------------------+------------+
| 2008-05-27 |              5404 |    2988128 |
+------------+-------------------+------------+
1 row in set (0.93 sec)

I’m wondering if it might be better to use the number of updates rather than assuming how many updates I will get in a day. But for now, I’ll stick with the six seconds assumption.

Update: After Alexis’ comment (below), I have switched my script to use the number of updates. It still assumes that each update is valid for approximately the same period of time, but that’s probably accurate enough for my purposes:
$costPerUpdate = $costPerDay / $NumberOfUpdates;

The number of updates for yesterday is very low because I only started up the Perl script to capture updates yesterday. By tomorrow, I should hopefully get a number of updates closer to 14,400.

Generating a “bill”

From here, I’ve put together a cron job on the server that will once a day at 8am. It runs a perl script that gets the values from MySQL for the previous day, does the sums, turns it into a pretty “bill”, then sends me an email.

Tags: , , ,

11 Responses to “A daily CurrentCost “bill””

  1. dale says:

    Another thought…

    It might be cool to add to the “bill” info about the environmental cost of this usage – such as the amount of CO2 produced to generate the electricity used.

    I’m gonna try and find some reliable figures for this – I’m not having any luck on the Southern Electric (my provider) website… in fact, the closest I’ve found is here.

  2. Pete says:

    Hmm, very interesting. When the external drive for my slug finally arrives I think I might do something more like this than yet-another-pretty-graph. One of the problems I fed back to CurrentCost was that the meter couldn’t handle my two-tier tariff – once the numbers are in Perl, though, tariff complexity is no problem. I could also probably manage a readout equivalent to the numbers on the actual supplier’s meter, to compare against bills without having to scramble down the side of the house.

  3. Neil Cowburn says:

    This is great stuff that I will definitely refer to when I get my CurrentCost monitor in the next month or so.

  4. Alexis says:

    I think you’ll be better off using the number of updates you actually get – while you get roughly one update per six seconds, over the course of a day this can slip a fair amount. My database records show the number of values received varying between between 13,396 and 13,580 per 24 hour period.

  5. dale says:

    Really? I was gonna wait until I’d collected my first full day’s, but if it’s that far out, I think I’ll tweak my script now – thanks!

  6. […] while not quite as interesting as Dale’s CurrentCost bill, I now have a working RRDtool SLAX module. RRDtool seems ideal for graphing CurrentCost data. […]

  7. Graphing Current Cost…

    After hooking up my Current Cost Meter to a database recently I’ve been logging my power usage so the next step is to look at what I can do with the data. As I mentioned when I introduced my meter lo……

  8. Jamie says:

    Hi,
    Can you publish your perl code that is storing your watt readings into the mysql db?
    tia,
    jamie

  9. dale says:

    The Perl code that adds entries to MySQL is here: https://dalelane.co.uk/blog/?p=272

  10. I’ve also been playing with the Current Cost and publishing the data to the web via Munin and RRDTool. I’m using Python to grab the data and storing it in a MySQL database and also locally on disk for the purposes of averaging – slightly different to how everyone else seems to be going about it: http://wiki.siftah.com/Current_Cost_Electricity_Monitor

    I like the idea of creating a daily bill, puts the usage into perspective!

  11. Graham Crawford says:

    Seeing the current cost monitor/meter puts out 3 phase info, anyone looked at writing programs to use a phase as a dedicated solar input?

    (I have my inverter connected to Ph3 – nothing else).