BBB and I2C Backpack, Use I2C1?

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dpancoe
 
Posts: 18
Joined: Thu Sep 06, 2012 10:28 am

BBB and I2C Backpack, Use I2C1?

Post by dpancoe »

Due to a board layout error, I need to use the i2c character LCD backpack on the I2C1 bus (SCL = P9-17, SDA = P9-18) instead of the default I2C2 bus (SCL = P9-19, SDA = P9-20).

If I use config-pin to make P9-17 & 18 into I2C pins (aware that this is only a temporary solution), I can detect the backpack when I do an i2cdetect -y -r 1, but when I run the test example code, I get a "no device at address 20" error.

What's the best way to get the Adafruit library to talk to the backpack on IC21? I see that the old library allowed the user to set the bus, and I see that the current library defaults to board.SDA and board.SCL, but I didn't find where those values are set.

Thanks,
Don

User avatar
dpancoe
 
Posts: 18
Joined: Thu Sep 06, 2012 10:28 am

Re: BBB and I2C Backpack, Use I2C1?

Post by dpancoe »

Here are two workarounds I found. Both worked for me.

For the first, I modified my code as follows...

Code: Select all

from adafruit_blinka.microcontroller.am335x import pin
...
i2c = busio.I2C(pin.I2C1_SCL, pin.I2C1_SDA)  # was (board.SLC, board.SDA)
For the second, I modified beaglebone_black.py as follows, from...

Code: Select all

123    SDA = pin.I2C2_SDA  # P9_19
124    SCL = pin.I2C2_SCL  # P9_20
to...

Code: Select all

123    SDA1 = pin.I2C1_SDA  # P9_17
124    SCL1 = pin.I2C1_SCL  # P9_18
125    SDA2 = pin.I2C2_SDA  # P9_19
126    SCL2 = pin.I2C2_SCL  # P9_20
then I only had to modify my code as follows...

Code: Select all

i2c = busio.I2C(board.SCL1, board.SDA1)  # was (board.SLC, board.SDA)
Don

User avatar
dpancoe
 
Posts: 18
Joined: Thu Sep 06, 2012 10:28 am

Re: BBB and I2C Backpack, Use I2C1?

Post by dpancoe »

As a side note, since I am using the BeagleBone Black Industrial (extended temperature range, but otherwise the same), I had to add the following lines to board.py

Code: Select all

elif board_id == ap_board.BEAGLEBONE_BLACK_INDUSTRIAL:
    from adafruit_blinka.board.beaglebone_black import *

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: BBB and I2C Backpack, Use I2C1?

Post by drewfustini »

Could you raise a pull request to add the Industrial to Adafruit_Blinka like you did in your local version?

Thanks!

User avatar
dpancoe
 
Posts: 18
Joined: Thu Sep 06, 2012 10:28 am

Re: BBB and I2C Backpack, Use I2C1?

Post by dpancoe »

Done. Didn't push my other changes since those would create problems with other published code.

Don

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”