QWIIC MUX and Grove I2C connections

I am confused on the QWIIC I2C and GROVE I2C connections:

I just purchased a [SparkFun Qwiic Mux Breakout - 8 Channel (TCA9548A)

In stock BOB-16784] for two projects. One project utilizing:

TFMini-S - Micro LiDAR Module SEN-16977

And another project utilizing:

SparkFun Triad Spectroscopy Sensor - AS7265x (Qwiic) SEN-15050

I was unable to make the TFMini Lidar work on the MUX board which was connected to a SparkFun RedBoard Qwiic - DEV-15123. First, I only came across the required MUX library by mistake. After including that with Rob’s Parking Garage Script. I also added a SSD1306 OLED to read the data. There were no readings. I Then took the MUX board out and connected directly to the RedBOard. And added a Grove Hat for the OLED. After several attempts there was success. The connection does not seem to be consistent.

One question for this POST, is the TFMINI supposed to work with a MUX board?

Second Question: will the TFMINI Lidar be ruined if it is connected to an I2C Grove (5v) connection?

Since the sensors mentioned above are hard to get and not cheap. I do not want to connect the sensors wrong and ruin them. The next question involves the potential use of a MUX board with the “SparkFun Triad Spectroscopy Sensor - AS7265x (Qwiic) SEN-15050” and connecting the MUX to a Grove connector on a WIO TERMINAL. The TRIAD is strictly 3V3 sensor – which is a concern. I read a warning on SparkFun that the SDA/SCL lines may have 5 volts on them depending what they are connected to.

Can I connect the TRIAD directly to my WIO TERMINAL by connecting the pins (not to the Grove connector) but directly to 3V3, GND SDA and SCL Pins on the GPIO?

Or can I connect the MUX board to the I2C Grove connector on the WIO TERMINAL and then connect the TRIAD to the MUX board and not blow up the TRIAD?

Or none of the above.

Why am I using the WIO Terminal? It has a display built in so I can see the results.

I would strongly suggest testing ONE component at a time, and adding them once you have them operating individually to your satisfaction

One question for this POST, is the TFMINI supposed to work with a MUX board? - Yes, though you my need to change its address

Second Question: will the TFMINI Lidar be ruined if it is connected to an I2C Grove (5v) connection? - The TFmini can be powered at either 3.3v or 5v; its data uses 3.3v…you need to use a logic level shifter if utilizing 5v lines

Can I connect the TRIAD directly to my WIO TERMINAL by connecting the pins (not to the Grove connector) but directly to 3V3, GND SDA and SCL Pins on the GPIO? - That should work

Or can I connect the MUX board to the I2C Grove connector on the WIO TERMINAL and then connect the TRIAD to the MUX board and not blow up the TRIAD?If the grove is outputting 5v, the mux will too

Run through the TFmini hookup guide https://learn.sparkfun.com/tutorials/tf … okup-guide and then the triad hookup guide https://learn.sparkfun.com/tutorials/sp … o3EALw_wcB and then the mux hookup guide https://learn.sparkfun.com/tutorials/qw … o3EALw_wcB

Best of luck!

Regarding the TFMINI LIDAR (06/17/2021)

Today I removed the Grove Shield and connected my I2C .96 OLED directly to a SparkFun QWIIC Blackboard (UNO). (OLED to Arduino UNO Pins 3V3, GND, SDA to A4 and SCL to PIN A5). Happily puzzled, the OLED is displaying the TFMINI Data. Now I will attempt to make it portable.

I connected the Blackboard, LIDAR and I2C .96 OLED to a LI battery with 5V 2A (2.4A Max) Output and all works!

Same experiment with the QWIIC RedBoard. OLED displays the LIDAR data!

I also connected a regular 9V battery to the barrel power connecter and the OLED is displaying TFMINI Data.

Next I will attempt to hook up my SparkFun Triad Spectroscopy Sensor.

I am still unsure of where the SDA and SCL get their voltage. Apparently, I cannot assume that if I hook an I2C sensor directly to 3v3 and GND that the signals SDA & SCL will obtain their voltage from that 3v3 pin!? I believe both the SEED XIAO and WIO Terminal are 5V based. Until I figure out how to use a logic level shifter and the easiest one to buy.

Finally, success with QWIIC MUX, WIO Terminal; (I2C) slot and two SparkFun Sensors:

SparkFun Triad Spectroscopy Sensor - AS7265x (Qwiic) - SEN-15050

SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic) - SEN-14722

The following code works (Next step is to write the Triad data to the internal SD Card.

Moderator edit: Please use code tags!

// 06/24/2021
// This Sketch worked!  
//NOTE:  Forgot to plug the "SparkFun_VL53L1X" and the Sketch would not OUTPUT anything.
//       Once I plugged the sensor on PORT 1, everything worked
//Background:
//tft.setRotation(r); This code rotates the screen. 0=0 , 1=90, 2=180, 3=270
//       tft.setFreeFont(FSSBO24)
//
//       Where the letters mean:
//       F = Free font
//       M = Mono
//      SS = Sans Serif (double S to distinguish is form serif fonts)
//       S = Serif
//       B = Bold
//       O = Oblique (letter O not zero)
//       I = Italic
//       # =  point size, either 9, 12, 18 or 24
//

#include <Wire.h>
#include"TFT_eSPI.h"
TFT_eSPI tft;
#include"Free_Fonts.h" //include the header file
#include <SPI.h>

#include "High_Temp.h"
HighTemp ht(A1, A0);
#include <SparkFun_I2C_Mux_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_I2C_Mux
QWIICMUX myMux;
#include "SparkFun_AS7265X.h" //Click here to get the library: http://librarymanager/All#SparkFun_AS7265X
AS7265X sensorTriad;    //I2C device found at address 0x49 : with MUX address 0x70

#include <Seeed_FS.h>  //https://github.com/Seeed-Studio/Seeed_Arduino_FS
#define DEV SD
#include "SD/Seeed_SD.h"

#include "SparkFun_VL53L1X.h" //Click here to get the library: http://librarymanager/All#SparkFun_VL53L1X
//   #include <ComponentObject.h>
//   #include <RangeSensor.h>
//   #include <vl53l1x_class.h>
//   #include <vl53l1_error_codes.h
SFEVL53L1X dist4mSensor;

//#include "SFUD/Seeed_SFUD.h"
#define SERIAL Serial
File root;

#define BUZZER_PIN WIO_BUZZER

int state = 0;
int xpos = 6;    //xpos =  6;
int ypos = 2;    //  ypos = 2;
int nY;          // set to =ypos + 27; in each Menu Option for multiple lines
int borderColor = TFT_WHITE;
int menuDelay = 2000;    //Set Delay for Menu/Button presses
float highTemp, curDistance;
byte port;
const byte Triad = 0;
const byte dist4m = 1;


void showBorders() {
  //bC == border Color
    tft.drawLine(0,0,320,0,borderColor); //drawing a black line from (0,0) to (0,320)  Top Horizantal
    tft.drawLine(0,25,315,25,borderColor);
    tft.drawLine(0,238,320,238,borderColor);   //Bottom horizantal line
    tft.drawLine(0,0,0,240,borderColor);    //Left Vertical Barely visible must tilt screen to see all the way to the left
    tft.drawLine(2,0,2,240,borderColor);     //Left Hand Vertical line
    tft.drawLine(318,0,318,240,borderColor);  //Vertical line Right hand side, cannot push further right to 320  
}
 
void setup() {
  Wire.begin();

// SparkFun MUX board BEGIN   This must be accomplished before initiating devices attached to MUX
    myMux.begin(0x70);
    if (myMux.begin() == false)
     {
      Serial.println("Mux not detected. Freezing...");
      while (1);
     }
    Serial.println("Mux detected");
// End MUX
// First start each MUX port with a device attached
//Try myMux.enablePort(port#);  KEYWORD2
//    myMux.disablePort(port#); KEYWORD2  That is, close port after finished with
// the current sensor

//  Then "begin each device 
    // PORT 0  
    myMux.enablePort(Triad); //Triad = 0;
 
    if(sensorTriad.begin() == false)
      {
       Serial.println("triad does not appear to be connected. Please check wiring. Freezing...");
       while(1);
      }   
     myMux.disablePort(Triad); 
     
     
    // PORT 1 
    myMux.enablePort(dist4m); //dist4m = 1; 
    if (dist4mSensor.begin() != 0) //Begin returns 0 on a good init
     {
      Serial.println("dist4m Sensor failed to begin. Please check wiring. Freezing...");
      while (1);
     }
     Serial.println("dist4m Sensor online!");
     dist4mSensor.setDistanceModeLong();
     myMux.disablePort(dist4m);
//   dist4mSensor.setDistanceModeShort();
//   END MUX device setup
    
//  Begin High Temperature sensor
    ht.begin();    
        
  //Initialise SD card
    if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
        while (1);
    }
  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(TFT_BLACK); 
  showBorders();                //Show Border and Heading
  //tft.setFreeFont(FSSBO24);              //FS12 or FS9 == FreeFont Serif 9pt
  //Define Header Text

  tft.setFreeFont(FS12);  //12pt Text for Header
  tft.setCursor(xpos, ypos);   //For Header Text
  tft.drawString("Header Text here", xpos, ypos, GFXFF); 
  
  Serial.begin(115200);
  pinMode(WIO_KEY_A, INPUT_PULLUP);
  pinMode(WIO_KEY_B, INPUT_PULLUP);
  pinMode(WIO_KEY_C, INPUT_PULLUP);
  pinMode(WIO_5S_UP, INPUT_PULLUP);      //Cursor Up
  pinMode(WIO_5S_DOWN, INPUT_PULLUP);    //Cursor Down
  pinMode(WIO_5S_LEFT, INPUT_PULLUP);    //Up Directory/ Folder
  pinMode(WIO_5S_RIGHT, INPUT_PULLUP);   //Down Directory/ Floder
  pinMode(WIO_5S_PRESS, INPUT_PULLUP);   //Select File

  pinMode(BUZZER_PIN, OUTPUT);
      SERIAL.print("Initializing SD card...");

#ifdef SFUD_USING_QSPI
    while (!DEV.begin(104000000UL)) {
        SERIAL.println("Card Mount Failed");
        return;
    }
#else
    while (!DEV.begin(SDCARD_SS_PIN,SDCARD_SPI,4000000UL)) {
        SERIAL.println("Card Mount Failed");
        return;
    }
#endif 
    SERIAL.println("initialization done.");

    //listDir(DEV, "/", 0);

    SERIAL.println("done!");
}

/*
 * Visible Rectangle Boundary 
 * (0,0) to (0,320)      TOP Line
 * (0,238) to (320,238)  BOTTOM Line
 * (2,0) to (2,240)      LEFT Vertical Line
 * (318,0) to (318,240)  RIGHT Vertical Line
 * HEADER TOP HORIZANTAL:
 * (0,25) to (315,25)     25 pixels from Top
 * HEADER TEXT 12pt fits between TOP two HORIZANTAL Lines
 * HEADER CURSOR POSITION:  (6,2)
 * BODY TEXT:  9pt
 * BODY TEXT Position:  (2,29)   (2,(2+27))
*/
void loop() {
  highTemp = ht.getThmc();    //highTemp
  // list MUX devices
  //listMUXdevices();
  
  // defined above: xpos =  6; ypos = 2;
  //showBorders();
  if (digitalRead(WIO_KEY_A) == LOW) {
    state = 1;
    //tft.fillScreen(TFT_BLACK);   
    //showBorders(TFT_WHITE);   //See setup
    //tft.drawString("C",140,100);
    playTone(1915, 500);
    
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_KEY_A-Pressed", xpos, ypos+27, GFXFF);
    delay(menuDelay);
    listDir(DEV, "/", 3);
   }
   else if (digitalRead(WIO_KEY_B) == LOW) {
    tft.fillScreen(TFT_BLACK);    //Clear display
    showBorders();                //Show Border and Heading
    tft.drawString("   WiFi Scan", xpos, ypos, GFXFF); 
    playTone(1700, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_KEY_B-Pressed              ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"
 
    delay(menuDelay); 
   }
   else if (digitalRead(WIO_KEY_C) == LOW) {
    state = 3;
    nY = ypos + 27;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("E",140,100);
    playTone(1519, 500);
    //tft.setRotation(3);
    tft.fillScreen(TFT_BLACK);
    showBorders();
    tft.setFreeFont(FS9);   //31 Characters fit between the 2 vertical boundary lines
    tft.drawString("WIO_KEY_C-Pressed              ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"
    nY = nY + 21;
    tft.drawString("High Temp: " + String(highTemp), xpos, nY, GFXFF); 
    nY = nY + 21;
    tft.drawString("Room Temp: " + String(ht.getRoomTmp()), xpos, nY, GFXFF);
    //nY = nY + 21:
    //getThmc()
    
    delay(menuDelay);    
   }else if (digitalRead(WIO_5S_UP) == LOW) {
    state = 4;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("F",140,100);
    playTone(1432, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_UP-Pressed              ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"     
        
   }
   else if (digitalRead(WIO_5S_DOWN) == LOW) {
    state = 5;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("G",140,100);
    playTone(1275, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_DWN-Pressed             ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"    
    delay(menuDelay);     
   }
   else if (digitalRead(WIO_5S_LEFT) == LOW) {
    state = 6;
    nY = ypos + 27;    //for multiple lines
    //tft.fillScreen(TFT_BLACK); 
    playTone(1136, 500);
    tft.fillScreen(TFT_BLACK);
    showBorders();    
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_L-Pressed               ", xpos, ypos+27, GFXFF);  
    //             "123456789A123456789B123456789C1"   
    //enablePort  KEYWORD2
    //myMux.disablePort
    Serial.println("Call  triad18Channel ");
    triad18Channel();  
    delay(menuDelay);     
   }
   else if (digitalRead(WIO_5S_RIGHT) == LOW) {
    state = 7;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("B",140,100);
    playTone(1014, 500);
    tft.fillScreen(TFT_BLACK);
    showBorders();    
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_R-Pressed               ", xpos, ypos+27, GFXFF);  
    //             "123456789A123456789B123456789C1"  
    Serial.println("dist4m : Call myDistance"); 
    curDistance = myDistance();   //in inches       
    delay(menuDelay);     
   }
   else if (digitalRead(WIO_5S_PRESS) == LOW) {
    state = 8;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("C",140,100);
    playTone(956, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_B-Pressed               ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"    
    delay(menuDelay);     
   }else{
    //tft.fillScreen(TFT_BLACK); 
   }
}


  void playTone(int tone, int duration) {
    for (long i = 0; i < duration * 1000L; i += tone * 2) {
        digitalWrite(BUZZER_PIN, HIGH);
        delayMicroseconds(tone);
        digitalWrite(BUZZER_PIN, LOW);
        delayMicroseconds(tone);
    }
}   //End PlayTone


void listDir(fs::FS& fs, const char* dirname, uint8_t levels) {
  //Main Header is at Location (6,2)
  //Set Cursor within the printable area
    int xPrtArea = xpos;   //  xpos currently 6
    int yPrtArea = ypos+27;
    String myDir;   //Note: File name includes Directory name
    String myFile;
    //stringOne.trim();Remove white space
    //stringOne.length();
    SERIAL.print("Listing directory: ");
    SERIAL.println(dirname);
    tft.setFreeFont(FS12);  //12pt Text for Header
    tft.setCursor(xpos, ypos);   //For Header Text
    tft.drawString("Listing directory: ", xpos, ypos, GFXFF); 

    tft.setFreeFont(FS9); 
    //             "123456789A123456789B123456789C1"
    //tft.drawString("                               ", xPrtArea, yPrtArea, GFXFF);
    //tft.drawString("Dir:=" + String(dirname), xPrtArea, yPrtArea, GFXFF); 
    yPrtArea = yPrtArea + 21;
    tft.setCursor(xPrtArea, yPrtArea);
    //tft.println(); 
    
    File root = fs.open(dirname);
    if (!root) {
        SERIAL.println("Failed to open directory");
        tft.println("Failed to open directory");
        tft.setFreeFont(FS9); 
        //tft.drawString("Failed to open directory", xPrtArea, yPrtArea, GFXFF); 
            
        return;
    }
    if (!root.isDirectory()) {
        SERIAL.println("Not a directory");
        return;
    }

    File file = root.openNextFile();
    while (file) {
        if (file.isDirectory()) {
            SERIAL.print("  DIR : ");
            SERIAL.println(file.name());
            myDir = file.name();  //   myDir Filename includes DIR so no need to print this out
            //tft.setFreeFont(FS9); 
            //tft.drawString("Dir:=" + myDir, xPrtArea, yPrtArea, GFXFF); 
            //yPrtArea = yPrtArea + 21;
            if (levels) {
                listDir(fs, file.name(), levels - 1);
                //tft.setCursor(xPrtArea, yPrtArea);   //For Header Text
                //tft.setFreeFont(FS9); 
                //tft.drawString("Dir:=" + myDir, xPrtArea, yPrtArea, GFXFF); 
                //tft.println("Dir:=" + myDir);
                //yPrtArea = yPrtArea + 21;
            }
        } else {
            SERIAL.print("  FILE: ");
            SERIAL.print(file.name());
            SERIAL.print("  SIZE: ");
            SERIAL.println(file.size());
            myFile = file.name();                     //   myFile
            //myFile = myFile.trim();  does not work
            yPrtArea = yPrtArea + 21;
            tft.setFreeFont(FS9); 
            //tft.drawString("                                           ", xPrtArea, yPrtArea, GFXFF);
            //tft.drawString("F:=" + myFile, xPrtArea, yPrtArea, GFXFF); 
            //yPrtArea = yPrtArea + 21;            
            tft.println("F:=" + myFile);
            //tft.println();
        }
        file = root.openNextFile();
    }
}     //End listDir

// MUX devices
void listMUXdevices() {
  Serial.println();

  byte nDevices = 1;
  for (byte address = 1; address < 127; address++)
  {
    Wire.beginTransmission(address);
    byte error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address < 0x10)
        Serial.print("0");
      Serial.print(address, HEX);
      Serial.println();

      nDevices++;
    }
    else if (error == 4)
    {
      Serial.print("Unknown error at address 0x");
      if (address < 0x10)
        Serial.print("0");
      Serial.println(address, HEX);
    }
  }

  if (nDevices == 0)
    Serial.println("No I2C devices found");
  else
    Serial.println("Done");

}

void triad18Channel()  {
  Serial.println("triad18Channel Before");
  //myMux.disablePort
  Serial.println(myMux.isConnected());
  Serial.print("PortState=");
  // PORT 0  
  myMux.enablePort(Triad); //Triad = 0;  
  //myMux.setPort(0); //Triad = 0
    port = myMux.getPort();
  Serial.print("CurrentPort: ");
  Serial.println(port);
  //myMux.enablePort(Triad);
  sensorTriad.takeMeasurementsWithBulb(); //This is a hard wait while all 18 channels are measured
  String Au = String(sensorTriad.getCalibratedA());
  String Bu = String(sensorTriad.getCalibratedB());
  String Cu = String(sensorTriad.getCalibratedC());
  String Du = String(sensorTriad.getCalibratedD());
  String Eu = String(sensorTriad.getCalibratedE());
  String Fu = String(sensorTriad.getCalibratedF());
  String Gu = String(sensorTriad.getCalibratedG());  

  String Hu = String(sensorTriad.getCalibratedH());
  String Iu = String(sensorTriad.getCalibratedI());
  String Ju = String(sensorTriad.getCalibratedJ());
  String Ku = String(sensorTriad.getCalibratedK()); 
  String Lu = String(sensorTriad.getCalibratedL());   

  String Ru = String(sensorTriad.getCalibratedR());
  String Su = String(sensorTriad.getCalibratedS());
  String Tu = String(sensorTriad.getCalibratedT());
  String Uu = String(sensorTriad.getCalibratedU());
  String Vu = String(sensorTriad.getCalibratedV());
  String Wu = String(sensorTriad.getCalibratedW());
  
  nY = nY + 21;
//tft.drawString("WIO_5S_R-Pressed               ", xpos, nY, GFXFF); 
  tft.drawString("A: " + String(Au) + " :B: " + String(Bu) + " :C: " + String(Cu), xpos, nY, GFXFF);
  nY = nY + 21;
  tft.drawString("D: " + String(Du) + " :E: " + String(Eu) + " :F: " + String(Fu), xpos, nY, GFXFF); 
  nY = nY + 21;
  tft.drawString("G: " + String(Gu) + " :H: " + String(Hu) + " :I: " + String(Iu), xpos, nY, GFXFF);
  nY = nY + 21;
  tft.drawString("J: " + String(Ju) + " :K: " + String(Ku) + " :L: " + String(Lu), xpos, nY, GFXFF); 
  nY = nY + 21;
  tft.drawString("R: " + String(Ru) + " :S: " + String(Su) + " :T: " + String(Tu), xpos, nY, GFXFF);
  nY = nY + 21;
  tft.drawString("U: " + String(Uu) + " :V: " + String(Vu) + " :W: " + String(Wu), xpos, nY, GFXFF);
  
  Serial.println("triad18Channel after");
  Serial.print(sensorTriad.getCalibratedA());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedB());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedC());

  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedD());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedE());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedF());
  Serial.print(",");

  Serial.print(sensorTriad.getCalibratedG());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedH());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedI());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedJ());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedK());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedL());
  Serial.print(",");

  Serial.print(sensorTriad.getCalibratedR());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedS());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedT());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedU());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedV());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedW());
  Serial.print(",");
  myMux.disablePort(Triad);
  Serial.println();
//l,r,s,t,u,v,w
}

float myDistance()  {
  Serial.println("dist4m : Inside Function myDistance"); 
  // Start PORT 1 for actual measurements
  //myMux.setPort(dist4m); //dist4m = 1; 
  tft.setFreeFont(FS9); 
  nY = ypos + 27;    //for multiple lines  - thereafter increment nY by 21
  tft.drawString("WIO_5S_R-Pressed               ", xpos, nY, GFXFF); 
  myMux.enablePort(dist4m); //dist4m = 1; 
  dist4mSensor.startRanging(); //Write configuration bytes to initiate measurement

  while (!dist4mSensor.checkForDataReady())
  {
    delay(1);
  }
  int distance = dist4mSensor.getDistance(); //Get the result of the measurement from the sensor
  dist4mSensor.clearInterrupt();

  dist4mSensor.stopRanging();

  Serial.print("Distance(mm): ");
  Serial.print(distance);
  nY = nY + 21;
//tft.drawString("WIO_5S_R-Pressed               ", xpos, nY, GFXFF); 
  tft.drawString("Distance (mm):" + String(distance), xpos, nY, GFXFF);
  float distanceInches = distance * 0.0393701;
  nY = nY + 21;
  tft.drawString("Distance (in):" + String(distanceInches), xpos, nY, GFXFF);  
  float distanceFeet = distanceInches / 12.0;
  nY = nY + 21;
  tft.drawString("Distance (ft):" + String(distanceFeet), xpos, nY, GFXFF);   

  Serial.print("\tDistance(ft): ");
  Serial.print(distanceFeet, 2);

  Serial.println();
  myMux.disablePort(dist4m);
  return(distanceInches);
}

Is this what you mean for “Code Tags”. I selected the IDE Code as “Copy For Forum”???

If not please let me know the procedure. Thank you

// 06/24/2021
// This Sketch worked!  
//NOTE:  Forgot to plug the "SparkFun_VL53L1X" and the Sketch would not OUTPUT anything.
//       Once I plugged the sensor on PORT 1, everything worked
//Background:
//tft.setRotation(r); This code rotates the screen. 0=0 , 1=90, 2=180, 3=270
//       tft.setFreeFont(FSSBO24)
//
//       Where the letters mean:
//       F = Free font
//       M = Mono
//      SS = Sans Serif (double S to distinguish is form serif fonts)
//       S = Serif
//       B = Bold
//       O = Oblique (letter O not zero)
//       I = Italic
//       # =  point size, either 9, 12, 18 or 24
//

#include <Wire.h>
#include"TFT_eSPI.h"
TFT_eSPI tft;
#include"Free_Fonts.h" //include the header file
#include <SPI.h>

#include "High_Temp.h"
HighTemp ht(A1, A0);
#include <SparkFun_I2C_Mux_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_I2C_Mux
QWIICMUX myMux;
#include "SparkFun_AS7265X.h" //Click here to get the library: http://librarymanager/All#SparkFun_AS7265X
AS7265X sensorTriad;    //I2C device found at address 0x49 : with MUX address 0x70

#include <Seeed_FS.h>  //https://github.com/Seeed-Studio/Seeed_Arduino_FS
#define DEV SD
#include "SD/Seeed_SD.h"

#include "SparkFun_VL53L1X.h" //Click here to get the library: http://librarymanager/All#SparkFun_VL53L1X
//   #include <ComponentObject.h>
//   #include <RangeSensor.h>
//   #include <vl53l1x_class.h>
//   #include <vl53l1_error_codes.h
SFEVL53L1X dist4mSensor;

//#include "SFUD/Seeed_SFUD.h"
#define SERIAL Serial
File root;

#define BUZZER_PIN WIO_BUZZER

int state = 0;
int xpos = 6;    //xpos =  6;
int ypos = 2;    //  ypos = 2;
int nY;          // set to =ypos + 27; in each Menu Option for multiple lines
int borderColor = TFT_WHITE;
int menuDelay = 2000;    //Set Delay for Menu/Button presses
float highTemp, curDistance;
byte port;
const byte Triad = 0;
const byte dist4m = 1;


void showBorders() {
  //bC == border Color
    tft.drawLine(0,0,320,0,borderColor); //drawing a black line from (0,0) to (0,320)  Top Horizantal
    tft.drawLine(0,25,315,25,borderColor);
    tft.drawLine(0,238,320,238,borderColor);   //Bottom horizantal line
    tft.drawLine(0,0,0,240,borderColor);    //Left Vertical Barely visible must tilt screen to see all the way to the left
    tft.drawLine(2,0,2,240,borderColor);     //Left Hand Vertical line
    tft.drawLine(318,0,318,240,borderColor);  //Vertical line Right hand side, cannot push further right to 320  
}
 
void setup() {
  Wire.begin();

// SparkFun MUX board BEGIN   This must be accomplished before initiating devices attached to MUX
    myMux.begin(0x70);
    if (myMux.begin() == false)
     {
      Serial.println("Mux not detected. Freezing...");
      while (1);
     }
    Serial.println("Mux detected");
// End MUX
// First start each MUX port with a device attached
//Try myMux.enablePort(port#);  KEYWORD2
//    myMux.disablePort(port#); KEYWORD2  That is, close port after finished with
// the current sensor

//  Then "begin each device 
    // PORT 0  
    myMux.enablePort(Triad); //Triad = 0;
 
    if(sensorTriad.begin() == false)
      {
       Serial.println("triad does not appear to be connected. Please check wiring. Freezing...");
       while(1);
      }   
     myMux.disablePort(Triad); 
     
     
    // PORT 1 
    myMux.enablePort(dist4m); //dist4m = 1; 
    if (dist4mSensor.begin() != 0) //Begin returns 0 on a good init
     {
      Serial.println("dist4m Sensor failed to begin. Please check wiring. Freezing...");
      while (1);
     }
     Serial.println("dist4m Sensor online!");
     dist4mSensor.setDistanceModeLong();
     myMux.disablePort(dist4m);
//   dist4mSensor.setDistanceModeShort();
//   END MUX device setup
    
//  Begin High Temperature sensor
    ht.begin();    
        
  //Initialise SD card
    if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
        while (1);
    }
  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(TFT_BLACK); 
  showBorders();                //Show Border and Heading
  //tft.setFreeFont(FSSBO24);              //FS12 or FS9 == FreeFont Serif 9pt
  //Define Header Text

  tft.setFreeFont(FS12);  //12pt Text for Header
  tft.setCursor(xpos, ypos);   //For Header Text
  tft.drawString("Header Text here", xpos, ypos, GFXFF); 
  
  Serial.begin(115200);
  pinMode(WIO_KEY_A, INPUT_PULLUP);
  pinMode(WIO_KEY_B, INPUT_PULLUP);
  pinMode(WIO_KEY_C, INPUT_PULLUP);
  pinMode(WIO_5S_UP, INPUT_PULLUP);      //Cursor Up
  pinMode(WIO_5S_DOWN, INPUT_PULLUP);    //Cursor Down
  pinMode(WIO_5S_LEFT, INPUT_PULLUP);    //Up Directory/ Folder
  pinMode(WIO_5S_RIGHT, INPUT_PULLUP);   //Down Directory/ Floder
  pinMode(WIO_5S_PRESS, INPUT_PULLUP);   //Select File

  pinMode(BUZZER_PIN, OUTPUT);
      SERIAL.print("Initializing SD card...");

#ifdef SFUD_USING_QSPI
    while (!DEV.begin(104000000UL)) {
        SERIAL.println("Card Mount Failed");
        return;
    }
#else
    while (!DEV.begin(SDCARD_SS_PIN,SDCARD_SPI,4000000UL)) {
        SERIAL.println("Card Mount Failed");
        return;
    }
#endif 
    SERIAL.println("initialization done.");

    //listDir(DEV, "/", 0);

    SERIAL.println("done!");
}

/*
 * Visible Rectangle Boundary 
 * (0,0) to (0,320)      TOP Line
 * (0,238) to (320,238)  BOTTOM Line
 * (2,0) to (2,240)      LEFT Vertical Line
 * (318,0) to (318,240)  RIGHT Vertical Line
 * HEADER TOP HORIZANTAL:
 * (0,25) to (315,25)     25 pixels from Top
 * HEADER TEXT 12pt fits between TOP two HORIZANTAL Lines
 * HEADER CURSOR POSITION:  (6,2)
 * BODY TEXT:  9pt
 * BODY TEXT Position:  (2,29)   (2,(2+27))
*/
void loop() {
  highTemp = ht.getThmc();    //highTemp
  // list MUX devices
  //listMUXdevices();
  
  // defined above: xpos =  6; ypos = 2;
  //showBorders();
  if (digitalRead(WIO_KEY_A) == LOW) {
    state = 1;
    //tft.fillScreen(TFT_BLACK);   
    //showBorders(TFT_WHITE);   //See setup
    //tft.drawString("C",140,100);
    playTone(1915, 500);
    
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_KEY_A-Pressed", xpos, ypos+27, GFXFF);
    delay(menuDelay);
    listDir(DEV, "/", 3);
   }
   else if (digitalRead(WIO_KEY_B) == LOW) {
    tft.fillScreen(TFT_BLACK);    //Clear display
    showBorders();                //Show Border and Heading
    tft.drawString("   WiFi Scan", xpos, ypos, GFXFF); 
    playTone(1700, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_KEY_B-Pressed              ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"
 
    delay(menuDelay); 
   }
   else if (digitalRead(WIO_KEY_C) == LOW) {
    state = 3;
    nY = ypos + 27;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("E",140,100);
    playTone(1519, 500);
    //tft.setRotation(3);
    tft.fillScreen(TFT_BLACK);
    showBorders();
    tft.setFreeFont(FS9);   //31 Characters fit between the 2 vertical boundary lines
    tft.drawString("WIO_KEY_C-Pressed              ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"
    nY = nY + 21;
    tft.drawString("High Temp: " + String(highTemp), xpos, nY, GFXFF); 
    nY = nY + 21;
    tft.drawString("Room Temp: " + String(ht.getRoomTmp()), xpos, nY, GFXFF);
    //nY = nY + 21:
    //getThmc()
    
    delay(menuDelay);    
   }else if (digitalRead(WIO_5S_UP) == LOW) {
    state = 4;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("F",140,100);
    playTone(1432, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_UP-Pressed              ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"     
        
   }
   else if (digitalRead(WIO_5S_DOWN) == LOW) {
    state = 5;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("G",140,100);
    playTone(1275, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_DWN-Pressed             ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"    
    delay(menuDelay);     
   }
   else if (digitalRead(WIO_5S_LEFT) == LOW) {
    state = 6;
    nY = ypos + 27;    //for multiple lines
    //tft.fillScreen(TFT_BLACK); 
    playTone(1136, 500);
    tft.fillScreen(TFT_BLACK);
    showBorders();    
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_L-Pressed               ", xpos, ypos+27, GFXFF);  
    //             "123456789A123456789B123456789C1"   
    //enablePort  KEYWORD2
    //myMux.disablePort
    Serial.println("Call  triad18Channel ");
    triad18Channel();  
    delay(menuDelay);     
   }
   else if (digitalRead(WIO_5S_RIGHT) == LOW) {
    state = 7;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("B",140,100);
    playTone(1014, 500);
    tft.fillScreen(TFT_BLACK);
    showBorders();    
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_R-Pressed               ", xpos, ypos+27, GFXFF);  
    //             "123456789A123456789B123456789C1"  
    Serial.println("dist4m : Call myDistance"); 
    curDistance = myDistance();   //in inches       
    delay(menuDelay);     
   }
   else if (digitalRead(WIO_5S_PRESS) == LOW) {
    state = 8;
    //tft.fillScreen(TFT_BLACK); 
    //tft.drawString("C",140,100);
    playTone(956, 500);
    tft.setFreeFont(FS9); 
    tft.drawString("WIO_5S_B-Pressed               ", xpos, ypos+27, GFXFF);   
    //             "123456789A123456789B123456789C1"    
    delay(menuDelay);     
   }else{
    //tft.fillScreen(TFT_BLACK); 
   }
}


  void playTone(int tone, int duration) {
    for (long i = 0; i < duration * 1000L; i += tone * 2) {
        digitalWrite(BUZZER_PIN, HIGH);
        delayMicroseconds(tone);
        digitalWrite(BUZZER_PIN, LOW);
        delayMicroseconds(tone);
    }
}   //End PlayTone


void listDir(fs::FS& fs, const char* dirname, uint8_t levels) {
  //Main Header is at Location (6,2)
  //Set Cursor within the printable area
    int xPrtArea = xpos;   //  xpos currently 6
    int yPrtArea = ypos+27;
    String myDir;   //Note: File name includes Directory name
    String myFile;
    //stringOne.trim();Remove white space
    //stringOne.length();
    SERIAL.print("Listing directory: ");
    SERIAL.println(dirname);
    tft.setFreeFont(FS12);  //12pt Text for Header
    tft.setCursor(xpos, ypos);   //For Header Text
    tft.drawString("Listing directory: ", xpos, ypos, GFXFF); 

    tft.setFreeFont(FS9); 
    //             "123456789A123456789B123456789C1"
    //tft.drawString("                               ", xPrtArea, yPrtArea, GFXFF);
    //tft.drawString("Dir:=" + String(dirname), xPrtArea, yPrtArea, GFXFF); 
    yPrtArea = yPrtArea + 21;
    tft.setCursor(xPrtArea, yPrtArea);
    //tft.println(); 
    
    File root = fs.open(dirname);
    if (!root) {
        SERIAL.println("Failed to open directory");
        tft.println("Failed to open directory");
        tft.setFreeFont(FS9); 
        //tft.drawString("Failed to open directory", xPrtArea, yPrtArea, GFXFF); 
            
        return;
    }
    if (!root.isDirectory()) {
        SERIAL.println("Not a directory");
        return;
    }

    File file = root.openNextFile();
    while (file) {
        if (file.isDirectory()) {
            SERIAL.print("  DIR : ");
            SERIAL.println(file.name());
            myDir = file.name();  //   myDir Filename includes DIR so no need to print this out
            //tft.setFreeFont(FS9); 
            //tft.drawString("Dir:=" + myDir, xPrtArea, yPrtArea, GFXFF); 
            //yPrtArea = yPrtArea + 21;
            if (levels) {
                listDir(fs, file.name(), levels - 1);
                //tft.setCursor(xPrtArea, yPrtArea);   //For Header Text
                //tft.setFreeFont(FS9); 
                //tft.drawString("Dir:=" + myDir, xPrtArea, yPrtArea, GFXFF); 
                //tft.println("Dir:=" + myDir);
                //yPrtArea = yPrtArea + 21;
            }
        } else {
            SERIAL.print("  FILE: ");
            SERIAL.print(file.name());
            SERIAL.print("  SIZE: ");
            SERIAL.println(file.size());
            myFile = file.name();                     //   myFile
            //myFile = myFile.trim();  does not work
            yPrtArea = yPrtArea + 21;
            tft.setFreeFont(FS9); 
            //tft.drawString("                                           ", xPrtArea, yPrtArea, GFXFF);
            //tft.drawString("F:=" + myFile, xPrtArea, yPrtArea, GFXFF); 
            //yPrtArea = yPrtArea + 21;            
            tft.println("F:=" + myFile);
            //tft.println();
        }
        file = root.openNextFile();
    }
}     //End listDir

// MUX devices
void listMUXdevices() {
  Serial.println();

  byte nDevices = 1;
  for (byte address = 1; address < 127; address++)
  {
    Wire.beginTransmission(address);
    byte error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address < 0x10)
        Serial.print("0");
      Serial.print(address, HEX);
      Serial.println();

      nDevices++;
    }
    else if (error == 4)
    {
      Serial.print("Unknown error at address 0x");
      if (address < 0x10)
        Serial.print("0");
      Serial.println(address, HEX);
    }
  }

  if (nDevices == 0)
    Serial.println("No I2C devices found");
  else
    Serial.println("Done");

}

void triad18Channel()  {
  Serial.println("triad18Channel Before");
  //myMux.disablePort
  Serial.println(myMux.isConnected());
  Serial.print("PortState=");
  // PORT 0  
  myMux.enablePort(Triad); //Triad = 0;  
  //myMux.setPort(0); //Triad = 0
    port = myMux.getPort();
  Serial.print("CurrentPort: ");
  Serial.println(port);
  //myMux.enablePort(Triad);
  sensorTriad.takeMeasurementsWithBulb(); //This is a hard wait while all 18 channels are measured
  String Au = String(sensorTriad.getCalibratedA());
  String Bu = String(sensorTriad.getCalibratedB());
  String Cu = String(sensorTriad.getCalibratedC());
  String Du = String(sensorTriad.getCalibratedD());
  String Eu = String(sensorTriad.getCalibratedE());
  String Fu = String(sensorTriad.getCalibratedF());
  String Gu = String(sensorTriad.getCalibratedG());  

  String Hu = String(sensorTriad.getCalibratedH());
  String Iu = String(sensorTriad.getCalibratedI());
  String Ju = String(sensorTriad.getCalibratedJ());
  String Ku = String(sensorTriad.getCalibratedK()); 
  String Lu = String(sensorTriad.getCalibratedL());   

  String Ru = String(sensorTriad.getCalibratedR());
  String Su = String(sensorTriad.getCalibratedS());
  String Tu = String(sensorTriad.getCalibratedT());
  String Uu = String(sensorTriad.getCalibratedU());
  String Vu = String(sensorTriad.getCalibratedV());
  String Wu = String(sensorTriad.getCalibratedW());
  
  nY = nY + 21;
//tft.drawString("WIO_5S_R-Pressed               ", xpos, nY, GFXFF); 
  tft.drawString("A: " + String(Au) + " :B: " + String(Bu) + " :C: " + String(Cu), xpos, nY, GFXFF);
  nY = nY + 21;
  tft.drawString("D: " + String(Du) + " :E: " + String(Eu) + " :F: " + String(Fu), xpos, nY, GFXFF); 
  nY = nY + 21;
  tft.drawString("G: " + String(Gu) + " :H: " + String(Hu) + " :I: " + String(Iu), xpos, nY, GFXFF);
  nY = nY + 21;
  tft.drawString("J: " + String(Ju) + " :K: " + String(Ku) + " :L: " + String(Lu), xpos, nY, GFXFF); 
  nY = nY + 21;
  tft.drawString("R: " + String(Ru) + " :S: " + String(Su) + " :T: " + String(Tu), xpos, nY, GFXFF);
  nY = nY + 21;
  tft.drawString("U: " + String(Uu) + " :V: " + String(Vu) + " :W: " + String(Wu), xpos, nY, GFXFF);
  
  Serial.println("triad18Channel after");
  Serial.print(sensorTriad.getCalibratedA());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedB());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedC());

  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedD());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedE());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedF());
  Serial.print(",");

  Serial.print(sensorTriad.getCalibratedG());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedH());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedI());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedJ());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedK());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedL());
  Serial.print(",");

  Serial.print(sensorTriad.getCalibratedR());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedS());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedT());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedU());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedV());
  Serial.print(",");
  Serial.print(sensorTriad.getCalibratedW());
  Serial.print(",");
  myMux.disablePort(Triad);
  Serial.println();
//l,r,s,t,u,v,w
}

float myDistance()  {
  Serial.println("dist4m : Inside Function myDistance"); 
  // Start PORT 1 for actual measurements
  //myMux.setPort(dist4m); //dist4m = 1; 
  tft.setFreeFont(FS9); 
  nY = ypos + 27;    //for multiple lines  - thereafter increment nY by 21
  tft.drawString("WIO_5S_R-Pressed               ", xpos, nY, GFXFF); 
  myMux.enablePort(dist4m); //dist4m = 1; 
  dist4mSensor.startRanging(); //Write configuration bytes to initiate measurement

  while (!dist4mSensor.checkForDataReady())
  {
    delay(1);
  }
  int distance = dist4mSensor.getDistance(); //Get the result of the measurement from the sensor
  dist4mSensor.clearInterrupt();

  dist4mSensor.stopRanging();

  Serial.print("Distance(mm): ");
  Serial.print(distance);
  nY = nY + 21;
//tft.drawString("WIO_5S_R-Pressed               ", xpos, nY, GFXFF); 
  tft.drawString("Distance (mm):" + String(distance), xpos, nY, GFXFF);
  float distanceInches = distance * 0.0393701;
  nY = nY + 21;
  tft.drawString("Distance (in):" + String(distanceInches), xpos, nY, GFXFF);  
  float distanceFeet = distanceInches / 12.0;
  nY = nY + 21;
  tft.drawString("Distance (ft):" + String(distanceFeet), xpos, nY, GFXFF);   

  Serial.print("\tDistance(ft): ");
  Serial.print(distanceFeet, 2);

  Serial.println();
  myMux.disablePort(dist4m);
  return(distanceInches);
}