Add pulse count in sketch for Emontx v2


I built an Emontx v2 and I want pulse counting.

Is there a sketch with pulse counting?

How can I add pulse counting in sketch “emonTx_CT123_Voltage_Temp”.

Thanks for all.

There is a sketch for pulse counting with the emonTx V2 on GitHub. However, it only counts pulses. It should be easy to copy the necessary parts of that sketch - I think that means every line containing “pulse” - and add them to the “emonTx_CT123_Voltage_Temp” sketch.

It’s not that more complicated? I’m going to try.

Thank you for your reply.

Sadly the resources section seems to have’lost’ direct reference to emontx v2 - as there are thousands out there​, and they are still in the shop, perhaps we can request it is put up?

I put up an emontx v2 sketch here…

that might be of interest.

It has both interrupt based pulse counting and timer based pulse counting, the later is good for things​ like gas meter pulses which use reed switches.

It sends data over serial so not an RF version. However it too might be a useful​ working example emontx v2 sketch for you… or not.

Have fun.

Have you looked at GitHub: GitHub - openenergymonitor/emonTxFirmware: An open-source wireless energy monitoring node ?

All that seems to be missing is a direct link to GitHub.

Yes, as you kindly point out it is on github. Perhaps the resource site needs an emontx v2 section… that would be good … Stuff like links for the build instructions etc.

It was @glyn.hudson who pointed out to me that he’d moved it all to GitHub - I’d originally gone to Wayback Machine to find it. So he knows people look for it from time to time, but there’s no indication that I have seen anywhere in Resources that it is in fact there and available.

In a manner of speaking…

The item listed on the emonTx v2 page is only a bare PC board and jacks, i.e it’s not a complete kit.

Agreed re shop. The need remains, I believe, for information on build, parts needed and calibration, sketches, designs etc. so the good work is easier to find… A way back from wayback :slight_smile: for emontx v2.

Have you actually looked at GitHub? The pcb layout & schematic, BOM (of sorts - I’ll grant you it doesn’t have manufacturers/suppliers and their catalogue numbers), Port Map, build instructions and 9 example sketches are all there. EmonTx V2 calibration is covered in the calibration instructions - it’s the emonPi that is missing! Now, when I get time to write that and prove it…

Yes thanks. After getting re-directed numerous times by Google to oem resource pages which have no emontx v2 content.

I can see I have not been too clear in my comment. It was a suggestion that oem resources has brief emontx v2 information with links to github resources etc. which, as you kindly indicate, exist somewhere.

My apologies for any confusion.

I leave the thought.

Hi all,

Thank you for your answers.

No problem to find different firmware for emontx v2.

Just, I want to know how to include the pulse counting in an existing sketch.

I can not compare the different scenarios.

The sections are not written in the same way.

Last question, is it possible to use the firmware of an emontx V3. It’s the same microcontroller.


Yes, it will be possible, but it is probably harder than pulling together the two V2 sketches. If you start with the V3 sketch, you will need to change all the analogue input ports, the type of RFM radio module, and the interrupt numbers. You will also need to remove the DIP switch code, because you do not have those.

I have integrated the two V2 sketches, the pulse input appears to work.
(I did not fully test all the inputs.) (3.8 KB)

If it is OK, tell us and I will ask for it to be put into GitHub.

Hi Robert,

I try your sketch this weekend and I tell you.

I am too newbie to know how to program but I try to understand.

Thanks for your work.

Thanks for letting me know that the emonTx V2 info was tricky to find, I have added an emonTx V2 section to the resources:

All the emonTx V2 info (hardware, firmware, build guide, port map, BOM etc) can be found on the emontx2 github