Hi there,
I am trying to read absolute angles (0 - 360) from the MPU 6050 IMU. I am using acceleration from the IMU to calculate the angles. The issue is that the angles are correct only when my IMU is stable. If I start moving my IMU in Y or Z axis then the acceleration in that axis changes and my angles become corrupt. How to get the absolute angles from MPU 6050 so that motion does not affect my data. Below is my code snippet-
float get_pitch() {
// Request only the bytes for AcY and AcZ
Wire.beginTransmission(MPU_addr);
Wire.write(0x3D); // AcY high byte register
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr, 4, true); // 2 bytes each for AcY and AcZ
AcY = Wire.read() << 8 | Wire.read();
AcZ = Wire.read() << 8 | Wire.read();
// Calculate pitch using only AcY and AcZ
float pitch_raw = atan2(-AcY, -AcZ) * RAD_TO_DEG + 180.0f; // or your chosen formula/convention
//Filtered value (if Kalman filter is available)
pitch = kf_x.updateEstimate(pitch_raw);
return pitch;
}