TCA9845A Octal IIC Device Expansion Module
Introduction to TCA9845A
It can be known from the IIC communication protocol that multiple IIC devices can be hung on the two buses of the IIC, but the IIC device addresses of each device are required to be different. When there are multiple identical IIC slave devices with the same device address to communicate with the IIC master device, if it is also hung on the two IIC buses to communicate, it will become disordered. TCA9845A can effectively solve this situation, and can make eight devices with the same IIC slave address communicate effectively with the IIC master. The TCA9548A device is equipped with eight bidirectional transfer switches that can be controlled through the IIC bus. Voltage level translation between 1.8V, 2…5V, 3.3V, and 5V buses is supported; operating supply voltage range is 1.65V to 5.5V; 0 to 400kHz clock frequency.
TCA9548A device address table
You can connect 8 TCA9548A to the same IIC bus, configure 8 different IIC addresses, and then expand and control 64 identical IIC slave device addresses.
TCA9845A connects 4 OLED modules with the same IIC slave address
Test code and experimental results
Arduino library manager search and install two libraries Adafruit_GFX and Adafruit_SSD1306
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display3(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display4(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Select I2C BUS
void TCA9548A(uint8_t bus){
Wire.beginTransmission(0x70); // TCA9548A address
Wire.write(1 << bus); // send byte to select bus
Wire.endTransmission();
Serial.print(bus);
}
void setup() {
Serial.begin(115200);
// Start I2C communication with the Multiplexer
Wire.begin();
// Init OLED display on bus number 2 (display 1)
TCA9548A(2);
if(!display1.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
// Clear the buffer
display1.clearDisplay();
// Init OLED display on bus number 3
TCA9548A(3);
if(!display2.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
// Clear the buffer
display2.clearDisplay();
// Init OLED display on bus number 4
TCA9548A(4);
if(!display3.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
// Clear the buffer
display3.clearDisplay();
// Init OLED display on bus number 5
TCA9548A(5);
if(!display4.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
// Clear the buffer
display4.clearDisplay();
// Write to OLED on bus number 2
TCA9548A(2);
display1.setTextSize(8);
display1.setTextColor(WHITE);
display1.setCursor(45, 10);
// Display static text
display1.println("1");
display1.display();
// Write to OLED on bus number 3
TCA9548A(3);
display2.setTextSize(8);
display2.setTextColor(WHITE);
display2.setCursor(45, 10);
// Display static text
display2.println("2");
display2.display();
// Write to OLED on bus number 4
TCA9548A(4);
display3.setTextSize(8);
display3.setTextColor(WHITE);
display3.setCursor(45, 10);
// Display static text
display3.println("3");
display3.display();
// Write to OLED on bus number 5
TCA9548A(5);
display4.setTextSize(8);
display4.setTextColor(WHITE);
display4.setCursor(45, 10);
// Display static text
display4.println("4");
display4.display();
}
void loop() {
}