Using the Serial Camera to Read the Smart-Meter
The Smart Meter display, cycles through five different readouts of 5 seconds each, which repeat every 25 seconds. The cycle times are not exact; I suspect that the meter’s microcontroller occasionally becomes busy with networking functions and so the timing becomes inconsistent. The first order of business is to correctly identify each of these images:
1. A Blank image, where the meter is blank (except for the letters CLS off-screen to the left.)
2. A Meter reading of total Kwatts used so far.
3. A meter Identifier, which for my meter is always “151”.
4. The Rate of electric usage in Kwatts per hour.
5. A Test screen where all the meter's LCD elements are active.
The screen identification algorithm I went with, is as follows: I start out by reading images from the camera, as fast as it will go, for the first 35 seconds. An image brightness is calculated by adding up each of the 160 green-blue bytes along a single centered horizontal line for each image. Transitions between successive images are scored by comparing brightness to the prior image. The biggest difference between brightnesses is when the Test screen transitions to the Blank screen. This maximum score is saved and used to calculate a cutoff value to detect successive blank screens. Now when a Blank screen is detected, a timer is started to read the next four images at five second intervals, but after the reading the fifth (Test) image, the timer reverts to quick reading images until a Blank image is found again. This algorithm seems to work well and I have not seen any misreading of image types.
Any image of interest can be turned in to a monochromatic image by subtracting from each pixel, the corresponding pixel from the Blank image. Subtracting the Blank’s background color and testing against a cutoff value generates a two toned image. I use the Test monochromatic image to find the locations of pixels in each segment of five LCD numerals. This process is CPU intense but when found, these segment pixel locations can be used for all images until the camera is moved. These segment pixel locations are scored against pixels on the Meter reading images and on the Rate images to generate a seven segment score that is translated to a numeric digit with the help of a look-up table (“1111111” is the digit 8 and “0101100” is the digit 7.) Common misreads are incorporated into the lookup table as well. There is a fair amount of parallax that distorts the furthest left and right digits. The decoded meter reading, rate and system time are saved in an array and backed to a Daily named file on an hourly basis. I included a little real-time electrical usage graph in a picture control, but I usually use another Graphing utility program to view the data from the saved files . All files are read/written to a 1G flash drive to allow my hard drive to get some rest at night.