I2C & BQ2060 Battery Gas Gauge (PYBOARD/LOBO) [solved]

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

I2C & BQ2060 Battery Gas Gauge (PYBOARD/LOBO) [solved]

Post by devnull » Fri Nov 17, 2017 5:14 am

Original Post edited with corrected info

Firstly, yes I have 10K 3V3 Pullups and the device I am connecting to is 3V3.

When I use bus-pirate to scan the bus I get:

Code: Select all

I2C>(1)
Searching I2C address space. Found devices at:
0x16(0x0B W) 0x17(0x0B R) 
So it correctly finds device 0x16 (22)

But when I scan using micropython (LOBO/ESP32 & PYBOARD) I get:

Code: Select all

>>> import machine as mc
>>> i2c=mc.I2C(sda=mc.Pin(21), scl=mc.Pin(22), freq=100000)
D (15887) intr_alloc: Connected src 49 to int 9 (cpu 1)
>>> i2c.scan()
[11]
It seems to find device 11 (0x0A) instead of 22 (0x16) ??

Also, I2C does not appear to work at speeds below 20khz, using speeds below 20000 i2c.scan() just hangs.
Last edited by devnull on Fri Nov 17, 2017 8:34 am, edited 1 time in total.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: I2C & BQ2060 Battery Gas Gauge (PYBOARD/LOBO)

Post by devnull » Fri Nov 17, 2017 8:20 am

OK, made some progress but still cannot communicate fully as I can with bus-pirate.

Don't know why the bq2060 address of 22(0x16) is reported by micropython to be 11(0x0b) ??

But I can talk to it and get meaningful data, but the bq2060 has a feature whereby if you send it a command, then within 1 second it will send all commands received directly to the 24Cxx eeprom and returns replies as if you were connected to it directly.

Now again, this works fine with the bus pirate, but I can't get it to work with uPy !

After sending the command to the bq to enable the eeprom bus, when I scan I get:

Code: Select all

>>> bq.scan()
[11, 12, 13, 14]
Addresses 11,12,13,14 - 11 I know is my device.

12,13 & 14 again do not match the eeprom's actual address which actually is 10(0xA0) and I am unable to get any replies from these addresses or from 0x0A which is the actual address ?

Any suggestions ?

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: I2C & BQ2060 Battery Gas Gauge (PYBOARD/LOBO)

Post by devnull » Fri Nov 17, 2017 8:32 am

Nice when you solve your own questions !

OK figured it out, 0x16 is the device ID, and 11(0x0b) is the read address, for the eeprom 0xA0 is the device ID and 80(0x50) is the Read/Write Address for the Eeprom.

All working now.

Post Reply