emonTx max pulse count frequency

I installed the pulse sensor on utility meter with 10.000 imp / kWh but checking after some time I find out that counted power is bit higher than half to real value? Is there a maximum frequency emonTx v3 is able to count? Or could an extension 3m of Ethernet cable effect the counting in high frequencies?
Thank for any advice.

I believe the emonTx will be the bottleneck. The optical pulse counter will count at high frequency.

I am not sure of the maximum pulse count frequency of the emonTx, we have not tested this since most meters don’t flash particular fast. Do you know the frequency at which your meter is flashing? What is the meter make and model?

The minimum pulse width is set in software to 100 ms, so that limits the pulse frequency to less than 10 Hz. I believe the pulse width was set to 100 ms as a means of combating contact bounce in a mechanical switch, and it could be reduced significantly when the optical sensor is the source.

I too have not tested to determine the maximum pulse rate, but as the ISR is a very small routine with no complicated maths, it should execute very quickly indeed.

What is your maximum load (kW)? Knowledge of that will allow you to calculate the pulse frequency. I believe most meters generate pulses at one tenth of the rate that yours does - at 1000 impulses/kWh. The nominal maximum load for our standard CT is 100 A, representing approx 24 kW. At that power, a meter delivering 1000 pulses/kWh will generate 6.667 pulses per second.

I may be experiencing the opposite issue on an emonPi with dropped pulses. I’ve been running tests (not done) with node-red and mqtt. If there is no pulse received for 150 seconds, then the node-red flow adds a line to a log file. I’m trying to figure out how to turn a node-red flow into a stopwatch-type timer and then “time” dropped pulses.

I first thought my test may be bad with node-red problems or mqtt problems. But I can see the Opto Pulse Sensor green LED flash and no pulse is received on the emonPi.

For the electricity meter, each pulse is 1 Wh. And my house usually idles near 300-400 W (low electricity use). So I think I should get one pulse every 10 seconds (if not more)

Sat Oct 22 2016 17:01:11 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Sun Oct 23 2016 12:32:53 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Mon Oct 24 2016 15:32:43 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Mon Oct 24 2016 15:57:24 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Mon Oct 24 2016 16:03:14 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Mon Oct 24 2016 17:08:45 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Mon Oct 24 2016 20:55:53 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Tue Oct 25 2016 10:58:08 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds
Thu Oct 27 2016 16:09:41 GMT-0500 (CDT)	Optical Pulse Stopped for 150 seconds


EDIT: I can start a new topic if I am highjacking this one…

Believe it or not the led flash does not confirm a pulse was definitely registered and output as TTL, sounds bizarre I know, but I have found the pulse sensors (from the oem shop) I tested can be delicately positioned to register a pulse enough to flash the led but not output a TTL pulse or vice versa, get a TTL pulse signal output without an LED flash. almost like there were 2 different sensors in there, one for the LED and one for the TTL, but that is most unlikely I did post about it but cannot find the post now.

Based on the meter spec it should be set default at 10.000 imp / kWh, which mean 10 pulses for 1W. But I also read somewhere that it may be programmable. Here is the meter photo:

This is why either emonTx misses pulses as it flashes really fast when electric boiler goes to 9kWh plus the house consumption or the meter is set somehow differently than the default value written on its case. If emonTx works ok, then I may be able to derive the ratio easily. In 20 hours the meters shows 40kWh but emon ~24kWh.

The meter is 3-phases and two tariffs T1, T2 based on time.

If the pulses are arriving too quickly for the emonTx to respond, the “correction” will not be linear. The emonTx will count correctly at low rates, but (say) divide by two at high rates. If you can program your emonTx, I suggest you try reducing the minimum pulse width. It is line 100 (my version!):

const byte min_pulsewidth= 110; // minimum width of interrupt pulse (default pulse output meters = 100ms)

and you can change the constant 110 to a small number, say 5.


It looks from the photo like there would be a sheet of glass / plastic in between the meter and the pulse counter, is the true? If so, this could have an effect on the readings.

Well, haven’t thought about it but yes there is plastic. I can set boiler to high consumption and check if LED is flashing in synch with the one on the meter. Good point.

It is definitely worth trying. I haven’t expected the need to reprogram emonTx so will need to get programmer and try. I knew it would come.

What happen if I insert expander with six temperature sensors in between emonTx and Pulse counter. My guess is that as temperature sensors are on one-wire and pulse counter on different pin (haven’t checked schematics) it should not effect the performance, right?

Did checked by eye and seems both LEDs are in synch even in high frequencies. Cannot say if it drops pulses but speed seems similar.

The LED on the detector flashing does not mean that the pulse registered correctly. Also, as Paul wrote, he has seen the situation where the LED on the detector flashes but the pulse is not generated. We do not know how this could happen, because we do not know what is inside the detector.

A load of 9 kW (not 9 kWh) should give you 25 pulses per second, which 2½ times the maximum rate that the unmodified emonTx sketch can handle.

Thank you! I am waiting for programmer delivery and will try to upload updated firmware into emonTx and let you know if it worked.

I just prepared everything and after compiling I got:

Sketch uses 17,286 bytes (53%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,685 bytes (82%) of dynamic memory, leaving 363 bytes for local variables. Maximum is 2,048 bytes.
Low memory available, stability problems may occur.

Is it normal?

I see a similar message. If you are concerned, you can probably remove parts of the sketch that you do not and will not use, otherwise wait and see if there are stability problems.

yes, that’s fine. It’s just a warning.

Thank for update! I bought CP2101 programmer locally but I was not able to make it working properly. It returned avrdude stk500_getsync() error but seems once it did something as it do not run the app there anymore so I ordered the one from OEM shop and hope I will be able to flash the hex properly and run the app again. Hope I did not broke the unit :p.

Hi, I updated the firmware and the counting is much better but still ~1kW smaller then the meter in a day.

1 kWh? Is that 100 pulses - in how many?
It may well be that you have a short period of time when the pulse rate is still higher than the emonTx is able to handle. What have you set the minimum pulse width to?

1kWh is 10.000 pulses and I set min_pulsewidth to 5ms. Now I am trying to decrease it to 1 and will see.