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

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tomasApo
 
Posts: 2
Joined: Fri Oct 22, 2021 1:54 pm

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

Post by tomasApo »

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

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 136 times

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

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

i2c_bus = board.I2C()
ss = Seesaw(i2c_bus, addr=0x36)
rtc = adafruit_pcf8523.PCF8523(i2c_bus)
Dave

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

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

Post by tomasApo »

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!

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

Excellent!

Dave

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

Return to “Adafruit CircuitPython”