Here is a working approach based on using a small C program with an interrupt handler. Interrupt handlers should have no problems keeping up with most meter pulse counters.
All I use in terms of hardware is a 3.3k pull-up resistor for my GPIO input pin. The counter end is an optical coupler (applies to most S0 interfaces). Maybe even the GPIO pullup is sufficient
In reverse order of operation:
Step 1: Create a dummy RFXmeter counter device. Under the devices, make note of the device index (117 in my setup)
Step 2: I used a LUA time based script to feed this dummy device from a
memory based file named
/var/run/shm/isrcounter1 . The script is available from
http://hansrune.net/domo/script_time_energy.lua. You will need to adapt this to your device index from step 1.
Step 3: The interrupt handler is adapted from the wiringPi samples. Under
wiringPi/examples, add the C program isrcounter1.c. I also added an output for a feedback LED in series with a current-limiting resistor. The LED output changes every other pulse received. Adjust pin numbers as needed in the C program, then
make isrcounter1. Copy the compiled code to
/usr/local/bin/isrcounter1. Source code can be downloaded from
http://hansrune.net/domo/isrcounter1.c
Step 4: Add a system startup / service script to
/etc/init.d/isrcounter. You can download my version from
http://hansrune.net/domo/isrcounter
Step 5: Wire your input signal, and optionally the feedback output
Step 6: Under domoticz application settings, adjust the number of pulses and costs per unit of consumption
One of the nice features is that you can adjust the displayed value to match your real meter reading. Stop the isrcounter service first. If your meter reads 128192 and there are 500 pulses per unit, do this:
Code: Select all
expr 128192 '*' 500 > /var/log/isrcounter1
... then start the isrcounter service
Hope that gives your enough details to try it out.