Monitoring samples every 40 - 50 milli seconds using EMONLIB

I am working on a project that requires taking voltage, current and frequency samples of the main supply every 40 - 50 ms and keeping logs in a micro sd card… Is this possible using the emonlib library? I may use an Arduino with a ACS1115 ADC to have a better resolution. also thinking about using SCT 013 - 000 for current and ZMPT101B for voltage and frequency measurement… Would this be enough to monitor the main supply? Please suggest if someone knows a better hardware combination?


Welcome @Zohait to the OEM forum.

It would help to know just why you need that kind of resolution.

You have no chance with emonLib. You stand a slightly better chance with emonLibCM, but that’s still not been tested at that sort of speed (the documentation tells you what it’s capable of). You have not completed your membership profile, so I can’t guess your mains frequency; you need to think what 40 - 50 ms means in terms of cycles at the supply frequency, and bear in mind how many samples you need to calculate a rms value - I have to guess that’s what you actually want. If you want a reasonably accurate rms value for voltage and current, and a power, then depending on the shape of your current wave in particular, you need around 50 samples of each per mains cycle (that would mean you would include harmonic currents up to the 25th).

The c.t. and v.t. are OK (probably not very accurate though at 1.25 kHz), but DO NOT use the ZMPT101B Module, the one that I could get a circuit diagram for is very badly designed and introduces a huge phase shift, which makes power measurement almost impossible to get right.

I can’t find an ADC called ACS1115, the ADS1115 will give you 430 samples per channel per second at the top sample rate, that (for me) is 8.6 samples per cycle which means it’s only good to the 3rd harmonic of the current waveform. The ADC in the Atmel 328P is better than that.

Perhaps with a little more information about what you are trying to achieve, I might be able to offer a better solution.

Hi Robert,
Thanks for your reply.

Its a requirement of the project to record the readings at max 50ms, I will only continue with the project if its cost effective and provide accurate reliable results.

I am from Australia and the frequency here is 50Hz i.e.1 cycle every 20ms. I have gone through emonLIBCM documentation and the capability stated is 0.1 sec (100ms).

As stated above, I am currently working on the feasibility and wont mind changing the hardware to get the accurate results. I am happy to use Arduinos internal ADC if the results would be reliable.

Regarding the ZMPT101B module, do you mean not to buy the module and make one myself? In that case do you have any circuit diagram that i can follow? Also is there any other c.t. and v.t. that you would recommend apart from the above mentioned?

What changes would I have to make in the emonLIBCM to make it work at max 50ms? is it just changing the datalog_period_in_seconds to 0.05 in the library cpp?

Please let me know if you need any more information… I would like to see if there’s any better solution available?


Hi Robert,

I may also require taking 400 samples per cycle for frequency… As the minimum allowed resolution is 0.0025Hz - this equals to 400 samples per cycle (20ms) if I am not wrong…


1 Like

What values do you need every 50 ms? (Remember, all I know about what you want to do is what you have written here.)

It may well work at 50 ms reporting interval, it is just that I did not test it below 100 ms as that’s far faster than anybody would need for general energy monitoring. The problem is not getting the data - emonLibCM in an Atmel ATMega 328P does that at one sample every 104 µs (so a pair of voltage and current samples every 208 µs which is better than 10 times faster than you need) - but calculating the averages, formatting and sending the data somewhere to use it or store it.

(Note: You must make the averaging period an exact multiple of half a cycle, otherwise you will have what we term “end effect” which will introduce ripple.)

I’m thinking you should look at the research we’ve published here about the STM32. There’s a very long thread STM32 Development (and others that are relevant), and whilst I’ve been watching it moderately closely, I’m not up to speed on the details. But I think that offers a more realistic solution than an Arduino-based one - mainly because the Atmel 328P is running close to the maximum that it can do with emonLibCM.

Regarding ZMPT101B, use the transformer alone, with a multiplier resistor in the primary circuit and a secondary burden feeding straight into your ADC as per the data sheet. The problem is with the op.amp and the filters in the module.

Hi Robert,
Thanks for the information. I am after Voltage, frequency and current readings only.
I will have a look at the STM development thread and probably order the components at the end of the week… will come back if I need any clarification…
Thanks for your help.


Not calculating the real power will ease the amount of computation required a little, so that will help you.