In an attempt to save a bit of electricity (you need to if you run a server at home!) I decided to set up a monitoring system to measure usage at 2 points: at the main distribution board and just before the server. This would let me see exactly how much the server, routers and switches use and subtract that from the total use around the house. After much research online and on the
#a&a IRC channels, I figured out what I needed and set to work.
The first thing I needed were some electricity meters as used by the utilities. They have an LED that blinks a number of times for every KWh used, and I could count the number of impulses in a time period and convert that into whatever units I needed. As usual eBay came to the rescue and I found two of them for Â£15.98, which arrived promptly. I plugged them in to test them and found that neither worked so I sent them back and got new ones, and these fortunately worked first time around.
After that I needed my detector circuit that could “watch” the LEDs on the meters and output a simple digital pulse when the LEDs were lit, and this pulse would be counted by a separate circuit. My research above pointed at a pre-fabricated kit from Velleman, the MK120 IR Beam Break Detector (Â£7.99 from Maplin). I would only need the detector half of the kit, modified slightly to remove the LED and buzzer so I could have a pure digital output.
The final part of the equation is circuit to count the pulses coming in from the MK120′s. In my case I used an ATmega8 AVR microcontroller that I had kicking around. I paired that with a PL2303-based USB to Serial adapter I got from Maplin, taken apart and hacked up so I wouldn’t need a TTL to RS232 level converter. I also had an LCD display kicking around so I decided to hook that up to the ATmega8 as well.
After programming the AVR I wrote a small daemon in PERL that would read the serial port and write the counters out to a log file. A very small shell script interacts with Cacti to graph the usage. Since my meters give “1000 imp/KWh”, that would mean one count per Wh. Cacti uses RRDTool which converts the counts into a pulses/sec value, so to get a figure in watts you need to multiply by 3600:
After all that, the graph we see goes something like this:
The FrankenUPS is an old APC Smart-UPS CS 500 which has been modified with external batteries and a fan to keep it cool during long run-times. Before the mod, the UPS managed around 18 minutes of run-time before draining the battery. I simply connected some 8AWG car-audio cables to the UPS’s battery terminals, and the other end to three Yuasa 12V 7Ah batteries in parallel. In theory the UPS should last around an hour with the setup, but there appears to be a built-in cut-off at ~42 minutes (2500 seconds?) which just shuts off the UPS. After that amount of time the UPS’s transformer did get extremely hot inside so I fitted the fan you see on top, thinking that this was probably a thermal shut-down, but this did not increase the run-time of the UPS at all despite keeping the temperature down. I plan to replace this at some point with a better online double-conversion UPS at some stage that will be more likely to run for longer!