Most modern energy meter have one or more LEDs which blink at a rate directly related to the energy used. The one above has two of them : one pulses at 1000 pulses per active kWh, the other one pulses at 1000 pulses per reactive kWh. I dealed with the active power only, event though I’m billed partially for reactive power also.

The idea is to collect the blinks of the LEDs in 5 minutes blocks. Twelve groups of 5 minutes-worth counts give an hour, then data are collected around 24 hours.

I used Processing to read to read the LED through a webcam and detect and collect the blinks.

Processing and its video library is the most obvious choice to me as I’m not much of a high-level programmer. Processing is well supported and gives instant gratification. It also runs on a variety of platforms, including my little Acer Aspire One where I managed to have processing run some time ago.

Grabbing the camera image is straighforward with processing : had to install vdig (vs 1.0.1) as instructed in the processing support forum and Apple’s Quicktime 7 which is the essential part to grab the video Everything went smooth, on my desktop at least. I couldn’t have it running on my Aspire One as vdig of course doesn’t run on it, and would have had to use a different library.

That said, I wrote a quick ’sketch’ in Processing to grab the camera, select with the mouse the “hot spot” of the meter (the LED) to minimize interference from the reactive power LED and ambient lights reflection. The code also represents visually the energy used in 5-minutes chucks over the 24 hours.

This is what is seen in Processing through the web cam. The image is upside-down because the camera is. But of course it doesn’t matter.

The LED area is selected clicking and dragging with the mouse. Some sort of dark cloth sleeve is necessary to pretect the camera from glare and reflection which might cause false or missed reading.

The camera view is activated pressing the “v” key on the keyboard. Click and drag a square around the LED. When done press any other key to turn on the count reading window, the one below :

The bars represent the total reading for a 5 minutes slot starting from 0:00 to 23:55 hours. The height of the bar is the reading (in my case 1Wh per pixel) and is incrmented every blink of the LED (1 Wh gone). Hovering the mouse on window (do not click on the window) returns on the top left the reading (kWh) for the time slot on the extreme left. Click on the image above to go to the flickr’s noted version for what the peaks are due to.

On the right of the string is the total reading over the last 24 hours.

A reasonably fast PC is necessary though to catch the quick blinks and evaluate the very frequent counts during peek energy requirements. And I didn’t want to dedicate my main dual core desktop PC to the purpose.

For now I did not design any mean to read remotely the data. Of course it is probably nonsense to keep continuously a fast-power hungry PC for the purpose. The Tweet-a-watt is a better option, with remote reading option also.

But I wanted to try this.

Version 2 !

It would be faster and less processor intensive to use an external event derived from the blinks and input it somewhere into the PC and log it with Processing.

I went for the “recycle way” and took apart an old mouse (well, no so old) and hooked the following circuit to the left mouse button : the light of the LED makes the TIL78-like phototransistor go into conduction which triggers an ever green NE555 (in the shape of a CMOS TLC555). The monostable in turn makes the NPN transistor close the relay which close the left mouse button of the mouse. Simple yet effective.

Side effect : the mouse can’t be used for anything else during count accumulation, otherwise the counts are affected, obvious. A dedicated external USB I/O device would solve the problem but this cost zero.

The purple wires are hooked to the coil of the relay inside the mouse.

The sketch for Processing for photo transistor version is here.

The sketch for Processing for the web cam version is here.

Have fun.

Alessandro

Here is how I installed Processing on my Linux Acer Aspire One. It took a little bit of time and I learned something also in the process. BTW, I can’t imagine a less convenient name (processing) to look for in the Internet : ANYTHING related to computers has to do with processing ! LOL

The steps :

I Downloaded processing-0148.tgz from processing.org. The file will go to the ‘Downloads’ directory.
Then I unpacked Processing-0148.tgz to the directory Processing-0148 inside the ‘Downloads’ directory.

Went to Java Sun website and downloaded Java SDK for Linux (jdk-6u10-linux-i586.bin).
Followed the install instruction from Sun specifically for the self-extracting bin :

cd /usr/share
sudo su
./home/user/Downloads/jdk-6u10-linux-i586.bin
That is : changed directory to where I wanted to JDKto be installed into, became root and executed the bin to install the JDK. Answered yes when required to agree to the terms of license.
A few moments more and JDK was installed.

Than moved Processing directory to /usr/share :
mv /home/user/Downloads/processing-0148 /usr/share/

Now the trick suggested by Fry and Reas necessary to make processing use the JDK and not the IcedTea Java which won’t work for processing and that is supplied with the Aspire One :

cd /usr/share/processing-0148
mv java java.bak
ln -s /usr/share/jdk1.6.0_10 java

The latter two steps backup the original java directory of processing and create a crosslink to the installed JDK.

To execute processing:

cd /usr/share/processing-0148/

./processing

That’s it.

I had hard time finding it in a local computer shop. When I found it the clerk said “the Windows one ….. finished” But I wanted the Linux one “mhhhh….the white one is sold out !”, he said then. What the … this is not a Mac, “I want it blue !” I said.

At last he gave up and handed me the small treasure box.

Not a cheap computer, 300 Euro – no way to find it for less -  this could be a great present instead of a super sleek mobile phone.

This one worked out of the box immediately, the WLAN connected immediately to my access point, just set the encryption mode and key. My HP printer connected immediately : I just followed the instructions from a good forum and could print the test page in 10 minutes overall .

Made a few more hacks like getting rid of the Acer desktop and took out the XFCE desktop and made some others hack.

I had hard time getting my Bluetooth at work but I was sure linker3000 would make it and today, Oct 4, he posted an update with drivers and instructions ! I love this Linux community. Now I have my GPS receiver Holux GPSlim240 send its messages to the console !

Next step : have Processing run, as for now I’m getting the following

java: xcb_xlib.c:50: xcb_xlib_unlock: Assertion `c->xlib.lock' failed.
./processing: line 17: 23577 Aborted   java processing.app.Base