For anyone else having this issue. I found you need to stop the measuring of one sensor using tof.stopMeasurement and then go to the next sensor. However once you stop measuring you need to start the sensor again using tof.begin. Therefore I had to move all the sensor code into the void loop. This is shown in this code:
tcaselect(1);
while(tof.begin() != 0){ //Initialization sensor,sucess return 0, fail return -1
Serial.println("failed1.");
delay(1000);
}
tcaselect(2);
while(tof.begin() != 0){ //Initialization sensor,sucess return 0, fail return -1
Serial.println("failed2.");
delay(1000);
}
tcaselect(1);
tof.setCalibrationData(caliDataBuf, sizeof(caliDataBuf));
tof.startMeasurement(tof.eModeCalib);
delay(1000);
if (tof.isDataReady()) { //Is check measuring data vaild, if vaild that print measurement data to USB Serial COM.
distance0 = tof.getDistance_mm();
Serial.print("Distance_0 = ");
Serial.print(distance0); //Print measurement data to USB Serial COM, unit mm, in eCOMBINE mode.
Serial.println(" mm");
}
tof.stopMeasurement();
tcaselect(2);
tof.setCalibrationData(caliDataBuf, sizeof(caliDataBuf));
tof.startMeasurement(tof.eModeCalib);
delay(1000);
if (tof.isDataReady()) { //Is check measuring data vaild, if vaild that print measurement data to USB Serial COM.
distance1 = tof.getDistance_mm();
Serial.print("Distance_1 = ");
Serial.print(distance1); //Print measurement data to USB Serial COM, unit mm, in eCOMBINE mode.
Serial.println(" mm");
}
tof.stopMeasurement();
}