i2cdevlib icon indicating copy to clipboard operation
i2cdevlib copied to clipboard

MPU6050_6Axis_MotionApps_V6_12 get stuck in loop due to my MU6050 ID(0xC)

Open williamesp2015 opened this issue 2 years ago • 5 comments

My sensors (MPU6050) return 0xC instead of 0x34 even though I modified getDeviceID to always return 0x34. uint8_t MPU6050_Base::getDeviceID() { I2Cdev::readBits(devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, buffer, I2Cdev::readTimeout, wireObj); if((buffer[0]==0x34) || (buffer[0]==0xC)) return 0x34; } but it stuck at loop when whants to get packet using mpu.getFIFOBytes(fifoBuffer, packetSize); . So I have to use uint8_t MPU6050_6Axis_MotionApps20 Any advice would be appreciated.

williamesp2015 avatar Oct 20 '21 04:10 williamesp2015

I need the values of MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH

Serial.print("MPU6050_RA_WHO_AM_I = " );
Serial.printf(MPU6050_RA_WHO_AM_I );
Serial.printf("MPU6050_WHO_AM_I_BIT = ");
Serial.printf(MPU6050_WHO_AM_I_BIT);
Serial.printf("MPU6050_WHO_AM_I_LENGTH = ");
Serial.printf(MPU6050_WHO_AM_I_LENGTH);

add this to your startup and give me the values.

Z

ZHomeSlice avatar Oct 20 '21 06:10 ZHomeSlice

Also, you should use this function instead of getFIFOBytes it will handle overflow and other failure modes for you

if (mpu.dmpGetCurrentFIFOPacket(fifoBuffer)) { // Get the Latest packet 
    // We got a new packet and we should do something with all the new data here
}

Z

ZHomeSlice avatar Oct 20 '21 06:10 ZHomeSlice

I'm seeing this as a duplicate discussion, not an issue related to the mpu6050 library code as I have not had any issues related to what is happening. If no further information is provided we can close this one.

ZHomeSlice avatar Oct 21 '21 16:10 ZHomeSlice

I need the values of MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH

Serial.print("MPU6050_RA_WHO_AM_I = " );
Serial.printf(MPU6050_RA_WHO_AM_I );
Serial.printf("MPU6050_WHO_AM_I_BIT = ");
Serial.printf(MPU6050_WHO_AM_I_BIT);
Serial.printf("MPU6050_WHO_AM_I_LENGTH = ");
Serial.printf(MPU6050_WHO_AM_I_LENGTH);

add this to your startup and give me the values.

Z At the end of Initialize(), I got: MPU6050_RA_WHO_AM_I =117 MPU6050_WHO_AM_I_BIT =6 MPU6050_WHO_AM_I_LENGTH =6

williamesp2015 avatar Oct 25 '21 10:10 williamesp2015

your reading the correct buffer address and the correct bytes I would now assume that your MPU6050 has a programming flaw with the MPU6050_RA_WHO_AM_I i2c address Byte.

Since you have access to the device you can ignore those lines of code. Z

ZHomeSlice avatar Oct 25 '21 15:10 ZHomeSlice