RP2350 I2C ports

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