Reading Multiple MPU 9250 Sensors using TCA9548A Multiplexer I am trying to read multiple MPU 9250 sensors using TCA9548A multiplexer in ESP 32 and Arduino IDE. Has anyone done that successfully?
I am new to the  area of Arduino coding. I am trying to edit the code in this tutorial for MPU 9250 (https://www.bluedot.space/tutorials/connect-multiple-sensors-using-i2c-multiplexer/). I am facing issues with libraries and commands while shifting from BME 280 to MPU 9250.  Once  I am changing to MPU 9250 and trying to call instance MPU9250 IMU_0, I am getting error &quot;no matching function for call to 'MPU9250&quot;, which I understand is because the library I've used doesn't support the call. I am unable to find alternate library or command. How can this be sorted out?
#include &lt;Wire.h&gt;
#include &lt;MPU9250.h&gt;
MPU9250 mpu_0;
MPU9250 mpu_1;
MPU9250 mpu_2;
MPU9250 mpu_3;

#define TCAADDR 0x70
void tcaselect(uint8_t i) {
  if (i &gt; 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 &lt;&lt; i);
  Wire.endTransmission();  
}
void setup() {
  Serial.begin(9600);
  Wire.begin();
  Serial.println(F(&quot;##############################&quot;));            
  Serial.println(F(&quot;Starting Initialization&quot;));
  Serial.println(F(&quot;##############################&quot;));       
 
  //*************INITIALIZING FIRST SENSOR*******************************   
  tcaselect(0);
    
  if (mpu_0.begin() != 0x68)
  { Serial.print(F(&quot;MPU.1 detected?\t&quot;)); Serial.println(F(&quot;No&quot;));}
  else
  { Serial.print(F(&quot;MPU.1 detected?\t&quot;)); Serial.println(F(&quot;Yes&quot;));}
  //**********************************************************************
  //*************INITIALIZING SECOND SENSOR*******************************  
  tcaselect(1);  
    
  if (mpu_1.begin() != 0x68)
  { Serial.print(F(&quot;MPU Nr.2 detected?\t&quot;)); Serial.println(F(&quot;No&quot;));}
  else
  { Serial.print(F(&quot;MPU Nr.2 detected?\t&quot;)); Serial.println(F(&quot;Yes&quot;));}
  //*********************************************************************      
  //**********************************************************************  
  Serial.println();
  Serial.println(F(&quot;##############################&quot;));            
  Serial.println(F(&quot;Initialization Finished&quot;));
  Serial.println(F(&quot;##############################&quot;));            
  Serial.println();
  Serial.println();
}
You need to adapt the example you're following to follow how the MPU library does its construction and setup.
Looking at the documentation for the MPU library you are using, you should change the definitions to:
 
MPU9250 mpu_0(Wire, 0x68);  // 0x69 if you pulled AD0 high

Then if you read further to the &quot;Common Setup Functions&quot; section, you'll see that this library's setup function has this behavior:

This function returns a positive value on a successful initialization and returns a negative value on an unsuccesful initialization

So you need to adapt that too:
Serial.print(F(&quot;MPU.1 detected?\t&quot;));
if (mpu_0.begin() &lt; 0) { // the examples assume zero is ok too
  Serial.println(F(&quot;No&quot;));
} else {
  Serial.println(F(&quot;Yes&quot;));
}

You'll save yourself some trouble if you use an array for your sensors too.
MPU9250 mpus[] = { MPU9250(Wire, 0x68), MPU9250(Wire, 0x68) }; 
const int num_mpus = sizeof(mpus)/sizeof(mpus[0]);

Then your initialization can be done with a loop:
for (int i = 0; i &lt; num_mpus; ++i) {
   tcaselect(i);
   if (mpus[i].begin() &lt; 0) {
     // ...
   }
 }

And you can do similar things for interacting with the sensor. e.g.:
for (int i = 0; i &lt; num_mpus; ++i) {
   tcaselect(i);
   mpus[i].readSensor();
   Serial.println(mpus[i].getAccelX_mss());
   // ...
 }