I2C 4 Channel Mux TCA9545A Python Drivers Released for Raspberry Pi

4 Channel I2C Mux Breakout Board

I2C 4 Channel Mux TCA9545A Python Drivers Released for Raspberry Pi

4 Channel I2C Mux Breakout Board
4 Channel I2C Mux Breakout Board

The I2C 4 Channel Mux Breakout Board is a TCA9545A based quad bidirectional translating switch controlled via the I2C bus.  The SCL/SDA controlling fans out to four downstream channels.  It works for both the Arduino and Raspberry Pi.

At SwitchDoc Labs, we love data. And we love I2C devices. We like to gather the data using lots of I2C devices on our computers and projects. Project Curacao has a total of 12, WeatherPi has 11 devices and SunRover will have over 20 and will require one I2C bus just for controlling the motors. We are always running into conflicts with addressing on the I2C device. Since there are no standards, sometimes multiple devices will have the same address, such as 0x70 and you are just out of luck in running both of them on the same I2C bus without a lot of jimmy rigging.

What is the solution for this? It’s an I2C controlled 4 I2C bus multiplexer!

Python Raspberry Pi Software

The Raspberry Pi Python software for the TCA9545A I2C Mux is located on github at:  https://github.com/switchdoclabs/SDL_Pi_TCA9545.  To the left you can see the I2C Mux Breakout Board in the WeatherPi project fixing an I2C address conflict.

IMG_3245
I2C 4 Channel Mux TCA9545A Breakout Board Test Setup
I2C Mux Breakout Board in WeatherPi
I2C Mux Breakout Board in WeatherPi

The test setup includes an INA3221 Breakout Board connected to Bus 0 at address 0x40. The test program switches between each bus and then runs an I2C Bus scan (using “i2cdetect -y 1”) and prints out the results. Note that you see the INA3221 in Bus 0 and not in Bus 1-Bus 3.

Running the included test software on the Raspberry Pi gives you this display:



Test SDL_Pi_TCA9545 Version 1.0 - SwitchDoc Labs

Sample uses 0x73
Program Started at:2015-04-03 03:04:39

-----------BUS 0-------------------
addr = 0x73 returndata = 0xa1 
tca9545 control register B3-B0 = 0x1
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xa
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

-----------BUS 1-------------------
addr = 0x73 returndata = 0xe2 
tca9545 control register B3-B0 = 0x2
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xe
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

-----------BUS 2-------------------
addr = 0x73 returndata = 0xc4 
tca9545 control register B3-B0 = 0x4
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xc
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

-----------BUS 3-------------------
addr = 0x73 returndata = 0xa8 
tca9545 control register B3-B0 = 0x8
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xa
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

Test SDL_Pi_TCA9545 Version 1.0 - SwitchDoc Labs

Sample uses 0x73
Program Started at:2015-04-03 03:04:39

-----------BUS 0-------------------
addr = 0x73 returndata = 0xa1 
tca9545 control register B3-B0 = 0x1
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xa
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

-----------BUS 1-------------------
addr = 0x73 returndata = 0xe2 
tca9545 control register B3-B0 = 0x2
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xe
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

-----------BUS 2-------------------
addr = 0x73 returndata = 0xc4 
tca9545 control register B3-B0 = 0x4
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xc
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

-----------BUS 3-------------------
addr = 0x73 returndata = 0xa8 
tca9545 control register B3-B0 = 0x8
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0xa
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

-----------------------------------

 

2 Comments

  1. Hi,
    I have this i2C MUX board and I attached the AM2315 sensor to it. The AM2315 sensor works fine when attached to the Raspberry Pi GPIO pins. I run the testSDL_Pi_TCA9545.py script but it only show the 73 code for the board. I have the sensor attached to bus 0 with 4 wires (vcc, gnd, scl, sda). I know when I run it directly off the RPi I need to run i2cdetect twice quickly to see it – do I need to adjust the testSDL code in some way to see the sensor on bus 0?
    Thanks!

    • John,

      The AM2315 is generally not picked up by the i2cscanner on the Arduino or the Raspberry Pi. Here is what we suggest:

      If you don’t see it on your i2cdetect on the Raspberry Pi or I2C scanner on the Arduino, remember the following two things:

      1) Check your wiring. Note that the colors aren’t a reliable guide to what wire goes where. Make sure you read the label on the wires. I’m sure you have done this, but check it again. The colors vary from batch to batch.

      2) The AM2315 Outdoor temperature sensor is at address 0x5C. The manufacturer of the device puts the sensor into a sleep mode except when it is going to be used to avoid self heating of the sensor. That makes sense, however, it means you have to go through a funny sequence to make sure the device is awake and responding. It doesn’t respond to an Arduino I2C scan nor a Raspberry Pi I2C scan, i2cdetect.

      The best thing to do to determine if it is actually there is run the test software and see if you are getting data. That is how we detect if it is present.

      https://github.com/switchdoclabs/Pi_AM2315

      SDL

Comments are closed.