I’m using the SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library with a esp32 thing plus c and I’m seeing some strange behaviour.
If I have another i2c device connected to the qwiic connector the reported battery percentage is consistently correct. However if I disconnect the i2c device the fuel gauge occasionally reports a value of 256%.
Has anyone else experienced this?
The i2c device I have connected in this case happens to be a piicodev motion sensor.
At the moment we don’t understand why this happens, but we suspect it is an I2C bus error - not the MAX17048 returning ‘bad’ data. Thank you for letting us know that the errors go away when you have another device connected. That’s really useful to know and makes me think that I2C pull-ups may be responsible. Do you have the pull-up resistors connected / enabled on both the fuel gauge and your motion sensor? And which fuel gauge board are you using: our SparkX (Black) Qwiic Fuel Gauge, or the SparkFun (Red) LiPo Fuel Gauge?
The PiicoDev board uses 4K7 pull-up resistors. The Thing Plus C does not have separate pull-up resistors, instead it uses the pull-ups internal to the ESP32 processor. My theory is:
the internal pull-ups in the ESP32 are approx. 45 kOhms and might be too high - on their own - for the MAX17048 and so introduce occasional I2C bus errors
when you add the PiicoDev board, the additional resistors improve the signal edges and the errors go away.
Thanks again for pointing this out. I will pass this along to the team.