Hello again, I have a new problem, I am trying to use a TCA9548A to connect 2 20x4 I2C LCDs and 2 16x2 I2C LCDs. I am using a Leonardo, so my SDA and SCL are D2 and D3 to connect to the SCL and SDA of the TCA9548A. I am connecting the VCC to 5V. I can detect the TCA9548A through the Arduino, but I cannot detect the LCDs connected to the various channels. I am using this code to detect I2C devices.
#include <Wire.h>
#define TCA_ADDR 0x70 // Address of the TCA9548A multiplexer
void setup() {
Serial.begin(9600);
Wire.begin();
}
void loop() {
scanAllChannels();
delay(1000); // Delay before rescanning
}
void scanAllChannels() {
// Scan through each channel
for (byte channel = 0; channel < 8; channel++) {
// Select channel
selectChannel(channel);
// Scan for devices on the selected channel
scanChannel(channel);
}
}
void selectChannel(byte channel) {
Wire.beginTransmission(TCA_ADDR);
Wire.write(1 << channel); // Select the desired channel
Wire.endTransmission();
}
void scanChannel(byte channel) {
Serial.print("Scanning Channel ");
Serial.println(channel);
Wire.beginTransmission(channel);
byte error = Wire.endTransmission();
if (error == 0) {
Serial.println("Device found!");
} else {
Serial.println("No device found.");
}
}
Any help is greatly appreciated