I have just measured the AC with a multimeter : 0.163A - 0.171A
But now I’m sure it’s the analog1 port of the cerbuino bee that doesn’t work. I tried with the analog5 pin and the CT sensor only ( without the gadgeteer module) and it returns me a value between 0.16A to 0.21A.
Now , I think my problem is my math, I attached you my code (is just a translation from the arduino code to c#) :
private double CalcIrms(int samplesnb)
int SUPPLYVOLTAGE = 5;
for (int i = 0; i < samplesnb; i++)
lastSampleI = sampleI;
sampleI = current.ReadRaw();
lastFilteredI = filteredI;
filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI);
// Root-mean-square method current
// 1) square current values
sqI = filteredI * filteredI;
// 2) sum
sumI += sqI;
double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / 1023.0);
Irms = I_RATIO * System.Math.Sqrt(sumI / samplesnb);
sumI = 0;
and I called it from this code :
Debug.Print("AC: " + CalcIrms(1480));
There is around 5.5% of error between the multimeter value and the CalcIrms.
Is there a better way to do this ?