My Flash Counter Project

"A project to check meter readings remotely and store results on my website"

Intro as posted on the MSE Forum :-

You may recall that some time ago I expressed doubts about the accuracy of my Wattson Meter and said that I thought I could build something a bit more accurate.

Project isn't finished yet but I have now built a device to count the flashes from my meter (each one of which represents 1Wh being imported) and log them into a web-based database.

Description of system :-

I've managed to construct a prototype using a photoresistor, an Arduino microprocessor board and an Arduino Ethernet shield.

View of meter

The photoresistor is fitted into a short length of 15mm plastic water pipe which slides into another piece of 22mm pipe which is located with a pipe clip on the meter box wall and a bit of 'blutak' on the face of the meter such that the decice can easily be withdrawn (I've also experimented with a phototransistor instead of the photoresistor and this arrangement makes it easy to swap measuring heads when required). View of the meter now looks like this :

I have a slight problem in that my meter is in a free-standing enclosure 25 metres away from the house. However, my meter tails go into the house where my main consumer units are situated in the basement and luckily I put a few extra lenths of armoured cable along the same route. I'm using one of these cables to join my measuring head to the indoor electrical cupboard. In the long term I'll probably fit the Arduino in that cupboard but meanwhile I'm using a couple of conductors in a 'spare' length of Cat5 cable to extend the signal cable to my study.



The Arduino board looks like this: View of meter It's not entirely clear from the photo but the ethernet shield sits above the main Arduino board making it into a 'double-decker' board.

It is (at the moment) permanently connected to my computer via a USB cable. At the moment, that's providing a 5V power supply to the microprocessor and lets me re-programme it. In the longer term, I'll only need a 5V supply so won't need to keep the computer running all the time and will probably use a 230V to USB socket adaptor instead.

It is of course connected to the measuring head via the cable disappearing out of top left corner of photo. Rather than trying to connect those cables directly to the board, they go via an external connector strip. Not at all clear from the photo is an external resistor in the measuring circuit which ensures that the analogue signal supplied to the Arduino input pin is wildly different during the 'meter lamp lit' and 'meter lamp dark' periods.

The third cable connected (to the shield rather than main board) is an ethernet cable along which the device can send out an internet command.

Command sent to internet is of form :-

(relevent url)?input=123450D

where the numbers show the number of flashes counted since the Arduino programme was last started and the suffix letter tells the webpage what to do with it. At the moment, I'm only sending Import Meter readings to the webpage and am deciding within the webpage script whether they represent day rate imports or night rate ones. Next stage will be to supply a signal to Arduino input pin when E7 circuits are live and let Arduino script append a letter 'N' when that signal is seen or a 'D' when it's not.

To reduce internet traffic, rather than telling the webpage about every single flash, I'm only sending output on every tenth flash.


The website logging script

When an Arduino variable is received, the script breaks up '123450D' into two variables '123450' and 'D' then decides from the alphabetic suffix how to treat it. Numeric result is then filed plus the word 'Day' or 'Night' along with current date and time onto a database page.

Also filed (separately) on that page are any actual meter readings and/or comments I want to make - again with date and time appended.

To date (11-Nov-13), that's all it does. You might be excused for thinking it pretty useless !

However, I can already read my database page, extract information manually and paste it into an Excel spreadsheet then calculate usage over a desired period. I'm also beginning to develop a set of webpage scripts that can extract data from the database automatically perform calculations on them and display the results on screen.

Next stage is to measure my export meter output in a similar manner - initially I'll use a separate board for each meter but should eventually be able to do both on the same one. Meanwhile, I can of course export my inverter readings manually for analysing historic data although that's not a lot of help for 'instant' results.

And of course when I have database fully up to date with imports, generation (and perhaps even exports) I can run other website scripts to process that output and show results on screen. Indeed, since it's a web-based project I could theoretically use a smartphone to see how the electricity generation and consumption are doing whilst I'm on holiday.

Costs

Anyone thinking of building a similar device would probably like some idea of the costs involved. It's really not been all that much.

I bought most of the bits from eBay where I prefer to stick with a seller who actually has the goods in the UK. For many of these items, it can be a lot cheaper to use an overseas based seller but I prefer to avoid the potential problems of pursuing any claims for non-delivery or faulty goods in a foreign court.

majority of items came from eBay seller 'booskibits'
Arduino Compatible Funduino Uno R3 - ATmega328P-PU Board with Free USB Cable & FREE DC to PP3 9V Battery Cable
eBay item number: 130991993087
Price:£9.75 inc free postage

although 'booskibits' also offer the ethernet shield, it was rather cheaper from from tradeflair
Ethernet Network Shield for Arduino UNO Mega W5100
eBay item number: 131041838299
Price:£10.90 inc free postage

Photoresistors were also from 'booskibits'
10x LDR 5537 Light Dependent Resistor Photoresistor

eBay item number: 141012523512
Light Resistance: 20-45Kohm, Dark Resistance: 2Mohm , Spectral peak (nm) : 540 , Response time (ms) : , rising: 20 , Fallen: 30
Price:£2.50(again free postage) for pack of ten (But of course I only need one per meter)

Alternative to that might have been a phototransistor
e.g. from 'ha5ia'
eBay item number: 180718759652
Infra Red/Remote Phototransistor Receiver LPT80A
2 pieces for £3.56 (also free postage)

I also needed one resistor for the measurement circuit but really wasn't certain in advance what I needed to use. Hence I bought a pack of mixed values from mjs-technologies
1/4w 1% Metal Film Resistor Kit 600pcs 30 Values Assortment/Pack/Mix/Selection
eBay item number: 221291711260
Price:£5.00 (again free postage)
I eventually used just one resistor value 1 (or was it 2 ??) megohm so arguably cost was approx 1p

Total cost for a unit to monitor one meter is therefore a little over £20.

To add my second meter, I'll probably use another complete set of bits whilst I'm experimenting but anticipate that I could eventually cut that down to just one extra photoresistor and one external resistor (total cost less than 30p) if I rewrite the Arduino script to monitor both at the same time (not terribly difficult to do but might cause problems deciding which system was at fault if it all stopped)

Software

The Arduino is programmed with what they call a 'sketch' (anyone else would call it a 'programme' or a 'script' ) written in a language not unlike 'C'. The sketch is compiled then loaded onto the Arduino via the USB port. For a flavour of the sketch used in this project Click Here
N.B. When finished reading that return here with browser's back button.

The ethernet command sent to webpage is of the form xxxxxx.php?input=123456A

That calls a webpage script which processes it.
As webpage scripts go, it's a pretty simple one. The main logical flow of it is set out in an example file which you can see if you Click Here although there are a few variables I've replaced with asterisks because I don't want anyone else trying to use them and a couple of lines I've had to remove (but say that I've done so) else the example would turn into a real script and start processing !
N.B. Again, when finished reading that return here with browser's back button.