|This guide explain how to turn pulses meters into a valid output format using an Arduino board.
It involve to know a bit of technical and software knowledge.
Now i will explain how to monitor electric, gas and water meters using simples 'pulse' sensors. For the interface, you'd be fine to use an Arduino. This platform have the avantage to be cheap, simple, open-sourced and you'll be able to find many sort of sensors that'll surely fits your needs.
If you own any electric production system you will need an additional meter on the consommation side. If you choose a pulse counter, choose one that have a S0 output that output a pulse per Wh or more.
Modifying your electrical installation need to be done by a qualified person. I am not joking on that, it involve high-voltage that can cause serious damage for you or to your house !
For the gas meter, i use a cheap IR barrier sensor to detect the reflective part on the hole of the 6 digit (It may be sometimes in the 9 or in the 0 digit). Adjusting the potentiometer to the good sensitivity is a game of patience !..
For the water meter, i had use a sensible and expensive (cough) reed-switch buyed to my water distribution provider.
Choosing an adequat sensors is essential, some may not be sensitive enough. You can use any "bang-bang" (On/Off) information, it can be a reed-sensor, a hall-effect sensor, you may catch the blink of a led,.. Be also be carefull when you do your cabling, it have to be done properly.
Poolmeters is given as example, it is not part of meterN project.
Since each installation is different, i sadly can't make a portable application so, you have to build it by yourself. But don't be afraid, here's some theory ;) I still use my installation as exemple.
The Arduino board must be dedicated to counting. The Leonardo have 4 hardware interrupts, it is strongly advisable to use interrupts for fast pulses meters rather than digital inputs as it make sure it detect the pulses rather than doing something else. (You may also use the register method, i know i should dig that)
When the interrupt detect a pulse, it stop the current code to do something more important: counting! Each interrupt have also priority, the lower the interrupt number, the higher the priority.
Your faster meter must then be on int. 0 and i will use it for my electrical meter. Beware the int. number don't correspond to the pin number.
For my gas meter, the pulses are slows, i then use a digital input to measure valid pulse time's width. It filter parasitics pulses it sometimes encounter..
If you use a open contact circuit like an S0 output, you need to put a pulldown resistor. If you don't, your cable will behave as an antenna and the arduino is sensible enough to detect really low voltage level.
If your sensor need to be disconnected, don't ever leave the input circuit open, you'll need to 'ground' it or you will always had constant interrupt.
The '_poolmeters.ino' code detect the interrupt count falling edges for electrical and water meters and also read the input pin state for the gas.
Some pulses may not be perfect and since the arduino is fast enough, it may detect several falling edges in a one. One trick is to use a RC circuit or, simplier, detect the pulses larger than a certain time. My electric meter pulses are around 50ms large, i put a 30ms threshold.
If your sensor is noisy,like my reed switch for water pulses is, you also may use an opto-isolator or a schmitt trigger to filter signals.
You've understand the hardest part ! Now, all it need is to communicate, the only output format understable by meterN is describe in the how-to.
The Main pooling :
Since the counter should always increase until it pass-over and can't return to zero (after a surge or if the arduino is reseted), the solution is to read the last recorded value in the daily csv and increment this record with the counting during the 5 min pooling period. Then, put to zero the arduino counter and so on..
It mean that even if meterN or the logger is stopped, the counter will always be increased and metered as long as the arduino is powered !
This is what the 'pooler.php' example script does.
The Dashboard pooling :
The live command may either return a value or a meter state, see why bellow :
Meter that increase frequently like an electric S0 output can send a time between two pulses. This time can be extrapolate to another value: The lower time, the more your consume.
Eg for my electrical meter: A time of 1716ms also give (1000*3600)/1716 =~ 2098W ! That's will be the value mode in the admin panel.
Be aware that if you don't consume much, the refreshing time between two pulses can be long. On a 1000pulse/kWh counter, it update to around a second with a 3500W consumption to ~3,6 sec with 1000W and only each ~36sec with 100W.
If your meter is slow and don't update frenquently like a gas or water meter, it can't really be usefull to know the average values for a long time.
But, if you counter receive a pulse recently, it mean than your device is running. So, the value may return 1 of 'on' or 0 for 'off' if the last pulse is too old. It's all about the 'state' mode.
Eg: I use a 30 sec basis for my gas meter and 8sec for my water meter. (coded in arduino)
All that things above should be coded according to your installation
To talk with the computer I use pyserial, a python module that ease the access to serial port. Check out the readme in poolmeters example for more details.