The library returns strange readings when the current is flickering around zero, and it appears to be due to a minor bug in the Adafruit library. In the function:
it is treating the value in the current register as an unsigned int, but in fact it is a signed value. This means that small negative currents are being treated as large positive ones.
The library returns strange readings when the current is flickering around zero, and it appears to be due to a minor bug in the Adafruit library. In the function:
it is treating the value in the current register as an unsigned int, but in fact it is a signed value. This means that small negative currents are being treated as large positive ones.
By changing the function to return a signed int:
it can return positive and negative currents correctly.
The function getShuntVoltage_raw() looks like it suffers from the same problem, but that has not been tested.