Connecting Multi MPU6050 using I2C on ESP32 Wroom 32D

I want to connect two MPU6050 sensor on Esp32 using the I2C protocol.

ESP32 to MPU6050 connection, I'm using -

VCC(ESP32) - VCC(MPU6050_1) - VCC(MPU6050_2)
GND(ESP32) - GND(MPU6050_1) - GND(MPU6050_2)
G21(ESP32) - SDA(MPU6050_1) - SDA(MPU6050_2)
G22(ESP32) - SCL(MPU6050_1) - SCL(MPU6050_2)

3V (ESP32) - AD0 (MPU6050_2)

and both the MPU6050 device are also detected by the I2C scanner program 0x68 , 0x69

but when the basic reading program to read for MPU6050 data , one MPU6050 is giving zero value for all accelerate axis and gyro axis.

// Basic demo for accelerometer readings from Adafruit MPU6050

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>

Adafruit_MPU6050 mpu1;
Adafruit_MPU6050 mpu2;

void setup(void) {
  Serial.begin(115200);
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit MPU6050 test!");


  // Try to initialize!
  if (!mpu1.begin(0x68)) {
    Serial.println("Failed to find MPU6050 chip1");
    while (1) {
      delay(10);
    }
  }

  if (!mpu2.begin(0x69)) {
    Serial.println("Failed to find MPU6050 chip2");
    while (1) {
      delay(10);
    }
  }
  Serial.println("MPU6050 Found!");

  mpu1.setAccelerometerRange(MPU6050_RANGE_8_G);

  mpu1.setGyroRange(MPU6050_RANGE_500_DEG);
  
  mpu1.setFilterBandwidth(MPU6050_BAND_21_HZ);

  mpu2.setAccelerometerRange(MPU6050_RANGE_8_G);

  mpu2.setGyroRange(MPU6050_RANGE_500_DEG);
  
  mpu2.setFilterBandwidth(MPU6050_BAND_21_HZ);
  
  Serial.println("");
  delay(100);
}

void first() {

  /* Get new sensor events with the readings */
  sensors_event_t a, g, temp;
  mpu1.getEvent(&a, &g, &temp);

  Serial.println("Sensor 1");

  /* Print out the values */
  Serial.print("Acceleration X: ");
  Serial.print(a.acceleration.x);
  Serial.print(", Y: ");
  Serial.print(a.acceleration.y);
  Serial.print(", Z: ");
  Serial.print(a.acceleration.z);
  Serial.println(" m/s^2");

  Serial.print("Rotation X: ");
  Serial.print(g.gyro.x);
  Serial.print(", Y: ");
  Serial.print(g.gyro.y);
  Serial.print(", Z: ");
  Serial.print(g.gyro.z);
  Serial.println(" rad/s");

  Serial.print("Temperature: ");
  Serial.print(temp.temperature);
  Serial.println(" degC");

  Serial.println("");
  delay(500);
}

void second() {

  /* Get new sensor events with the readings */
  sensors_event_t a, g, temp;
  mpu2.getEvent(&a, &g, &temp);

  Serial.println("Sensor 2");

  /* Print out the values */
  Serial.print("Acceleration X: ");
  Serial.print(a.acceleration.x);
  Serial.print(", Y: ");
  Serial.print(a.acceleration.y);
  Serial.print(", Z: ");
  Serial.print(a.acceleration.z);
  Serial.println(" m/s^2");

  Serial.print("Rotation X: ");
  Serial.print(g.gyro.x);
  Serial.print(", Y: ");
  Serial.print(g.gyro.y);
  Serial.print(", Z: ");
  Serial.print(g.gyro.z);
  Serial.println(" rad/s");

  Serial.print("Temperature: ");
  Serial.print(temp.temperature);
  Serial.println(" degC");

  Serial.println("");
  delay(500);
}

void loop(){

  first();

  delay(1000);

  second();
  
}

All connection and config are correct both still MPU6050 sensor two not giving the correct data.

I request you to please check and see, what wrong I'm doing in it.

I moved your topic to an appropriate forum category @sourabh10397.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Welcome to the forum.

The sketch seems okay, so we have to look further.

If you have a module with a voltage regulator and you feed VCC with 3.3V, then the MPU-6050 runs at maybe 2.3V.

If you bought your MPU-6050 from Ebay/AliExpress/Amazon, then it is a counterfeit.

If you have both problems (a counterfeit at 2.3V) then anything can happen.

How long are the wires of the I2C bus ? (should be short).
Do you use SDA next to SCL in a flat ribbon cable ? (never do that).
Are you using a breadboard and jumper wires ? (could be bad quality).

Yes, we check the all the possibility but one point i want to draw your attention is one MPU6050 is giving good data but the second one is giving the wrong data (Zero for Acceleration and Rotation).
for your reference, I'm sharing the serial monitor -

Adafruit MPU6050 test!
MPU6050 Found!

Sensor 1
Acceleration X: -2.18, Y: 1.27, Z: 9.20 m/s^2
Rotation X: 0.23, Y: 8.34, Z: 2.97 rad/s
Temperature: 31.69 degC

Sensor 2
Acceleration X: 0.00, Y: 0.00, Z: 0.00 m/s^2
Rotation X: 0.00, Y: 0.00, Z: 0.00 rad/s
Temperature: 36.53 degC

Sensor 1
Acceleration X: -2.21, Y: 1.29, Z: 9.17 m/s^2
Rotation X: 0.06, Y: 8.29, Z: 2.96 rad/s
Temperature: 31.70 degC

Sensor 2
Acceleration X: 0.00, Y: 0.00, Z: 0.00 m/s^2
Rotation X: 0.00, Y: 0.00, Z: 0.00 rad/s
Temperature: 36.53 degC

Change the AD0 connections to swap the addresses between the two sensors. Which one gives zero readings after?

Connect the two sensors each in turn, with the other sensor completely disconnected. Do both sensors work correctly when used alone?

Yes, I tested both the sensor alone, it working fine.

A sensor whose AD0 is connected to 3V is giving the zero value even after the swap both the sensor.

Can you show a photo that shows the module and AD0 ?
Or you could step out of the trouble and buy other genuine sensors.

I assume that you did it right and that the counterfeit sensor has a problem.

Ok, that's good.

I also cannot see a problem in your code. (I have several ideas to improve it, but after you get both sensors working.)

Test this also: connect each sensor alone, but with AD0 pulled high and using address 0x69.

I hope it would be a little higher than that, maybe ~3V if a truly LDO regulator is used. But boards from eBay etc may not have good quality regulators, I guess.