Grove - 8 Channel I2C Multiplexer/I2C Hub (TCA9548A)

First you need to set the address of your sensors in hardware via the dedicated Address 0/1 jumpers on your board.
Then you can daisy chain up to four sensors per I2C interface.
Then according to the set addresses (0x0C, 0x0D, 0x0E & 0x0F) you can talk to the individual devices on the bus.

The MLX90393 even comes in multiple variants with a separate base address each with an individual sets of four “sub addresses”


which would allow to have up to 16 sensors on the same bus.

With the code above you’d just have to set the correct value where you currently use your constant Addr 0x0C.

I havent’t tested this library (due to lack of such sensors :wink: ) but it seems to make things a lot easier.
You’d create one instance of the library object per sensor and call the respective ::begin() function to setup the I2C interface and address.

something like this

#include <MLX90393.h> 

SerialLogHandler logger(LOG_LEVEL_ERROR, { { "app", LOG_LEVEL_INFO } });

const int SENSORS = 5;
MLX90393 mlx[SENSORS];              // sensor objects
MLX90393::txyz data[SENSORS];       // strcts to hold sensor data (t, x, y, z)

void setup() {
  Wire.begin();
  Wire1.begin();
  mlx[0].begin(0, 0, -1, Wire);     // A1, A0, no ready pin, I2C interface D0/D1 
  mlx[1].begin(0, 1, -1, Wire); 
  mlx[2].begin(1, 0, -1, Wire); 
  mlx[3].begin(0, 0, -1, Wire1);    //                       I2C interface D2/D3 
  mlx[4].begin(0, 1, -1, Wire1); 

  for (int s = 0; s < SENSORS; s++) {
    mlx[s].setOverSampling(0);
    mlx[s].setDigitalFiltering(0);
  }
}

void loop() {
  for (int s = 0; s < SENSORS; s++) {
    mlx[s].readData(data[s]);       // read all sensors
    Log.info("x: %6.2f, y: %6.2f, z: %6.2f, t: %4.1f °C"
            , data[s].x
            , data[s].y
            , data[s].z
            , data[s].t
            );
  }
  delay(100);
}