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 "no matching function for call to 'MPU9250", 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 <Wire.h>
#include <MPU9250.h>
MPU9250 mpu_0;
MPU9250 mpu_1;
MPU9250 mpu_2;
MPU9250 mpu_3;
#define TCAADDR 0x70
void tcaselect(uint8_t i) {
if (i > 7) return;
Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
}
void setup() {
Serial.begin(9600);
Wire.begin();
Serial.println(F("##############################"));
Serial.println(F("Starting Initialization"));
Serial.println(F("##############################"));
//*************INITIALIZING FIRST SENSOR*******************************
tcaselect(0);
if (mpu_0.begin() != 0x68)
{ Serial.print(F("MPU.1 detected?\t")); Serial.println(F("No"));}
else
{ Serial.print(F("MPU.1 detected?\t")); Serial.println(F("Yes"));}
//**********************************************************************
//*************INITIALIZING SECOND SENSOR*******************************
tcaselect(1);
if (mpu_1.begin() != 0x68)
{ Serial.print(F("MPU Nr.2 detected?\t")); Serial.println(F("No"));}
else
{ Serial.print(F("MPU Nr.2 detected?\t")); Serial.println(F("Yes"));}
//*********************************************************************
//**********************************************************************
Serial.println();
Serial.println(F("##############################"));
Serial.println(F("Initialization Finished"));
Serial.println(F("##############################"));
Serial.println();
Serial.println();
}