TCA9548A causing issues, serial print only returns some characters

Hello, I have been through many attempts at trying to get 3 VL53V1X sensors to work with the arduino. I tried changing their address, and using them on the same i2c bus, and they kind or worked, but only the last one to be initialized would update the distance values, the rest would give fixed values.
Then I went on ST's forum and saw that they recommend using a multiplexer, so I bought 2 TCA9548A multiplexers, one of them didnt work at all, the other one kinda sorta works when it feels like it.
Enough details, the specific problem I'm having is that when I run a program to check what i2c devices are on each channel of the TCA9548A, the serial monitor only returns a few letters out of the code.

Here is the code:

#include "Wire.h"

#define TCAADDR 0x70

void tcaselect(uint8_t i) {
  if (i > 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(0x00);
  Wire.endTransmission(); 

  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << 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<8; t++) {
      tcaselect(t);
      Serial.print("TCA Port #"); Serial.println(t);

      for (uint8_t addr = 0; addr<=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() 
{
}

Here are the correct results which it gives VERY rarely:
TCAScanner ready!

TCA Port #0

TCA Port #1

TCA Port #2

TCA Port #3

TCA Port #4

TCA Port #5

TCA Port #6

TCA Port #7

done

and here are the results it gives usually (after clicking the reset button or re-uploading the program):
TCAScanner ready!

TCA Port #0

TCAScanner ready!

TCA

TCAScanner ready!

TCA Port #0

Ive found that it gives the correct printout when I leave it alone for a few minutes and come back to reset it, but when i run the program again, it always prints just a few letters like "T" or "TCA" or "TCAScanner ready!", does anyone know what the cause of this malfunction is? i had it on a breadboard them moved it to directly attach to wires to the arduino, but i can't say it makes any difference in my results. Any help us appreciated!

Which Arduino are you using?

How do you power the sensors?

Why does your scanner not detect any I2C device?

Your output suggests that the Arduino is reset frequently. Bad power supply?

Did You assign them different addresses?
Connecting 3 items to the I2C bus You likely need to check up the pullups. If there's no pullup in the sensor You need to add external ones. If every sensor has a pullup one or two might need to be removed.

Could You provide a link to their datasheet?

Not really

The hardware diagram is missing.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.