MPU6050 Sketch/Device Freezes


I am trying to interface with the MPU6050 Gyro/Accelerometer board using my Arduino Leonardo. When running the MPU6050_DMP6 example sketch, it will receive the serial output for about 5-20 seconds, and then stop. I notice that, when this happens, the TX led on my board goes out. I would appreciate any help figuring out why this might be happening.

My Pinout: VCC --> 3.3V Gnd --> Gnd SCL --> 3 SDA --> 2 INT --> 7

The data I am receiving seems to be accurate, so the only issue is the stopping/freezing. Many thanks for your responses!

Hi, welcome to the forum.

Use 5V for VCC if the module has a 3.3V voltage regulator onboard.

Did you change the library for interrupt 4 (pin 7 of Leonarod) instead of interrupt 0 (pin 2 for the Uno).

There was someone on the forum, who had trouble using interrupt 4 at pin 7. I forgot if he got it working.

Hello, and thank you!

I believe it does have a voltage regulator, though switching to 5V didn’t seem to make a difference.

I had not changed the library, and doing so seemed to do the trick. I changed the following line:

		attachInterrupt(4, dmpDataReady, RISING);

(the 4 was originally a 0, I believe).

Is there any benefit to using the 5V vs the 3.3V?

Thank you again!

Yes, but it is a long story, and it depends on the MPU-6050 module that you use.

Long story: The ATmega chip in I2C mode needs 0.7*5V = 3.5V for a valid 'high' for SDA and SCL. The MPU-6050 is a 3.3V sensor, and the module has probably pullup resistors from SDA and SCL to 3.3V. The ATmega chip has also 50k internal pullup resistors to 5V, those help a little to get the SDA and SCL a little above 3.3V and hopefully not destroying the MPU-6050. The result is that the MPU-6050 connected to the Arduino Leonardo barely works, the voltage levels are outside the specifications. When 3.3V is applied to the module VCC, the 3.3V regulator makes 3.2V out of that. That means that the SDA and SCL voltage levels are even lower. When 5V is applied, the sensor works at a nice 3.3V. A I2C level shifter can avoid all these problems. Some modules have level shifting on the board already.