Open anvgfr opened 3 months ago
For other users that will come on this problem :
Searching more for this problem since it still occurs, i fall on a weird bug in espressif SDK with floating point calculation errors due to context switching. It seems to have been corrected in 5.1.0 version and for the ESP32-S3, but since it is not my target, i suspect that the problem is wider and not corrected on the 4.4 branch too.
Hello,
using your library to make data acquisition i noticed that sometimes computeVolt return a bad result, due to some compiler optimisation, like in this output :
Channel 1 and 2 are wrong : rms is rounded as int before calling computeVolt to get Vapp, it should be 0V !
I am running on ESP32 with Arduino_ESP32 library (Arduino IDE version 2.3.2), AdaFruit latest release (2.5.0). Chips is an ADS1015 (from techniot bought on Amazon)
Original parts of the code producing random wrong value some times:
(source is used to get the right ADC object to used on a list of 2...)
to solve temporarly this problem i had to use the source value before calling computeVolt in my own code (using a printf or another operation. (removing one or the other comment)
reading the current library code, i found that the current operation give priority on the division of the full range value (float) by the resolution BEFORE applying current source value.
So i changed the order of the code to do the multiplication first then the division (better for accurancy)
And now i did'nt get any problem with the calculation.