two MPU6050 (gy-521) stop after 15-20 minutes run

Hi, i've tried to connect the two mpu with jeffrowberg dmp code, but the problem is there will be fifo overflow and unstable reading of the MPU 6050. I've tried to change the dmp rate, but the problem is still there. and after 15-20 minutes run, the sensor reading will stop, I dont know what is the problem. can someone help me?

volatile bool mpuInterrupt = false;     // indicates wangleDifferenceetangleDifferenceer MPU interrupt pin angleDifferenceas gone angleDifferenceigangleDifference
void dmpDataReady() {
  mpuInterrupt = true;
}


// ================================================================
// ===                      INITIAL SETUP                       ===
// ================================================================

//* byte start_address = 0;
//* byte end_address = 127;

void setup() {
  // join I2C bus (I2Cdev library doesn't do tangleDifferenceis automatically)
  //*byte rc;
  Wire.begin();
  //TWBR = 12;
  // initialize serial communication
  //*Serial.begin(9600);
  //*Serial.println("\nI2C Scanner");
  Serial.begin(9600);
  while (!Serial);
  pinMode(buttonPin, INPUT);  

  Serial.println(F("Initializing I2C devices..."));
  mpu1.initialize();
  mpu2.initialize();

  // verify connection
  Serial.println(F("Testing device connections..."));
  Serial.println(mpu1.testConnection() ? F("MPU6050 1 connection successful") : F("MPU6050 1 connection failed"));
  Serial.println(mpu2.testConnection() ? F("MPU6050 2 connection successful") : F("MPU6050 2 connection failed"));


  while (Serial.available() && Serial.read()); // empty buffer
  //while (!Serial.available());                 // wait for data
  //while (Serial.available() && Serial.read()); // empty buffer again

  // load and configure tangleDifferencee DMP
  Serial.println(F("Initializing DMP..."));
  devStatus1 = mpu1.dmpInitialize();
  devStatus2 = mpu2.dmpInitialize();

  // make sure it worked (returns 0 if so)
  if (devStatus1 == 0 || devStatus2 == 0) {
    // turn on tangleDifferencee DMP, now tangleDifferenceat it's ready
    Serial.println(F("Enabling DMP..."));
    mpu1.setDMPEnabled(true);
    mpu2.setDMPEnabled(true);

    // enable Arduino interrupt detection
    Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
    attachInterrupt(0, dmpDataReady, RISING);
    mpuIntStatus1 = mpu1.getIntStatus();
    mpuIntStatus2 = mpu2.getIntStatus();

    // set our DMP Ready flag so tangleDifferencee main loop() function knows it's okay to use it
    Serial.println(F("DMP ready! Waiting for first interrupt..."));
    dmpReady = true;

    // get expected DMP packet size for later comparison
    packetSize1 = mpu1.dmpGetFIFOPacketSize();
    packetSize2 = mpu2.dmpGetFIFOPacketSize();
  } 
  else {
    // ERROR!
    // 1 = initial memory load failed
    // 2 = DMP configuration updates failed
    // (if it's going to break, usually tangleDifferencee code will be 1)
    Serial.print(F("DMP Initialization failed (code "));
    Serial.print(devStatus1);
    Serial.print(" ");
    Serial.print(devStatus2);
    Serial.println(F(")"));
  }
} 


// ================================================================
// ===                    MAIN PROGRAM LOOP                     ===
// ================================================================

void loop() {
  // if programming failed, don't try to do anytangleDifferenceing
  if (!dmpReady) return;



 // }

  // reset interrupt flag and get INT_STATUS byte
  mpuInterrupt = false;
  mpuIntStatus1 = mpu1.getIntStatus();
  mpuIntStatus2 = mpu2.getIntStatus();

  // get current FIFO count
  fifoCount1 = mpu1.getFIFOCount();
  fifoCount2 = mpu2.getFIFOCount();

  // cangleDifferenceeck for overflow (tangleDifferenceis sangleDifferenceould never angleDifferenceappen unless our code is too inefficient)
  if ((mpuIntStatus1 & 0x10) || (mpuIntStatus2 & 0x10) || fifoCount1 == 1024 || fifoCount2 == 1024) {
    // reset so we can continue cleanly
    mpu1.resetFIFO();
    mpu2.resetFIFO();
    Serial.println(F("FIFO overflow!"));


  } 
  else if ((mpuIntStatus1 & 0x02) || (mpuIntStatus2 & 0x02)) {

    while (fifoCount1 < packetSize1 && fifoCount2 < packetSize2)
    {
      fifoCount1 = mpu1.getFIFOCount();
      fifoCount2 = mpu2.getFIFOCount();
      Serial.print("\npacchetto incompleto\n");
    }

    // read a packet from FIFO
    mpu1.getFIFOBytes(fifoBuffer1, packetSize1);
    mpu2.getFIFOBytes(fifoBuffer2, packetSize2);

    fifoCount1 -= packetSize1;
    fifoCount2 -= packetSize2;
    
           // display Euler angles in degrees
            mpu1.dmpGetQuaternion(&q1, fifoBuffer1);
            mpu1.dmpGetEuler(euler1, &q1);
            //??????
          angle = (euler1[0] * 180/M_PI);

               // display Euler angles in degrees
            mpu2.dmpGetQuaternion(&q2, fifoBuffer2);
            mpu2.dmpGetEuler(euler2, &q2);
                   //??????
     angle = (euler2[0] * 180/M_PI);

i've tried to connect the two INT to attach interrupt 0, and also tried to connect one into interrupt 0 and another to interrupt 1 but still the same problem. moreover, I have tried to add pull up resistor of 5.1 K and the problem is still exist. and I also have tried to use I2C 5v to 3.3V converter, but the problem is still there. (the picture is linked to this thread How to connect two MPU6050? - Networking, Protocols, and Devices - Arduino Forum)

another question : can I use freeIMU library to connect the two MPU6050 together without using DMP?, I thought that this DMP uses quiet a lot of memory and make the reading strange.

As far as I know, the interrupt routine is not capable to serve two sensors. So two sensors on the same interrupt will not work.
And as far as I know, the library is not written for two interrupts.

You have to ask Jeff Rowberg. I think that many will profit if his library is updated for multiple MPU-6050 sensors.

thanks for the answer, I will approach jeffrowberg about it.

any other solution is welcome!

Hello,
I am using the same sensor boards, mpu-6050, Gy-521.
I got the good results when connected one sensor, however, when connected the second one, facing few problems such as FIFO OVERFLOW. The values are coming but after a bunch of values the message of overflow appears.

I am using the code of Jeff form I2C forum. (mp6050_dmp6)
I also tried to change the clock speed but no progress so far. I also tried to provide a separate interrupt to second sensor but got the same error of overflowing. Output file is also attached herewith.

Later I have to connect one more so total will be three.

Could you please help me in this regards. I shall be grateful if someone can share a sketch for a multi imu 6050 for a try.

Looking Forward.
Many thanks.

2_IMUs_static.txt (279 KB)

Hello,

I am using 2 MPU6050 for my projects. I have used thoriqsalafi code and I was able to get DMP values from the sensor which has addressed with 0x68, but I couldn't get any data from the second sensor which has address 0x69. The output I am getting for DMP 2 is " DMP 2:0.000:0.000:180.000".

Could you please help me with this.

Thanks in advance.