mpu-6050 code freezes

My mpu-6050 for navigation robot freezes while it is running the entire code with interrupt pin 2. I do not know why, but it seems to be a common issue for many mpu-6050 gyroscope users. Can anyone let me know how to tackle this issue who have solved this problem?

This is my pin configuration:
//VDD on Gyro chip connected to → 3.3V pin on arduino
//INT → digital pin 2
//SCL → analog pin A5
//SDA → analog pin A4
//VIO → VDD on gyro(3.3V)

The AD0 pin is left unconnected. Not sure if i should connect it to ground. I have attached my gyro setup code for all to see. Looking forward to your response.

Gyro Setup.txt (1.58 KB)


include "I2Cdev.h"

include "MPU6050_6Axis_MotionApps20.h"


include "Wire.h"


MPU6050 mpu;


bool blinkState = false; bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer Quaternion q; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float yaaaw[1];/////////////////////////////////////////////////////////////// uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' }; // ================================================================ // === Gyro INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; }