Many years ago I bought a Current Cost meter. Infact it was so long ago now that they have called my version The Classic. I wanted to see how much electrical energy all my servers, home computers and gadgets were using.
The Current Cost package contains two main parts, a transmitter and the display. The transmitter is hooked around your house/offices main power in BEFORE the consumer meter. The consumer meter is the big box that is usually under your stairs. The meter constantly sends power usage to the display which shows the watts currently being used, watts over time and, with a little bit of input from the user how much your energy usage is going to cost you over time.
The reason I went with a Current Cost meter is becuase it has a serial connection on the bottom of the display unit. One annoyance is that it uses a RJ45 connector so you either need to stump up for a custom cable from Current Cost or make your own (google it, there are a number of sites with pinouts and instructions).
I already monitor pretty much every aspect of my servers using Munin so it seemed like a natural solution for graphing the Current Cost data over time.
Sending data to Munin is fairly easy and it has a simple plugin interface. There are some complexities to it as Munin uses RRDTool to render it’s graphs and the options for RRDTool are complex and confusing.
The results are graphs like this:
showing watts used over time
showing temparature at or near the Current Cost display
OK they are not very pretty but that’s not the point. I can see that right now as I am typing this my house is consuming about 440 watts. At this rate, per hour I am using
440Wh (watt hours) or
0.44 kWh which is (on average)
0.44 * £0.15 ~ £0.06 per hour
Now as you can see, through the day we get massive spikes, they are usually boiling water for coffee or cooking.
The most interesting thing for me is that having the data before me modifies my behaviour. For example I finally unplugged my Wii today, 4 months after getting my WiiU. It’s been there quietly sucking up a few kWh per day. It hasn’t cost me a lot but as they always say:
If we all did it we’d save the planet!
That is a direct quote from Al Gore!
So here is the python code that you can use as a munin plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
There is a lot going on here so I’ll summerise the code:
- Munin plugins are usually symbolic links to scripts. This script gathers either the watts being used or the room temperature depending on the name of the symbolic link. So if the link is called currentcost_watts it will return information about watts, if it’s currentcost_temperature it will return temperature information. This is normal Munin pratice. (see line 88)
- Munin passes in the argument “config” if it wants the plugin to output the RRDGraph config for the data. (see line 87)
_readvalues()function is hardcoded to read from FreeBSD’s serial device
/dev/cuaU0your Current Cost meter might appear somewhere else.
_readvalues()function returns a DataBlock class. Reading from serial means you get partial data at times so the code iterates over the serial stream until it’s get all the data needed for ONE DataBlock. Because the munin script is being called once every 5 minutes it doesn’t matter too much.
- Where there is a lot of power being used I seem to get values appearing on Channel 2. The Current Cost meter I have can read from three meters. I only have one meter so I don’t know how this is happening. I assume it’s a bug in the Current Cost meter but it could be in my code.
I hope this helps someone, good luck getting your energy bills down. I wish there was a similar bit of hardware to measure natural gas usage.
be seeing you.