0

I am looking to connect an external battery to my Raspberry and know its level of charge. For that, I have to use a SMBus connection, so I can use the I2C ports of my Raspberry. But I can not recover the battery data.

My battery is on 0x0b

I know that the first byte is a write byte and that the code is 0x16, the other two bytes are readbytes and the code to have the level of charge is 0x0d.

Could someone help me?

My program:

import smbus
import time
bus = smbus.SMBus(1)

bus.write_byte(0x0b,1)
x=bus.read_word_data(0x0b,0x0d)
print x

x=65535

Why this result?

  • Does i2cdetect -y 1 detect the device? – joan Jul 10 '18 at 12:41
  • What device is this? Where's the datasheet? – stevieb Jul 10 '18 at 19:51
  • it's an external battery – Mathieu Sollier Jul 11 '18 at 6:17
  • ti.com/lit/an/slua475/slua475.pdf it's SMBus doc – Mathieu Sollier Jul 11 '18 at 6:17
  • @MathieuSollier that doc is a general SMBus doc. Can you add the part number or the data sheet of the chip which has the I2C command list – karan Jul 11 '18 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.