measuring power usage

Today I discovered that the ethernet port on my beaglebone white that I used as a home automation controller had died. Luckily I had a new beaglebone black at hand. Since several people have asked about my automation stuff I decided to take a couple of pictures while replacing the controller.

In general my breaker box looks like this:
breaker box

The energy meter in the top left corner is mine so I could just connect beaglebone to its counter pins directly instead of reading it from the IR diode. Beaglebone black is the thing with blue leds in the bottom left side of the picture. The energy meter basically has a switch that “connects” the attached wires 1000 times for every kWh consumed. So measuring the energy usage is just a simple matter of configuring one of the beaglebone’s IO pins for input and poll()’ing for the changes.


The protoboard + arduino combo to the left of the beaglebone is used for listening in on my house alarm system bus (DSC 5010). I haven’t yet reconnected it. To the right of the beaglebone you can see the cable modem that I use to connect this thing to the router on the second floor. Wifi would have been easier but doesn’t work well in the basement, coaxial cables happened to be present and I got some old cable modems for free.

Beaglebone also serves a simple web frontend with statistics for all the sensor feeds that it records. For example the energy usage overview looks like this:
energy usage

I currently use PostgreSQL as my data store and I have been seriously impressed with its ability to run on such a weak hardware. When I was using beaglebone white that only had 256MB of RAM, with class 4 SD card I actually only used raw measurements table that stored data for all my datasources with 1 minute precision. This table had 2.5 million rows and still managed to answer complex aggregate queries for energy usage (N last days, group by day and each day by day and night) in about 5 seconds. Now that I have added hourly aggregated table it’s back to about 0.1s.

I also moved to a newer kernel (3.8.13) where the old omap_mux sysfs hierarchy is gone so it took me a bit of time to find how to configure the pins under the new world order.
It turns out to be rather logical (besides the pin numbering part :-P) so in order to configure pin 12 on P9 header as an input I had to do this:

echo 60 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio60/direction
echo falling > /sys/class/gpio/gpio60/edge

Leave a Reply

Your email address will not be published.