RP2350 I2C ports

I got my hands on some Xiao RP2350 boards and I am looking to use them with the Grove VL53L0X ToF sensors. I just spent several hours trying to get the RP2350 to even recognize the sensor. I’ve tried multiple different I2C sensors, other dev boards and even using the Grove Base and Grove Expansion Base. It wasn’t until a little more research that I realized that the main I2C ports (SCL0/SDA0) are broken out on the bottom, which is extremely odd for a board that is mad to be surface mounted, but I digress…
In some of the example Arduino sketches for the Grove ToF sensor, I don’t see where to change it so that is uses SDA1//SCL1.

So my question is, how do I get these boards to use the secondary I2C ports? (using the primary ones on the bottom are not an option for this particular project as they will be surface mounted.

Hi there,

So I would try something like this,

import board
import busio

# Use default pins (e.g., GPIO20/GPIO21 on Metro RP2350)
i2c = board.I2C()

# Or, define custom pins (e.g., GPIO6 for SDA, GPIO7 for SCL)
# The pins must be valid for the same I2C peripheral instance (I2C1 in this case)
# i2c = busio.I2C(scl=board.GP7, sda=board.GP6) 
import board
import busio

# Define the I2C bus using the specific GPIO pins
# GPIO16 is board.GP16, GPIO17 is board.GP17
# Ensure both pins belong to the same I2C peripheral (I2C0 in this case)
i2c = busio.I2C(scl=board.GP17, sda=board.GP16)

# Now you can use the i2c object to scan for devices or communicate
while not i2c.try_lock():
    pass

# Use the i2c bus
print("I2C devices found:", [hex(i) for i in i2c.scan()])

i2c.unlock()

HTH
GL :slight_smile: PJ :v:

// Wire
#define __WIRE0_DEVICE (i2c0)
#define PIN_WIRE0_SDA  (16u)
#define PIN_WIRE0_SCL  (17u)
#define SDA            PIN_WIRE0_SDA
#define SCL            PIN_WIRE0_SCL
#define I2C_SDA        (SDA)
#define I2C_SCL        (SCL)

#define __WIRE1_DEVICE (i2c1)
#define PIN_WIRE1_SDA  (6u)
#define PIN_WIRE1_SCL  (7u)

also have a look at this Thread , it’s very good.

1 Like