Help running emonlib on MKR1000 for sct-013-000

Hello ,

I have built a circuit as per the schematics in the open energy documentation page . The circuit doesn’t seem to be providing accurate results . For example a 5.5A load is reported as 0.14A

First I thought my wiring could be wrong . I tested the same circuit with a Mega and I get accurate results . So I was able to isolate the issue to be something to do with running emonlib on a MKR1000 platform . Any help would be greatly appreciated .

What are the differences between that and the Mega? One of the first things I would be looking for is, what does emonLib report for the ADC reference voltage with readVcc( )? If that is wrong, all the calibration will be wrong. (You might need to tell emonLib that you have an emonTx, so that it uses a fixed value of 3.3 V, for example.) Also, the ADC resolution appears to be selectable - emonLib assumes 10 bits which you set with ADC_BITS (in emonLib.h), so that might need changing too.

Also, the ADC resolution appears to be selectable - emonLib assumes 10 bits which you set with ADC_BITS (in emonLib.h), so that might need changing too

Yes, it will definitely affect the results. I noticed that when running emonLib on an Arduino Due, which has a 12-bit ADC. If it wasn’t set for 12 bit operation, the numbers reported were in error by a significant amount.

Add the line

analogReadResolution(ADC_BITS);

to the main sketch, inside the setup() function.