Hi Robert, I have found the problem! I had originally thought that something I was doing in my code was interfering with “Irms = emon1.calcIrms(1480);” getting the correct value. That thought was completely wrong and that line of code can be used in a callback or function as you said.
The project I am working on uses opto-coupled relays with the option to supply the relay coils with a different voltage source to the one powering Arduino. So, I supplied 12 Vdc into the project box and dropped that to 8 Vdc with an SMPS to power the Arduino via its Raw input and on board regulator, I then used an AMS1117-5 ( 0.8A max) to supply 5 Vdc to the relay coils. I set up a test with a fixed AC load fed via the CT, the measured value was 300 mA. The relays had no linkage to the fixed AC load at all.
The 1117 supplying the relay coils was faulty, with one relay coil energised @ 65 mA I got the expected
300 mA reading. When I energised the second relay (130 mA total coil current) I got a completely wrong mA reading for the same fixed load, but it seemed to be consistently wrong. Checking various voltage I found faulty ams1117 was dragging the 12 volt supply down, causing the Arduino voltage to drop to 3.5 volts and thus the ADC reference was flawed.
The reason for supplying the power in the way I have is because I try to make my projects universal and other variants require 12V for some solenoid valves.