You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Pi Zero W reading registers from an AdaFruit MAX17042 battery fuel gauge https://www.adafruit.com/product/5580 using the I2C bus with a single cell LiPo battery and a 68 Ohm resistor and red LED as a load. AdaFruit provides some C code to interface to the board https://github.com/adafruit/Adafruit_CircuitPython_MAX1704x/tree/main and I can read the voltage from the register on the chip using the I2C bus, and it appears to be accurate. When I try to read the same register using smbus2 I get a different value.
The value read from the Adafruit code is 513D:
The value read from the smbus2 code is 5113:
I am using data = self.i2cbus.read_word_data(self.i2caddress, register) to read the registers on the MAX17048 chip. The python files for the code I am using are attached as .txt.files. i2ctest.txt MAX17048.txt
If I use smbus instead of smbus2 to read the MAX17042's registers, I get the correct result. I have attached the updated MAX17048.py code to use smbus instead of smbus2. MAX17048-smbus.txt
The text was updated successfully, but these errors were encountered:
Hi @pmi123.
smbus2 is not a clever library. It is just a wrapper on top of the Linux kernel's i2c bus interface with the objective to simplify i2c and SMBus communication in Python. It doesn't do any sort of data conversion or adjustments, just pipes through the commands and responses as is.
I am not familiar with the device you have, but aren't the differences in the received word values very small? 513D vs 5113 are not a lot if the whole word range is used. Thus leaving room for measurement error/noise, I mean....?
I have a Pi Zero W reading registers from an AdaFruit MAX17042 battery fuel gauge https://www.adafruit.com/product/5580 using the I2C bus with a single cell LiPo battery and a 68 Ohm resistor and red LED as a load. AdaFruit provides some C code to interface to the board https://github.com/adafruit/Adafruit_CircuitPython_MAX1704x/tree/main and I can read the voltage from the register on the chip using the I2C bus, and it appears to be accurate. When I try to read the same register using smbus2 I get a different value.
The value read from the Adafruit code is 513D:
The value read from the smbus2 code is 5113:
I am using
data = self.i2cbus.read_word_data(self.i2caddress, register)
to read the registers on the MAX17048 chip. The python files for the code I am using are attached as .txt.files.i2ctest.txt
MAX17048.txt
If I use smbus instead of smbus2 to read the MAX17042's registers, I get the correct result. I have attached the updated MAX17048.py code to use smbus instead of smbus2.
MAX17048-smbus.txt
The text was updated successfully, but these errors were encountered: