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

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/123/211/medium800/components_5626-06.jpg?1690985570)

You just found the perfect I2C sensor, available in a handy chainable&nbsp;[**Qwiic, or STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;package, and you want to wire up two or three or more of them to your microcontroller 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&nbsp; **Adafruit PCA9548 8 Channel STEMMA QT / Qwiic I2C Multiplexer**!

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 I2C port with your command.

![](https://cdn-learn.adafruit.com/assets/assets/000/123/212/medium800/components_5626-05.jpg?1690985583)

**In case you're wondering why this uses the PCA9548A not the&nbsp;[TCA9548A](https://www.adafruit.com/product/2717)**,&nbsp;the PCA9548 is the 'fraternal twin sister' of the TCA9548 but is easier to get during the great&nbsp;chip shortage of 2022. It works exactly the same, just can't go down to 1.8V power which is OK because QT boards are 3V or 5V only anyways.&nbsp;[You can still use any example code or library for the TCA9548](https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/overview)

![](https://cdn-learn.adafruit.com/assets/assets/000/123/213/medium800/components_5626-02.jpg?1690985599)

Using it is fairly straight-forward: the multiplexer itself is on I2C address 0x70 (but can be adjusted from 0x70 to 0x77 using jumpers on the back) 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/123/214/medium800/components_5626-03.jpg?1690985611)

The&nbsp; **Adafruit STEMMA QT / Qwiic PCA9548A Mux Breakout - 8 Channel** &nbsp;has eight JST SH 1mm connectors in two rows of four, all with the power, ground, and SDA/SCL pins connected. There's one port at the end that connects to your I2C controller (there are&nbsp;also breadboard breakout pins if you need them). Use this breakout to add as many I2C devices to the bus as you need. Complete with mounting holes so the board can be added to any system. A small power LED lets you know that the hub board has connectivity.

![](https://cdn-learn.adafruit.com/assets/assets/000/123/215/medium800/components_5626-04.jpg?1690985622)

There's even an onboard 3.3V 500mA regulator, so if you're using this with a 5V microcontroler like an Arduino 328-compatible, you can level shift all the QT ports to have 3V power and logic level.

Of course, because&nbsp;[STEMMA QT is Qwiic compatible](https://learn.adafruit.com/introducing-adafruit-stemma-qt), it will&nbsp;[work with any and all STEMMA QT or Qwiic&nbsp;boards and parts we have in the Adafruit shop](https://www.adafruit.com/?q=stemma%20qt).

Comes with only the assembled PCB, no&nbsp;[cables or sensors included (we have tons available though!)](http://learn.adafruit.com/introducing-adafruit-stemma-qt)

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

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/115/950/medium800/components_front_back.jpg?1666043139)

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

## Power Pins

- **V+** &nbsp;- this is the power pin. Since the multiplexer 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  
This connection is shared with the STEMMA QT port on the opposite side of the board.
- **-** &nbsp;- common ground for power and logic.  
This connection is shared with the STEMMA QT port on the opposite side of the board.

## Vlogic Switch

- **Vlogic** - this switch selects between supplying the 8 STEMMA QT ports with either the incoming voltage on **V+** (3-5 VDC) or level shifting to 3.3V 500mA (labeled **3V** ). For example, if you're using this with a 5V microcontroller like an Arduino 328-compatible, you can level shift all the QT ports to have 3V power and logic level.

## I2C Logic Pins - Control

- **SCL**** &nbsp; **- I2C clock pin, connect to your microcontroller I2C clock line. This pin is level shifted so you can use 3-5V logic, and there's a&nbsp;** 10K pullup**&nbsp;on this pin. This connection is shared with the STEMMA QT port on the opposite side of the board.
- **SDA**** &nbsp; **- I2C data pin, connect to your microcontroller I2C data line. This pin is level shifted so you can use 3-5V logic, and there's a&nbsp;** 10K pullup**&nbsp;on this pin. This connection is shared with the STEMMA QT port on the opposite side of the board.
- **[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;-&nbsp;**These connectors allow you to connect to dev boards with **STEMMA QT** &nbsp;connectors or to other things with&nbsp;[various associated accessories](https://www.adafruit.com/category/619). There's **one port at the end** that connects to your microcontroller. The other eight connectors in two rows of four are discussed below.

## I2C Logic Pins - Multiplexed

- **STEMMA QT Ports 0** to **7** - There are eight JST SH 1mm connectors in two rows of four, all with the power, ground, and SDA/SCL pins connected. There are 8 sets of&nbsp; **SDA** &nbsp;and&nbsp; **SCL** &nbsp;pins, from&nbsp; **SD0/SC0** &nbsp;to&nbsp; **SD7/SC7**. These are the multiplexed pins. Each one is a completely separate I2C bus set. You can have 8 I2C devices with identical addresses, as long as they are on one I2C bus each. The power input for the connectors is the output from the **Vlogic** switch, and is either **V+** or **3.3V 500mA**.

Warning: 

## Address Pins
On the back of the board are&nbsp; **three address jumpers** , labeled&nbsp; **A0** ,&nbsp; **A1** , and&nbsp; **A2,** between the board name and Adafruit logo on the board silk. These jumpers allow you to chain up to 8 of these boards on the same pair of I2C clock and data pins. To do so, you solder the jumpers "closed" by connecting the two pads.

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 soldered closed and** A ****0** &nbsp;is soldered closed, the address is&nbsp; **0x70 + 4 + 1 = 0x75**.

 If only **A**** 0 **&nbsp;is soldered closed, the address is&nbsp;** 0x70 + 1 = 0x71**

 If only **A1** &nbsp;is soldered closed, the address is&nbsp; **0x70 + 2 = 0x72**

 If only **A**** 2 **&nbsp;is soldered closed, the address is&nbsp;** 0x70 + 4 = 0x74**

The table below shows all possible addresses, and whether the pin(s) should be high (closed) or low (open).

![](https://cdn-learn.adafruit.com/assets/assets/000/115/951/medium800/components_i2ctable.jpg?1666044858)

## Reset Pin
- **RST** - Reset pin for resetting the multiplexer chip. Pulled high by default, connect to ground to reset.

## Power LED

- **Power LED -&nbsp;** In the upper left corner, above the STEMMA connector, on the front of the board, is the power LED, labeled **&nbsp;on**. It is the green LED.

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

## CircuitPython & Python

It's easy to use the&nbsp; **PCA9548** &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 **PCA9548&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 [check out this guide](https://learn.adafruit.com/working-with-multiple-i2c-devices) 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)
## Why the Adafruit\_CircuitPython\_TCA9548A Module?

The PCA9548 is the 'fraternal twin sister' of the TCA9548 but it is easier to get during the great chip shortage of 2022. It works exactly the same, it just can't go down to 1.8V power which is OK because QT boards are 3V or 5V only anyways. [You can still use any example code or library for the TCA9548](https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/overview)

## CircuitPython Microcontroller Wiring

First, wire up a PCA9548 to your board exactly as shown below. Here's an example of wiring a Feather M4 to the PCA9548 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 PCA9548 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)**
- **TSL2591 1** to **mux STEMMA port 0**
- **TSL2591 2** to **mux STEMMA port 1**

![components_featherStemma_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/116/563/medium640/components_featherStemma_bb.jpg?1668009548)

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)**
- **TSL2591 1** to **mux STEMMA port 0**
- **TSL2591 2** to **mux STEMMA port 1**

![components_featherBB_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/116/562/medium640/components_featherBB_bb.jpg?1668009530)

## 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** to **mux STEMMA port 0**
- **TSL2591 2** to **mux STEMMA port 1**

![components_piStemma_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/116/564/medium640/components_piStemma_bb.jpg?1668009564)

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** to **mux STEMMA port 0**
- **TSL2591 2** to **mux STEMMA port 1**

![components_piBB_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/116/565/medium640/components_piBB_bb.jpg?1668009575)

## 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 PCA9548, 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 PCA9548 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 PCA9548.

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 PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer

## Python Docs

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

## Arduino

Using the PCA9548 I2C multiplexer&nbsp;with Arduino involves wiring up the I2C multiplexer to your Arduino-compatible microcontroller and running the provided example code.

If you're curious why you'd need an I2C multiplexer, be sure to [check out this guide](https://learn.adafruit.com/working-with-multiple-i2c-devices) 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)
## Wiring

Wire as shown for a&nbsp; **5V** &nbsp;board like an Uno. If you are using a **&nbsp;3V** &nbsp;board, like an Adafruit Feather, wire the board's 3V pin to the PCA9548 VIN.

Here is an Adafruit Metro wired up to the PCA9548 using the STEMMA QT connector, along with two VL53L4CD STEMMA boards plugged into port 0 and port 1 on the PCA9548:

- **Board 5V** &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)**
- **VL53L4CD 1** to **mux STEMMA port 0**
- **VL53L4CD 2** to **mux STEMMA port 1**

![components_metroStemma_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/967/medium640/components_metroStemma_bb.jpg?1666103500)

Here is an Adafruit Metro wired up using a solderless breadboard:

- **Board 5V** &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)**
- **VL53L4CD 1** to **mux STEMMA port 0**
- **VL53L4CD 2** to **mux STEMMA port 1**

![components_metroBB_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/968/medium640/components_metroBB_bb.jpg?1666103541)

## Library Installation

The [Multi-Sensor example](https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino#multi-sensor-example-code-3129188) uses two VL53L4CD time of flight sensors. You can install the&nbsp; **VL53L4CD** &nbsp;library for Arduino using the Library Manager in the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/115/979/medium800/components_Arduino_Open_Library_Manager.png?1666115018)

Click the&nbsp; **Manage Libraries ...** &nbsp;menu item, search for&nbsp; **VL53L4CD** ,&nbsp;and select the&nbsp; **STM32duino VL53L4CD** &nbsp;library:

![](https://cdn-learn.adafruit.com/assets/assets/000/115/980/medium800/components_arduinoLibFlight.png?1666115052)

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

#include "Wire.h"

#define PCAADDR 0x70

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


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

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

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

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

void loop() 
{
}
```

![](https://cdn-learn.adafruit.com/assets/assets/000/115/981/medium800/components_arduinoScan.jpg?1666116093)

Upload the sketch to your board and open up the Serial Monitor ( **Tools -\> Serial Monitor** ) at 115200 baud. You should see the 8 ports print to the Serial Monitor. If an I2C device is plugged into one of the ports, its address will be printed below the port number.

## Multi-Sensor Example Code
```auto
/**
 * PCA9548 I2C Multi Sensor Example
 *
 * Using two VL53L4CD sensors on ports 0 and 1
 *
 */

#include &lt;Arduino.h&gt;
#include &lt;Wire.h&gt;
#include &lt;vl53l4cd_class.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdint.h&gt;
#include &lt;assert.h&gt;

#define PCAADDR 0x70
#define DEV_I2C Wire

#define SerialPort Serial

// create two instances of the sensor
VL53L4CD tof1(&amp;DEV_I2C, A1);
VL53L4CD tof2(&amp;DEV_I2C, A1);

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

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

    Wire.begin();
    
    Serial.begin(115200);
    Serial.println("\nMultiSensor PCA9548");
    
    // define the port on the PCA9548 for the first sensor
    pcaselect(0);
    // setup the first sensor
    tof1.begin();
    tof1.VL53L4CD_Off();
    tof1.InitSensor();
    tof1.VL53L4CD_SetRangeTiming(200, 0);
    tof1.VL53L4CD_StartRanging();
  
    // define the port on the PCA9548 for the 2nd sensor
    pcaselect(1);
    
    // setup the 2nd sensor
    tof2.begin();
    tof2.VL53L4CD_Off();
    tof2.InitSensor();
    tof2.VL53L4CD_SetRangeTiming(200, 0);
    tof2.VL53L4CD_StartRanging();
      
}

void loop() 
{
  uint8_t NewDataReady = 0;
  VL53L4CD_Result_t results;
  uint8_t status;
  char report[64];
  
  // define port on the PCA9584
  pcaselect(0);

  // loop for time of flight sensor 1
  do {
    status = tof1.VL53L4CD_CheckForDataReady(&amp;NewDataReady);
  } while (!NewDataReady);

  if ((!status) &amp;&amp; (NewDataReady != 0)) {
    // (Mandatory) Clear HW interrupt to restart measurements
    tof1.VL53L4CD_ClearInterrupt();

    // Read measured distance. RangeStatus = 0 means valid data
    tof1.VL53L4CD_GetResult(&amp;results);
    snprintf(report, sizeof(report), "ToF 1 - Status = %3u, Distance = %5u mm, Signal = %6u kcps/spad\r\n",
             results.range_status,
             results.distance_mm,
             results.signal_per_spad_kcps);
    SerialPort.println(report);
  }

  // define port on PCA9548
  pcaselect(1);

  // loop for time of flight sensor 2
  do {
    status = tof2.VL53L4CD_CheckForDataReady(&amp;NewDataReady);
  } while (!NewDataReady);

  if ((!status) &amp;&amp; (NewDataReady != 0)) {
    // (Mandatory) Clear HW interrupt to restart measurements
    tof2.VL53L4CD_ClearInterrupt();

    // Read measured distance. RangeStatus = 0 means valid data
    tof2.VL53L4CD_GetResult(&amp;results);
    snprintf(report, sizeof(report), "ToF 2 - Status = %3u, Distance = %5u mm, Signal = %6u kcps/spad\r\n",
             results.range_status,
             results.distance_mm,
             results.signal_per_spad_kcps);
    SerialPort.println(report);
  }
}
```

![](https://cdn-learn.adafruit.com/assets/assets/000/115/982/medium800/components_multiSensorArduino.jpg?1666116318)

Upload the sketch to your board and open up the Serial Monitor ( **Tools -\> Serial Monitor** ) at 115200 baud. You should see readings from the two VL53L4CD time of flight sensors print to the Serial Monitor.

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

## Downloads

## Files

- [PCA9548 Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/115/917/original/pca9548a.pdf?1666013231)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-PCA9548-PCB)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20PCA9548%20STEMMA%20I2C%20Multiplexer.fzpz)

## Schematic and Fab Print
![](https://cdn-learn.adafruit.com/assets/assets/000/115/918/medium800/components_schem.png?1666014354)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/919/medium800/components_fab.png?1666014363)


## Primary Products

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

[Adafruit PCA9548 8-Channel STEMMA QT / Qwiic I2C Multiplexer](https://www.adafruit.com/product/5626)
You just found the perfect I2C sensor, available in a handy chainable&nbsp;[**Qwiic, or STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;package, and you want to wire up two or three or more of them to your microcontroller when you realize...

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

## Featured Products

### Adafruit TSL2591 High Dynamic Range Digital Light Sensor

[Adafruit TSL2591 High Dynamic Range Digital Light Sensor](https://www.adafruit.com/product/1980)
When the future is dazzlingly-bright, this ultra-high-range luminosity sensor will help you measure it. The TSL2591 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. Compared to low cost CdS cells, this sensor is more precise, allowing...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1980)
[Related Guides to the Product](https://learn.adafruit.com/products/1980/guides)
### Adafruit VL53L4CD Time of Flight Distance Sensor - ~1 to 1300mm

[Adafruit VL53L4CD Time of Flight Distance Sensor - ~1 to 1300mm](https://www.adafruit.com/product/5396)
The **Adafruit VL53L4CD Time of Flight Sensor** is another great _Time of Flight_&nbsp;distance sensor from ST in the VL5 series of chips, this one is great for shorter distances. The sensor contains a very tiny invisible laser source&nbsp;and a matching sensor. The...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5396)
[Related Guides to the Product](https://learn.adafruit.com/products/5396/guides)
### STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable

[STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable](https://www.adafruit.com/product/4209)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium Dupont male headers on the other. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert...

In Stock
[Buy Now](https://www.adafruit.com/product/4209)
[Related Guides to the Product](https://learn.adafruit.com/products/4209/guides)
### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)
### JST SH 4-pin Cable with Alligator Clips - STEMMA QT / Qwiic

[JST SH 4-pin Cable with Alligator Clips - STEMMA QT / Qwiic](https://www.adafruit.com/product/4398)
This cable will make it super easy to use our plug-and-play STEMMA QT boards with boards like Circuit Playground. On one end you get a Qwiic / STEMMA QT connector (technically known as a JST SH 4-pin plug)&nbsp; into 4 individual wires with grippy alligator clips. We're carrying these to...

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

## Related Guides

- [Adafruit TSL2591 High Dynamic Range Digital Light Sensor](https://learn.adafruit.com/adafruit-tsl2591.md)
- [Adafruit VL53L4CD Time of Flight Distance Sensor](https://learn.adafruit.com/adafruit-vl53l4cd-time-of-flight-distance-sensor.md)
- [I2C Addresses and Troublesome Chips](https://learn.adafruit.com/i2c-addresses.md)
- [MIDI Laser Harp with Time of Flight Distance Sensors](https://learn.adafruit.com/midi-laser-harp-time-of-flight-sensors.md)
- [CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials.md)
- [Raspberry Pi Video Synth with Blinka and Processing](https://learn.adafruit.com/raspberry-pi-video-synth-with-blinka-and-processing.md)
- [Tombstone Prop-Maker RP2040](https://learn.adafruit.com/tombstone-prop-maker-rp2040.md)
- [No-Code IoT Soil Sensor](https://learn.adafruit.com/soil-node.md)
- [PyPaint Drawing Program In CircuitPython](https://learn.adafruit.com/pypaint.md)
- [Reindeer Mask with Animated Eyes](https://learn.adafruit.com/reindeer-mask-with-animated-eyes.md)
- [Adafruit LSM6DS33 6-DoF IMU Breakout](https://learn.adafruit.com/lsm6ds33-6-dof-imu-accelerometer-gyro.md)
- [CircuitPython on the Arduino Nano RP2040 Connect](https://learn.adafruit.com/circuitpython-on-the-arduino-nano-rp2040-connect.md)
- [AdaBox 015](https://learn.adafruit.com/adabox015.md)
- [Adafruit STEMMA Reflective Photo Interrupt Sensor](https://learn.adafruit.com/adafruit-stemma-reflective-photo-interrupt-sensor.md)
- [NeoPixel Remote: IR Control with WLED](https://learn.adafruit.com/neopixel-remote-ir-control-with-wled.md)
