跳到主要内容

Grove - 8 Channel I2C Multiplexer/I2C Hub (TCA9548A)

We've already released the Grove - I2C Hub (4 Port) and the Grove - I2C Hub (6 Port). Wait, still not enough? Well well, we know you are seeking more. Here you are, we present you the Grove - 8 Channel I2C Hub.

More importantly, this is more than just a superposition of port quantities. As we all know, I2C devices must use different addresses in the same bus system, even use the Grove I2C Hub (4 or 6 port), the rule is still the rule. However, with the help of Grove - 8 Channel I2C Hub, you can plug up to 8 same-address I2C devices to the same Grove I2C system. All thanks to the TCA9548A I2C Multiplexer Chip. It adopts time-division multiplexing technology so that the same controller can control 8 I2C devices with the same address. No more worrying about address conflicts.

Features​

  • 8 Grove I2C Port
  • Support multiple devices with the same I2C address
  • Support 3.3V/5V System

Platform Supported​

ArduinoRaspberry Pi

Getting Started​

Read the I2C address of devices connecting on the Grove - 8 Channel I2C Hub​

Materials Required​

Seeeduino XIAOGrove BreadboardGrove - 8 Channel I2C Multiplexer/I2C Hub (TCA9548A)
Get one nowGet one nowGet one now

We also require up to 8 I2C devices, please click here to find the Grove I2C devices you like. At these example, we use three I2C devices.

Hardware connection​

Connect the I2C Hub with Seeeduino XIAO's I2C interface, and connect each I2C device with each hub.

Software code​

#include "TCA9548A.h"

// if you use the software I2C to drive, you can uncommnet the define SOFTWAREWIRE which in TCA9548A.h.
#ifdef SOFTWAREWIRE
#include <SoftwareWIRE.h>
SoftwareWire myWIRE(3, 2);
TCA9548A<SoftwareWire> TCA;
#define WIRE myWIRE
#else
#include <Wire.h>
TCA9548A<TwoWire> TCA;
#define WIRE Wire
#endif

#define SERIAL Serial

void setup()
{
SERIAL.begin(115200);
while(!SERIAL){};

//WIRE.begin();
TCA.begin(WIRE);
//defaut all channel was closed
//TCA.openAll();
//TCA.closeAll();

// Select the channels you want to open. You can open as many channels as you want
TCA.openChannel(TCA_CHANNEL_0); //TCA.closeChannel(TCA_CHANNEL_0);
TCA.openChannel(TCA_CHANNEL_1); //TCA.closeChannel(TCA_CHANNEL_1);
TCA.openChannel(TCA_CHANNEL_2); //TCA.closeChannel(TCA_CHANNEL_2);
TCA.openChannel(TCA_CHANNEL_3); //TCA.closeChannel(TCA_CHANNEL_3);
TCA.openChannel(TCA_CHANNEL_4); //TCA.closeChannel(TCA_CHANNEL_4);
TCA.openChannel(TCA_CHANNEL_5); //TCA.closeChannel(TCA_CHANNEL_5);
TCA.openChannel(TCA_CHANNEL_6); //TCA.closeChannel(TCA_CHANNEL_6);
TCA.openChannel(TCA_CHANNEL_7); //TCA.closeChannel(TCA_CHANNEL_7);

}

void loop()
{

uint8_t error, i2cAddress, devCount, unCount;

SERIAL.println("Scanning...");

devCount = 0;
unCount = 0;
for(i2cAddress = 1; i2cAddress < 127; i2cAddress++ )
{
WIRE.beginTransmission(i2cAddress);
error = WIRE.endTransmission();

if (error == 0)
{
SERIAL.print("I2C device found at 0x");
if (i2cAddress<16) SERIAL.print("0");
SERIAL.println(i2cAddress,HEX);
devCount++;
}
else if (error==4)
{
SERIAL.print("Unknow error at 0x");
if (i2cAddress<16) SERIAL.print("0");
SERIAL.println(i2cAddress,HEX);
unCount++;
}
}

if (devCount + unCount == 0)
SERIAL.println("No I2C devices found\n");
else {
SERIAL.print(devCount);
SERIAL.print(" device(s) found");
if (unCount > 0) {
SERIAL.print(", and unknown error in ");
SERIAL.print(unCount);
SERIAL.print(" address");
}
SERIAL.println();
}
SERIAL.println();
delay(1000);
}
  • Step 1 Download the library from the resource and add the "zip" library to your Arduino IDE. Please refer to How to install an Arduino Library.

  • Step 2 Find the example code and upload it to your board. Please refer to How to upload code.

  • Step 3 After uploading the code, you will see the I2C adress of each device from the serial monitor. The adress 0x70 is the I2C adress of I2C Hub.

Schematic Online Viewer​

Resource​

Tech Support​

if you have any technical issue. submit the issue into our forum.


Loading Comments...