Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

"ValueError: SCL in use" how to connect multiple I2C address
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

"ValueError: SCL in use" how to connect multiple I2C address

by tomasApo on Fri Oct 22, 2021 2:33 pm

Hello everyone,

I'm so close to completing my Basil project but I'm stuck because of the Adalogger FeatherWing & STEMMA Soil Sensor. They are both using the I2C bus...
I am unsure how to make these both work. From my research in I2C I can have multiple sensors connected but I have no clue where to go from here. One is using "board" the other "busio"

[component list] FeatherS2, Adalogger FeatherWing, STEMMA Soil Sensor. [/component list]

Code: Select all | TOGGLE FULL SIZE
i2c_bus = board.I2C()
ss = Seesaw(i2c_bus, addr=0x36)

myI2C = busio.I2C(board.SCL, board.SDA)
rtc = adafruit_pcf8523.PCF8523(myI2C)
Attachments
IMG_4891.jpg
IMG_4891.jpg (1001.68 KiB) Viewed 80 times

tomasApo
 
Posts: 2
Joined: Fri Oct 22, 2021 1:54 pm

Re: "ValueError: SCL in use" how to connect multiple I2C add

by dastels on Fri Oct 22, 2021 3:06 pm

You can only create a single I2C bus object on a given SCL/SDA pair. Using board.I2C() is the best way since it caches the object and will only create one using the board's SCL and SDA pins.

Try:
Code: Select all | TOGGLE FULL SIZE
i2c_bus = board.I2C()
ss = Seesaw(i2c_bus, addr=0x36)
rtc = adafruit_pcf8523.PCF8523(i2c_bus)


Dave

dastels
 
Posts: 7871
Joined: Tue Oct 20, 2015 3:22 pm

Re: "ValueError: SCL in use" how to connect multiple I2C add

by tomasApo on Tue Oct 26, 2021 1:43 pm

Amazing Dave. Project is now fully working!
:)
Thank you for the help. Also now I can remove the busio library as that is no longer needed!

tomasApo
 
Posts: 2
Joined: Fri Oct 22, 2021 1:54 pm

Re: "ValueError: SCL in use" how to connect multiple I2C add

by dastels on Tue Oct 26, 2021 2:17 pm

Excellent!

Dave

dastels
 
Posts: 7871
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.


cron