OK here goes. Here is a port of the monitoring part of the Open Energy Monitor - very little needed to be changed. I had an Arduino/Raspberry Pi energy monitor running for a couple of years but the Spark frees me from a long run of wires and gives me more processing power without going to the expense of Zigbee.
The Spark has only been running for a few days so doubtless it is still very buggy. I had some strange behaviour with the ADC readings as the Spark Core team have been going through the process of improving the firmware. With some recent firmware the ADC values have been odd but the power factor has remained correct so everything kept working. I will dig into this in a lot more detail when I next have time in a couple of weeks.
The system is based on a Spark that sits close to my two electricity meters (domestic and PV generation) and my gas meter.
The domestic meter is monitored by a clip on current sensor.
The voltage and relative phase is measured with an ac adaptor.
Both of these are straight from the Open Energy Monitor project http://openenergymonitor.org
The PV meter is inaccessible for a current sensor so I monitor it and also the domestic meter with photoresistors which detect the LED flashes which on my meters occur every Joule. A third digital input measures my gas consumption using a reed switch.
So the inputs to the Spark are 3 digital interrupts and two 50Hz low voltage analog signals.
The Spark acts as a UDP server and reports the energy consumption (actually the average power) since the last poll.
The Spark is polled by a Raspberry Pi which is sited conveniently close to my router and the energy display. It records the data on a USB hard drive, plots it to an image file used for a web page and sends it to an Arduino-driven 20x4 lcd display which also has a button to define whether my immersion heater should be on, off or controlled by the Pi depending on the solar PV. There are doubtless better web displays and better 20x4 displays but these work for me. The other reason for keeping the Pi is that it drives a Telldus USB stick that remotely switches my immersion heater and other electrical equipment.
The photos show the Spark on a Veroboard - there is very little external circuitry. The ribbon connector goes to the sensors.
There is a magnet built into the 1/100 m3 wheel of the gas meter and this closes a reed switch (attached with blu tack) once per revolution.
The photoresistors are poked down the tube of an old pen and attached to the meter with blutack.
The display consists mainly of a bar which has a length proportional to actual electricity use with the horizontal position showing the import/export balance. Rather busily is also shows the gas consumption and the energy cost for the past 24 hrs.
The web display shows a running 24 hrs generation and use on a Ā± 4kW scale superimposed on the gas unfortunately for my bills on a 0 - 40kW scale.
Iāll fill in more details in a week or two but in the meantime there are several potentially helpful snippets:
ADC measurements faster than the standard loop() will give you
A simple port of Open Energy Monitorās emon.lib
Spark interrupts triggered by flashes and a reed relay
UDP communications with a Raspberry Pi
Serial communications between Raspberry Pi and an Arduino controlled display.
It may seem a little odd that I use 3 different devices. It is mainly historical - I originally had a 4 core telephone cable from the meters to the Arduino display which then delivered data to the Pi for storage and to act as Web server and immersion controller. The Spark does away with the wires and allows me to collect more information but I still need a ārealā computer to control the spare PV power and since the Arduino already does a good job controlling the display I havenāt reworked it.
The Spark, Pi and Arduino code is at: https://gist.github.com/phec/9254793
The Spark
Photoresistor on generation meter
Reed switch on gas meter
Simple display
Busy display
Web image