# Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

## Overview

Primary: Also see the guide on the Adafruit PCA9548 which is TCA9548A compatible and has Stemma QT ports for I2C.

### Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer - Overview

[Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer)
[Overview](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/overview)
![](https://cdn-learn.adafruit.com/assets/assets/000/027/695/medium800/adafruit_products_2717_iso_ORIG.jpg?1442011540)

You just found the perfect I2C sensor, and you want to wire up two or three or more of them to your Arduino when you realize "Uh oh, this chip has a fixed I2C address, and from what I know about I2C, you cannot have two devices with the same address on the same SDA/SCL pins!" Are you out of luck? You would be, if you didn't have this ultra-cool **TCA9548A 1-to-8 I2C multiplexer!**

![](https://cdn-learn.adafruit.com/assets/assets/000/027/696/medium800/adafruit_products_2717_kit_ORIG.jpg?1442011561)

Finally, a way to get up to 8 same-address I2C devices hooked up to one microcontroller - this multiplexer acts as a gatekeeper, shuttling the commands to the selected set of I2C pins with your command.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/697/medium800/adafruit_products_2717_quarter_ORIG.jpg?1442011572)

Using it is fairly straight-forward: the multiplexer itself is on I2C address 0x70 (but can be adjusted from 0x70 to 0x77) and you simply write a single byte with the desired multiplexed output number to that port, and bam - any future I2C packets will get sent to that port. In theory, you could have 8 of these multiplexers on each of 0x70-0x77 addresses in order to control 64 of the same-I2C-addressed-part.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/698/medium800/adafruit_products_Metro_Sensor_Demo_kitjk_ORIG.jpg?1442011589)

Like all Adafruit breakouts, we put this nice chip on a breakout for you so you can use it on a breadboard with capacitors, and pullups and pulldowns to make usage a snap. Some header is required and once soldered in you can plug it into a solderless-breadboard. The chip itself is 1.8V - 5V compliant so you can use it with any logic level.

# Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/027/663/medium800/adafruit_products_2717_top_ORIG.jpg?1442001787)

## Power Pins:

- **Vin** - this is the power pin. Since the sensor chip uses 3-5 VDC. To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V micro like Arduino, use 5V
- **GND** - common ground for power and logic

## I2C Control-Side pins:

- **SCL** - this is the I2C clock pin for the chip itself, connect to your microcontrollers I2C clock line.
- **SDA** - this is the I2C data pin for the chip itself, connect to your microcontrollers I2C data line.
- **RST** - this is the reset pin, for resetting the multiplexer chip. Pulled high by default, connect to ground to reset.

## I2C Address Selection

The default I2C address is&nbsp; **0x70**.

- **A0**  **A1 A2** - these are the address selection pins _for the multiplexer_. By default the multiplexer is at address **0x70** and these three pins are pulled low. Connect them to **Vin** to set the address to **0x71** - **0x77**.
- **A0** is the lowest-significant bit (if it is pulled high, it will increase the address by 1).
- **A1** is the 2nd-lowest-significant bit (if it is pulled high, it will increase the address by 2).
- **A2** is the 3rd-lowest-significant bit (if it is pulled high, it will increase the address by 4).

The default I2C address is&nbsp; **0x70**. The other address options can be calculated by “adding” the **A**** 0/A1/A2 **&nbsp;to the base of&nbsp;** 0x70**.

**A0** &nbsp;sets the lowest bit with a value of&nbsp; **1** , **A**** 1 **&nbsp;sets the next bit with a value of&nbsp;** 2&nbsp; **and** A ****2** &nbsp;sets the next bit with a value of&nbsp; **4.&nbsp;** The final address is&nbsp; **0x70 + A2 + A1 + A0** &nbsp;which would be&nbsp; **0x77**.

 So for example if **A**** 2 **&nbsp;is wired to power and** A ****0** &nbsp;is soldered closed, the address is&nbsp; **0x70 + 4 + 1 = 0x75**.

 If only **A**** 0 **&nbsp;is wired to power, the address is&nbsp;** 0x70 + 1 = 0x71**

 If only **A1** &nbsp;is wired to power, the address is&nbsp; **0x70 + 2 = 0x72**

 If only **A**** 2 **&nbsp;is wired to power, the address is&nbsp;** 0x70 + 4 = 0x74**

The table below shows all possible addresses, and whether the pin(s) should be high/H (wired to power) or low/L (unconnected).

![](https://cdn-learn.adafruit.com/assets/assets/000/129/868/medium800/adafruit_products_stemma-circuit.jpg?1715108684)

## I2C Multiplexed-Side pins:

- **SDx** and **SCx** :&nbsp; There are 8 sets of **SDx** and **SCx** pins, from **SD0/SC0** to **SD7/SC7**. These are the multiplexed pins. Each one is a completely seperate I2C bus set. So you can have 8 I2C devices with identical addresses, as long as they are on one I2C bus each.   
_These pins do not have any pullups installed, so if you are using a chip or breakout without i2c pullups be sure to add them!_ Nicely, you can have **Vin** be 3.3V and have these pins pulled up to 5V (that is, they are 5V compliant)

# Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/027/654/medium800/adafruit_products_2717_kit_ORIG.jpg?1442000534)

## Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - **long pins down**

![adafruit_products_headers.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/655/medium640/adafruit_products_headers.jpg?1442000545)

## Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

![adafruit_products_place.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/656/medium640/adafruit_products_place.jpg?1442000558)

## And Solder!

Be sure to solder all pins for reliable electrical contact.  
  
_(For tips on soldering, be sure to check out our_ [_Guide to Excellent Soldering_](http://learn.adafruit.com/adafruit-guide-excellent-soldering)_)._

![adafruit_products_solder1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/657/medium640/adafruit_products_solder1.jpg?1442000569)

![adafruit_products_solder2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/658/medium640/adafruit_products_solder2.jpg?1442000576)

![adafruit_products_solder3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/659/medium640/adafruit_products_solder3.jpg?1442000580)

![adafruit_products_solder4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/660/medium640/adafruit_products_solder4.jpg?1442000584)

![adafruit_products_solder5.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/661/medium640/adafruit_products_solder5.jpg?1442000603)

You're done! Check your solder joints visually and continue onto the next steps

![adafruit_products_done.jpg](https://cdn-learn.adafruit.com/assets/assets/000/027/662/medium640/adafruit_products_done.jpg?1442001745)

# Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

## Arduino Wiring & Test

Also see [the guide](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino) on the Adafruit PCA9548 which is TCA9548A compatible and has Stemma QT ports for I2C.

### Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer - Arduino

[Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer)
[Arduino](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino)
The TCA9548A multiplexer is interesting in that it has an I2C address (0x70 by default) - and you basically send it a command to tell it which I2C multiplexed output you want to talk to, then you can address the board you want to address.

We suggest using this little helper to help you select the port

```auto
#define TCAADDR 0x70

void tcaselect(uint8_t i) {
  if (i &gt; 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 &lt;&lt; i);
  Wire.endTransmission();  
}

```

You can then call tcaselect(0) thru tcaselect(7) to set up the multiplexer.

Note that you if you happen to have I2C devices with I2C address 0x70, you will need to short one of the **Addr** pins on the TCA9548 breakout to **Vin** in order to make it not conflict. Given that you can have 0x70 thru 0x77, just find one that's free and you're good to go!

# Example Multiplexing

For example, say we want to talk to two HMC5883 breakouts. These magnetometers have a fixed address of **0x1E** so you cannot have two on one I2C bus. Wire up the TCA9548 breakout so that:

- **Vin** is connected to **5V** (on a 3V logic Arduino/microcontroller, use **3.3V** )
- **GND** to ground
- **SCL** to I2C clock
- **SDA** to I2C data

Then wire up each of the other sensor breakouts to **Vin** , **Ground** and use one of the **SC_n_** / **SD** _ **n** _ multiplexed buses:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/690/medium800/adafruit_products_Metro_Sensor_Demo_kitjk_ORIG.jpg?1442009395)

On an Arduino, which is what we're using, we suggest running this handy scanner script which will tell you what the breakout detected

```cpp
/**
 * TCA9548 I2CScanner.ino -- I2C bus scanner for Arduino
 *
 * Based on https://playground.arduino.cc/Main/I2cScanner/
 *
 */

#include "Wire.h"

#define TCAADDR 0x70

void tcaselect(uint8_t i) {
  if (i &gt; 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 &lt;&lt; i);
  Wire.endTransmission();  
}


// standard Arduino setup()
void setup()
{
    while (!Serial);
    delay(1000);

    Wire.begin();
    
    Serial.begin(115200);
    Serial.println("\nTCAScanner ready!");
    
    for (uint8_t t=0; t&lt;8; t++) {
      tcaselect(t);
      Serial.print("TCA Port #"); Serial.println(t);

      for (uint8_t addr = 0; addr&lt;=127; addr++) {
        if (addr == TCAADDR) continue;

        Wire.beginTransmission(addr);
        if (!Wire.endTransmission()) {
          Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
        }
      }
    }
    Serial.println("\ndone");
}

void loop() 
{
}
```

For example, running it on the above setup will give you:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/691/medium800/adafruit_products_Untitled.png?1442009916)

Next up you will have to adjust whatever code you have to select the correct multiplexed port!

Make sure before you query from the sensor that you call **tcaselect** to get the right one

```auto
#include &lt;Wire.h&gt;
#include &lt;Adafruit_Sensor.h&gt;
#include &lt;Adafruit_HMC5883_U.h&gt;

#define TCAADDR 0x70

/* Assign a unique ID to this sensor at the same time */
Adafruit_HMC5883_Unified mag1 = Adafruit_HMC5883_Unified(1);
Adafruit_HMC5883_Unified mag2 = Adafruit_HMC5883_Unified(2);

void displaySensorDetails(Adafruit_HMC5883_Unified *mag)
{
  sensor_t sensor;
  mag-&gt;getSensor(&amp;sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" uT");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" uT");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" uT");  
  Serial.println("------------------------------------");
  Serial.println("");
  delay(500);
}

void tcaselect(uint8_t i) {
  if (i &gt; 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 &lt;&lt; i);
  Wire.endTransmission();  
}


void setup(void) 
{
  Serial.begin(9600);
  Serial.println("HMC5883 Magnetometer Test"); Serial.println("");
  
  /* Initialise the 1st sensor */
  tcaselect(2);
  if(!mag1.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Ooops, no HMC5883 detected ... Check your wiring!");
    while(1);
  }
  
  /* Initialise the 2nd sensor */
  tcaselect(6);
  if(!mag2.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Ooops, no HMC5883 detected ... Check your wiring!");
    while(1);
  }
  
  /* Display some basic information on this sensor */
  tcaselect(2);
  displaySensorDetails(&amp;mag1);
  tcaselect(6);
  displaySensorDetails(&amp;mag2);
}

void loop(void) 
{
  /* Get a new sensor event */ 
  sensors_event_t event; 
  
  tcaselect(2);
  mag1.getEvent(&amp;event);
 
  /* Display the results (magnetic vector values are in micro-Tesla (uT)) */
  Serial.print("Sensor #1 - ");
  Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print("  ");Serial.println("uT");
  
  tcaselect(6);
  mag2.getEvent(&amp;event);
  /* Display the results (magnetic vector values are in micro-Tesla (uT)) */
  Serial.print("Sensor #2 - ");
  Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print("  ");Serial.println("uT");
  
  delay(500);
}
```

However, once you add all the **tcaselect()**'s you will be able to talk to both sensors!

## Multiple Multplexers

Since the&nbsp;TCA9548 is addressible, you can have more than one multiplexer on the bus. &nbsp;With 8 possible adresses, that means you can control as many as 64 separate i2c buses.&nbsp;

To avoid conflict between devices with the same address on different multiplexers, you can disable all channels on a multiplexer with the following code:

```auto
Wire.beginTransmission(TCAADDR1);
Wire.write(0);  // no channel selected
Wire.endTransmission();
```

# Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

## CircuitPython & Python

Also see [the guide](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/circuitpython-python) on the Adafruit PCA9548 which is TCA9548A compatible and has Stemma QT ports for I2C.

### Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer - CircuitPython & Python

[Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer)
[CircuitPython & Python](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/circuitpython-python)
It's easy to use the **T**** CA9548A**&nbsp;with Python or CircuitPython, and the&nbsp;[Adafruit\_CircuitPython\_TCA9548A](https://github.com/adafruit/Adafruit_CircuitPython_TCA9548A) module. This module allows you to easily write Python code that allows you to multiplex up to 8 STEMMA boards with the**T ****CA9548A&nbsp;** I2C multiplexer. You can use this multiplexer with any CircuitPython microcontroller board or with a computer that has GPIO and Python&nbsp;[thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

If you're curious why you'd need an I2C multiplexer, be sure to&nbsp;[check out this guide](https://learn.adafruit.com/working-with-multiple-i2c-devices)&nbsp;that goes in depth on working with&nbsp;_ **multiple** _&nbsp;copies of the same I2C device, which most likely have the&nbsp; **same I2C address**.

[Working with Multiple Same Address I2C Devices Learn Guide](https://learn.adafruit.com/working-with-multiple-i2c-devices)
## CircuitPython Microcontroller Wiring

First, wire up a TCA9548A to your board exactly as shown below. Here's an example of wiring a Feather M4 to the TCA9548A with I2C using one of the handy&nbsp;[**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;connectors. Then, plug two TSL2591 STEMMA boards into the TCA9548A via STEMMA plug 0 and STEMMA plug 1:

- **Board 3V** &nbsp;to&nbsp;**mux VIN (red wire)**
- **Board GND** &nbsp;to&nbsp; **mux**** &nbsp;GND (black wire)**
- **Board SCL** &nbsp;to&nbsp; **mux**** &nbsp;SCL (yellow wire)**
- **Board SDA** &nbsp;to&nbsp; **mux**** &nbsp;SDA (blue wire)**

&nbsp;

- **TSL2591 1 SDA** to **mux SD0**
- **TSL2591 1 SCL** to **mux SC0**
- **TSL2591 1 VIN** to **mux VIN**
- **TSL2591 1 GND** to **mux GND**

&nbsp;

- **TSL2591 2 SDA** to **mux SD1**
- **TSL2591 2 SDA** to **mux SC1**
- **TSL2591 2 VIN** to **mux VIN**
- **TSL2591 2 GND** to **mux GND**

![adafruit_products_TCA_featherStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/115/985/medium640/adafruit_products_TCA_featherStemma_bb.png?1666184574)

You can also use standard&nbsp; **0.100" pitch** &nbsp;headers to wire it up on a breadboard:

- **Board 3V** &nbsp;to&nbsp;**mux VIN (red wire)**
- **Board GND** &nbsp;to&nbsp; **mux**** &nbsp;GND (black wire)**
- **Board SCL** &nbsp;to&nbsp; **mux**** &nbsp;SCL (yellow wire)**
- **Board SDA** &nbsp;to&nbsp; **mux**** &nbsp;SDA (blue wire)**

&nbsp;

- **TSL2591 1 SDA** to **mux SD0**
- **TSL2591 1 SCL** to **mux SC0**
- **TSL2591 1 VIN** to **mux VIN**
- **TSL2591 1 GND** to **mux GND**

&nbsp;

- **TSL2591 2 SDA** to **mux SD1**
- **TSL2591 2 SDA** to **mux SC1**
- **TSL2591 2 VIN** to **mux VIN**
- **TSL2591 2 GND** to **mux GND**

![adafruit_products_TCA_featherBB_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/115/986/medium640/adafruit_products_TCA_featherBB_bb.png?1666184776)

## Python Computer Wiring

Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired to the I2C multiplexer using I2C and a&nbsp;[**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;connector:

- **Pi 3V** &nbsp;to&nbsp;**mux VIN (red wire)**
- **Pi GND** &nbsp;to&nbsp; **mux**** &nbsp;GND (black wire)**
- **Pi SCL** &nbsp;to&nbsp; **mux**** &nbsp;SCL (yellow wire)**
- **Pi SDA** &nbsp;to&nbsp; **mux**** &nbsp;SDA (blue wire)**

- **TSL2591 1 SDA** to **mux SD0**
- **TSL2591 1 SCL** to **mux SC0**
- **TSL2591 1 VIN** to **mux VIN**
- **TSL2591 1 GND** to **mux GND**

&nbsp;

- **TSL2591 2 SDA** to **mux SD1**
- **TSL2591 2 SDA** to **mux SC1**
- **TSL2591 2 VIN** to **mux VIN**
- **TSL2591 2 GND** to **mux GND**

![adafruit_products_TCA_piStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/115/987/medium640/adafruit_products_TCA_piStemma_bb.png?1666184811)

Finally here is an example of how to wire up a Raspberry Pi to the I2C multiplexer using a solderless breadboard:

- **Pi 3V** &nbsp;to&nbsp;**mux VIN (red wire)**
- **Pi GND** &nbsp;to&nbsp; **mux**** &nbsp;GND (black wire)**
- **Pi SCL** &nbsp;to&nbsp; **mux**** &nbsp;SCL (yellow wire)**
- **Pi SDA** &nbsp;to&nbsp; **mux**** &nbsp;SDA (blue wire)**

- **TSL2591 1 SDA** to **mux SD0**
- **TSL2591 1 SCL** to **mux SC0**
- **TSL2591 1 VIN** to **mux VIN**
- **TSL2591 1 GND** to **mux GND**

&nbsp;

- **TSL2591 2 SDA** to **mux SD1**
- **TSL2591 2 SDA** to **mux SC1**
- **TSL2591 2 VIN** to **mux VIN**
- **TSL2591 2 GND** to **mux GND**

![adafruit_products_TCA_piBB_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/115/988/medium640/adafruit_products_TCA_piBB_bb.png?1666184836)

## Python Installation of TCA9548A Library

You'll need to install the&nbsp; **Adafruit\_Blinka** &nbsp;library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.&nbsp;[Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `sudo pip3 install adafruit-circuitpython-tca9548a`

If your default Python is version 3, you may need to run&nbsp;`pip`&nbsp;instead. Make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## CircuitPython Usage

To use with CircuitPython, you need to first install the TCA9548A library, and its dependencies, into the&nbsp; **lib** &nbsp;folder on your&nbsp; **CIRCUITPY** &nbsp;drive. Then you need to update&nbsp; **code.py** &nbsp;with the example script.

Thankfully, we can do this in one go. In the example below, click the&nbsp; **Download Project Bundle** &nbsp;button below to download the necessary libraries and the&nbsp; **code.py** &nbsp;file in a zip file. Extract the contents of the zip file, and copy the&nbsp; **entire&nbsp;**** lib **&nbsp;** folder **&nbsp;and the&nbsp;** code.py **&nbsp;file to your&nbsp;** CIRCUITPY**&nbsp;drive.

Your&nbsp; **CIRCUITPY/lib** &nbsp;folder should contain the following folders and file:

- **adafruit\_bus\_device/**
- **adafruit\_tca9548a.mpy**
- **adafruit\_tsl2591.mpy**

![CIRCUITPY](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/tca9584a_tca9548a_multisensor.py.png )

## Python Usage

Once you have the library&nbsp;`pip3`&nbsp;installed on your computer, copy or download the following example to your computer, and run the following, replacing&nbsp; **code.py** &nbsp;with whatever you named the file:

`python3 code.py`

## Simple Test Example Code
https://github.com/adafruit/Adafruit_CircuitPython_TCA9548A/blob/main/examples/tca9548a_simpletest.py

 **If running CircuitPython:** &nbsp;Once everything is saved to the&nbsp; **CIRCUITPY** &nbsp;drive,&nbsp;[connect to the serial console](https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console)&nbsp;to see the data printed out!

**If running Python:&nbsp;** The console output will appear wherever you are running Python.

![](https://cdn-learn.adafruit.com/assets/assets/000/115/975/medium800/components_replSimple.jpg?1666109444)

In this simple test for the TCA9548A, an I2C scan is performed for all eight of its ports. If any devices are connected, then the I2C address will be printed to the REPL next to the channel number. If no device is connected, then the port will print with empty brackets (`[]`).

## Multi-Sensor Example Code
https://github.com/adafruit/Adafruit_CircuitPython_TCA9548A/blob/main/examples/tca9548a_multisensor.py

In the multi-sensor example, the TCA9548A is used as an I2C multiplexer with two TSL2591 light sensors. When the connected sensors are instantiated over I2C, the I2C pins declared are the ports from `0` and `1` on the TCA9548A.

In the example, the first TSL2591 light sensor, instantiated as `tsl1`, is plugged into port 0 (`tca[0]`) and the second TSL2591 light sensor, instantiated as `tsl2`, is plugged into port 1 (`tca[1]`).

```python
# Create the TCA9548A object and give it the I2C bus
tca = adafruit_tca9548a.TCA9548A(i2c)

# For each sensor, create it using the TCA9548A channel instead of the I2C object
tsl1 = adafruit_tsl2591.TSL2591(tca[0])
tsl2 = adafruit_tsl2591.TSL2591(tca[1])
```

In the loop, the readings from the two light sensors are printed to the REPL every `0.1` seconds.&nbsp;

```python
while True:
    print(tsl1.lux, tsl2.lux)
    time.sleep(0.1)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/115/976/medium800/components_multiSensorREPL.jpg?1666110088)

# Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout

## Downloads

# Datasheets

- [TCA9548A datasheet](http://www.adafruit.com/datasheets/tca9548a.pdf)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-TCA9548A-I2C-Multiplexer-PCB)

# Schematic

Click to embiggen

![](https://cdn-learn.adafruit.com/assets/assets/000/027/693/medium800/adafruit_products_schem.png?1442010910)

# Fabrication Print

Dimensions in Inches

![](https://cdn-learn.adafruit.com/assets/assets/000/027/694/medium800/adafruit_products_pting.png?1442011021)


## Featured Products

### TCA9548A I2C Multiplexer

[TCA9548A I2C Multiplexer](https://www.adafruit.com/product/2717)
You just found the perfect I2C sensor, and you want to wire up two or three or more of them to your Arduino when you realize "Uh oh, this chip has a fixed I2C address, and from what I know about I2C, you cannot have two devices with the same address on the same SDA/SCL pins!" Are you...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2717)
[Related Guides to the Product](https://learn.adafruit.com/products/2717/guides)

## Related Guides

- [How to Scan and Detect I2C Addresses](https://learn.adafruit.com/scanning-i2c-addresses.md)
- [Working with Multiple Same Address I2C Devices](https://learn.adafruit.com/working-with-multiple-i2c-devices.md)
- [MIDI Laser Harp with Time of Flight Distance Sensors](https://learn.adafruit.com/midi-laser-harp-time-of-flight-sensors.md)
- [I2C Addresses and Troublesome Chips](https://learn.adafruit.com/i2c-addresses.md)
- [Working with I2C Devices](https://learn.adafruit.com/working-with-i2c-devices.md)
- [Introducing Bluefruit EZ-Link Breakout](https://learn.adafruit.com/introducing-bluefruit-ez-link.md)
- [Adafruit VEML7700 Ambient Light Sensor](https://learn.adafruit.com/adafruit-veml7700.md)
- [Adafruit I2C QT Rotary Encoder](https://learn.adafruit.com/adafruit-i2c-qt-rotary-encoder.md)
- [Facial Detection and Recognition with MEMENTO](https://learn.adafruit.com/facial-detection-and-recognition-with-memento.md)
- [Adafruit LSM6DS33 6-DoF IMU Breakout](https://learn.adafruit.com/lsm6ds33-6-dof-imu-accelerometer-gyro.md)
- [Adafruit Sparkle Motion Stick](https://learn.adafruit.com/adafruit-sparkle-motion-stick.md)
- [Adafruit LiIon or LiPoly Charger BFF Add-On for QT Py](https://learn.adafruit.com/adafruit-qt-py-charger-bff.md)
- [Butterfly Bench with Edge Lit Acrylic](https://learn.adafruit.com/butterfly-bench-with-edge-lit-acrylic.md)
- [Adafruit Bluefruit LE Shield](https://learn.adafruit.com/adafruit-bluefruit-le-shield.md)
- [Adafruit BrainCraft HAT - Easy Machine Learning for Raspberry Pi](https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi.md)
