Arduino pulse counting with multiple Energy Meters and logging to Emoncms
Part of the circuit shown runs (by necessity) 220V AC current. If you are not sure what that means and how to avoid getting injured because of it, please keep reading but don't try replicating the project. I am in no way responsible if you manage to get electrocuted but I would be sorry to know that you did it because you tried this at home and you didn't read the disclaimer .....
I have been working on a prototype for an arduino based project aimed at measuring energy consumption using multiple energy meters that can be interfaced to an arduino input pin like this one from finder :
the requirements for this project:
- monitor power consumption using multiple counters
- store the collected data through a net connection to an Open Energy Monitor instance
Such a setup would allow me to monitor multiple power consumption (or production) counters, like house energy consumption and photovoltaic production, or energy consumption in multiple zones of an house.
Energy meter (one or more):
I used two energy meters from a chinese supplier mainly because of cost (about 1/3 than the Finder meters).
These are the specs from the datasheet:
The important part is the pulse output section that states the frequency of the pulses (one every Wh consumed) and the duration of the pulse (useful for the debouncing settings).
I set up a test rig composed of the two meters, and had two arduino analog inputs connected (red cables) to the two pulse inputs and the pulse outputs connected to arduino GND
Please be careful when wiring them especially the AC part.. read the diagram provided on the pulse meter datasheet and, if in doubt, don't do it ... have an experienced electrician (or spark .. whatever) do it.
Itead studio IBOARD
An arduino duemilanove compatible board, it drops support for arduino shields but has embedded ethernet, an xbee socket, microsd support, a dedicated socket for a wireless module (nRF24L01) and exposes directly all the duemilanove analog pins, all for around 30 euro ...
Test RigA breadboard, some pushbuttons and some leds, lots of jumpers and another arduino to generate enough pulses in a known quantity to test and debug the pulse counting sketch:
I started testing the pulse counting sketch using pushbuttons (still present on the breadboard) but I quickly realized that if I wanted to run tests with consistent input data my finger and my stopwatch wouldn't really be enough in the long term, then I decided to go ahead and use the energy meters, and I had no problems hooking them up and start counting pulses, but then I wanted to test how accurate the sketch was when counting pulses, and how many inputs it could theoretically support, so I set up a second arduino board running this sketch:
The sketch can be configured to generate a variable load on six different channels, with a configurable pulse duration. By changing this array
I was able to generate pulses for a simulated load of up to 20kWh with reasonable accuracy (about 99.5%) , more than that and accuracy quickly drops below 99% (a 20kWh load with a 1Wh resolution means a pulse every 180ms and with a 90ms pulse length plus six channels to handle there will be a discrepancy, but for my testing purposes it is fine)
Pulse counting sketchThis is the main sketch that does the pulse counting and forwards the data to the energy monitor software, I won't go into much details about emoncms, suffice it to say that it is a wonderful piece of open source software and it has a great community to support it.
The skecth can be configured to count the pulses from multiple (in theory as many as there are input pins ) inputs, for my tests I settled for six, with another six pins used for driving some leds to have a visual read on the pulse counting.
By necessity the sketch uses interrupts to reliably detect pulses, and since the standard arduino duemilanove has support for two (pin 2 and 3, I believe) I used a library called pinchangeint to enable interrupts to be triggered on input value changes on all the pins.
This is a graph of the logged values when running the load simulator with these parameters:
This is a graph showing all the measures in a pretty emoncms dashboard
This is a graph of a real load with values read from the two energy meters:
The evolution of this test setup will be to implement it for monitoring my home consumption (in addition to other means of counting) and, possibly, to develop an embedded solution aimed at measuring single and three phase photovoltaic/home setups, with some added options for eventually diverting the photovoltaic production to different uses depending on conditions
Posta un commento