MPU6050 Connection Failed

Hi, I'm trying to use the MPU6050. I'm running it off a uno, with 5v and ground twisted, scl & sda twisted & 5k1 pull up resistors (don't have 4.7) to 5v, and a short INT to I/O pin 2. I'm using the example from ElectricalCat's MPU6050 library: https://github.com/ElectronicCats/mpu6050/blob/master/examples/MPU6050_DMP6_using_DMP_V6v12/MPU6050_DMP6_using_DMP_V6v12.ino

I get the connection failed message every once in a while, seemingly randomly. When it fails, the uno stops printing the readings from the axyl. If I reset after it fails, it will just say that the connection failed.
(code regarding connection failed)

  Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

Here's the trouble shooting I've done so far:

  • Entirely removing the INT connector, and directly connecting the pin, bypassing the breadboard. --> INT connection isn't required for the connection to succeed or fail.
  • Plugging and unplugging the power to the axyl (resetting the MPU6050) always results in the next reset having a successful connection.
  • Directly bypassing the breadboard for both SDA and SCL pins does not result in a consistent connection.
  • There was one time when the readings kept on coming, and yet wouldn't change when I moved the axyl. The axyl does read correctly otherwise - might've been a fluke.
  • There was one time when resetting the arudino did nothing. I didn't receive the next print statements from serial, but moving things around got it to work eventually. I also changed the cable to the uno, so it shouldn't be the issue.

My main idea is there's some loose connection somewhere, and it's throwing everything off. It could also be a bad board, but intermittent function doesn't seem like a manufacturing mistake.

Any suggestions are appreciated. Thanks!

MPU6050 is an i2c interface. Are there adequate pullup resistors on the SDA and SCK lines?

Easy way to tell is voltmeter check voltages on those lines. When idle, the lines should be near V+, not gnd.

While 5.1kΩ pull-up resistors are close to the recommended 4.7kΩ, the actual value might affect the communication stability. If possible, try to use 4.7kΩ resistors. Keep the I2C wires (SDA and SCL) as short as possible to reduce the chances of noise or interference. For more info regarding this module, you can see here:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.