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!