An odd situation (solved) with Adafruit_ADS1015 library.

I’ve built a device with Arduino measuring the power comsumption and the power produced by solar panels (so that I can turn on a thermodynamic boiler when I have enough spare power). I measure both currents with a couple of induction current sensors, both of them connected to the ADS1115 that in turn is connected to an Arduino uno by I2C interface and I call iteratively the readADC_Differential_0_1() and readADC_Differential_2_3() for about 500ms for each one. Then I choose the maximum among all values and convert it in Watt.
After several months that the device was running, I’ve updated the software with some minor changes, but after then the current measurments started to float in an unacceptabile way.
Then I’ve found the reason: the readADC_Differential_0_1() now takes exactly 10ms to return a single value.
In Italy, we have a 220V 50Hz AC current. So the wave length is 20ms. By calling repeatdly the readADC_Differential_0_1() with a 10ms between subsequent calls, it causes to return always a similar way on the sine wave. I solved the problem by inserting a quick delay of 0,33 ms between calls with this istructions:
tempo=micros();
while(micros()-tempo<330);

Now the measurements are a lot more stable.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.