The Pico has two I2C hardware controllers. Each controller can talk to multiple IIC devices as long as all the devices communicating on each controller have distinct addresses.
I2C0 SDA are on GPIOs 0, 4, 8, 12, 16 and 20
I2C0 SCL are on GPIOs 1, 5, 9, 13, 17 and 21
I2C1 SDA are on GPIOs 2, 6, 10, 14, 18 and 26
I2C1 SCL are on GPIOs 3, 7, 11, 15, 19 and 27
I2C Scanner for I2C 0
1 2 3 4 5 6 7 8 9101112131415161718
importmachineI2C_SDA_PIN=0I2C_SCL_PIN=1i2c=machine.I2C(0,sda=machine.Pin(I2C_SDA_PIN),scl=machine.Pin(I2C_SCL_PIN),freq=400000)print('Scanning I2C bus.')devices=i2c.scan()# this returns a list of devicesdevice_count=len(devices)ifdevice_count==0:print('No i2c device found.')else:print(device_count,'devices found.')fordeviceindevices:print('Decimal address:',device,", Hex address: ",hex(device))
importmachineI2C0_SDA_PIN=0I2C0_SCL_PIN=1I2C1_SDA_PIN=2I2C1_SCL_PIN=3i2c0=machine.I2C(0,sda=machine.Pin(I2C0_SDA_PIN),scl=machine.Pin(I2C0_SCL_PIN),freq=400000)i2c1=machine.I2C(1,sda=machine.Pin(I2C1_SDA_PIN),scl=machine.Pin(I2C1_SCL_PIN),freq=400000)print('Scanning I2C bus 0.')devices=i2c0.scan()# this returns a list of devicesdevice_count=len(devices)ifdevice_count==0:print('No i2c device found on bus 0.')else:print(device_count,'devices found.')fordeviceindevices:print('Decimal address:',device,", Hex address: ",hex(device))print('Scanning I2C bus 1.')devices=i2c1.scan()# this returns a list of devicesdevice_count=len(devices)ifdevice_count==0:print('No i2c device found on bus 1.')else:print(device_count,'devices found.')fordeviceindevices:print('Decimal address:',device,", Hex address: ",hex(device))
Results for both a OLED display on I2C 0 and a time-of-flight sensor on I2C 1