0

Understanding TCA9548A
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Understanding TCA9548A

by UncleT on Mon Nov 30, 2020 3:27 pm

I recently bought a TCA9548A breakout because I need to connect 2 I2C devices (SHT35 temp/humidity sensors), with the same address, to the I2C pins on my raspberry pi.
Ive managed to get the TCA9548A breakout working with my sensors and they are now reading independently using sample python libs adafruit_sht31d and adafruit_sht31d

My end goal is to create the same functionality using C# code (dotNet Core) so that I can integrate it into a larger project. In order for me to do this I need to understand the workings of TCA9548A and I2C more than I currently do.

Is there a way I can connect 2 led to the TCA9548A and control them independently, or will this not work because the leds dont implement the I2C interface? If this is possible code and wiring diagram would be great.

UncleT
 
Posts: 10
Joined: Thu Oct 29, 2020 3:45 am

Re: Understanding TCA9548A

by adafruit_support_bill on Mon Nov 30, 2020 3:51 pm

The multiplexer does not have any way to control LEDs specifically. It is just an i2c bus multiplexer. We do have i2c controlled LED displays: https://www.adafruit.com/?q=i2c+backpack&sort=BestMatch
You would need to send i2c commands directly to those devices to change what is displayed.

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding TCA9548A

by UncleT on Mon Jan 04, 2021 4:07 pm

Im picking up on this project again.

I have purchased a TCA9548A (from adafruit) and I have connected 2 x SHT35 temperature and humidity sensors (not from adafruit but they do implement the i2c interface)

TCA9548A has an address on the i2c bus of 0x70
Both of my SHT35 sensors have the same address on the i2c bus (0x44)

I have wired one of my sht35 to sd0 and sc0 on the TCA9548A and the other to sd1 and sc0

Im trying to write python code that will allow me to read from each sht35 independently but I'm struggling. I can see an example of using the multiplexer code with adafruit_tsl2591 at https://github.com/adafruit/Adafruit_Ci ... pletest.py

I can't work out from the code at the above url what I need to to do to satisfy my requirement.)


The sample code I have for reading data from sht35 is from https://github.com/OlivierdenOuden/Sensirion_SHT35

UncleT
 
Posts: 10
Joined: Thu Oct 29, 2020 3:45 am

Re: Understanding TCA9548A

by adafruit_support_bill on Mon Jan 04, 2021 4:47 pm

That library isn't designed to work with the multiplexer. You will probably have an easier time using this one: https://github.com/adafruit/Adafruit_Ci ... _sht31d.py

You can specify the multiplexer channel in the constructor the same way as is done with the tsl2591.

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding TCA9548A

by UncleT on Mon Jan 04, 2021 5:24 pm

Ive managed to get my sensors reading using the suggested library in conjunction with the adafruit_tca9548a library

Thanks


My code....

import time
import adafruit_sht31d
import adafruit_tca9548a
from busio import I2C
from board import SCL,SDA

i2c=I2C(SCL,SDA)
tca = adafruit_tca9548a.TCA9548A(i2c)

sht1 = adafruit_sht31d.SHT31D(tca[0])
sht2 = adafruit_sht31d.SHT31D(tca[1])

while 1:
print("Sensor #1: Temp: {}, RH: {}".format(sht1.temperature,sht1.relative_humidity))
print("Sensor #2: Temp: {}, RH: {}".format(sht2.temperature,sht2.relative_humidity))
print("-------------------------")
time.sleep(1)

UncleT
 
Posts: 10
Joined: Thu Oct 29, 2020 3:45 am

Re: Understanding TCA9548A

by adafruit_support_bill on Mon Jan 04, 2021 7:19 pm

Good to hear. Thanks for the update!

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.