questions about adding several I2C boards to a PICO/W

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
quinn123
 
Posts: 27
Joined: Tue Oct 25, 2022 3:43 pm

questions about adding several I2C boards to a PICO/W

Post by quinn123 »

Hi,
Most demos I've come across only use one I2C board at a time, so I'm a bit confused on the number of I2C sda,scl pairs on the PICO board vs the number of of pairs that can be used at the same time. It seems that I can have only 2 pairs in use because there are two hardware modules on the PICO (id=0 and id=1).So then I can not attach to the I2C type boards to the other pins labled I2C. Is this correct?

However to get more than two I2C boards (not the same type), I can daisy chain them together. Is this correct? What precautions such as additional resisters should I use in this case?

When daisy chaining boards, is it better to take power from the previous board, or take power directly from the breadboard separately for each board (the first board is wired to the breadboard which is powered from the PICO). Should resistors be used? if so where?

For those wanting to use different multiple boards, below is micropython code.

#Below is code to attach two boards directly to the PICO (not daisy chain)
from machine import Pin, I2C
from clPCF8575 import PCF8575
from pca import PCA9685
from led import LED # this calls PCA9685
import utime
import time
sda=Pin(0)
scl=Pin(1)
id=0
i2c=I2C(id=id,sda=sda,scl=scl)
print("output for i2c:"+ str(i2c)+ "scan: "+str(i2c.scan()))

id1=1
sda1=Pin(14)
scl1=Pin(15)
i2c1=I2C(id=id1,sda=sda1,scl=scl1)
print("output for i2c1:"+ str(i2c1)+ "scan: "+str(i2c1.scan()))

###################################################
#below is code to daisy chain two boards. I use PCA9685 and PCF8575 here.
from machine import Pin, I2C
from clPCF8575 import PCF8575
from pca import PCA9685
from led import LED # calls PCA9685
import utime
import time

id1=0
sda1=Pin(12)
scl1=Pin(13)
i2c1=I2C(id=id1,sda=sda1,scl=scl1)
print("output for i2c1:"+ str(i2c1)+ "scan: "+str(i2c1.scan()))
led=LED(i2c=i2c1)
led.power(12,400) # turn on

pcf=PCF8575(i2c=i2c1)
pcf.pin(16,0) #turn on

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: questions about adding several I2C boards to a PICO/W

Post by mikeysklar »

When chaining boards on the i2c bus you will want to make sure you can supply enough current and that the addresses are unique. You normally do not need to deal with resistors.

Adafruit just introduced a 5 port stemma hub which is ideal for what you are suggesting.

https://www.adafruit.com/product/5625

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

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”