MPU6050 Offset Setup confused

Hello,
So i am totally confused with respect of how to setup the MPU6050's I have read and read many post on many forums and the more I read the more confused I get.
I am using the jeff rowberg library that seems to be as good as it gets.
With #include "MPU6050_6Axis_MotionApps_V6_12.h" for the DMP
In my setup i have the following which i think is best for what i want to do:
mpu.setFullScaleAccelRange( MPU6050_ACCEL_FS_2 );
mpu.setFullScaleGyroRange( MPU6050_GYRO_FS_250 );
mpu.setDLPFMode( MPU6050_DLPF_BW_20 );

What is really unclear is when to use the offsets and what values to put in them
I tried setting them all to zero as below and post calibration the Yaw is about 70 deg out!
mpu.setXAccelOffset( 0 );
mpu.setYAccelOffset( 0 );
mpu.setZAccelOffset( 0 );
mpu.setXGyroOffset( 0 );
mpu.setYGyroOffset( 0 );
mpu.setYGyroOffset( 0 );
So I commented them all out and post calibration the Yaw is about 1 deg out but drifts in the first few seconds of run time to about 3 deg.
Then the drift just seems continue to changing in line with Earth Rotation eg about -0.25 deg per minute.

So I guess my question is, where to get the correct offset values from, are the post calibration then edited in pre calibration or is there some other function I need to call to get these offsets?
Many thanks in advance imk

The MPU6050 cannot measure yaw angles. A magnetometer is usually used for that.

The drift is due to the gyro offset. To remove that offset, record and average a few hundred gyro readings while the sensor is sitting still on the desk, then subtract those offsets from subsequent readings (one for each gyro axis).

jreminton Oh dear.
Gyros measure angular momentum/velocity as Yaw, Pitch and Roll, FULL STOP!
Drift is due Earth Rotation as MPU6050 measures coriolis which is greater the further you move up or down a longitude from the equator! hence if you are on or near to the equator your mpu6050 may not be sensitive enough earth rotation! I am at 53N hence it is quite strong here hence the drift i am measuring is Earths Rotation. See:

https://iopscience.iop.org/article/10.1088/0957-0233/23/2/025005
Thanks for tip on how to fix drift, but better to realize it is Earths Rotation and add 0.0041666 degs per second to the Yaw fifo output!
I do then get only drift of 1less than 1.5 deg per hour and i am hoping that getting the offset right will reduce this even more.
imk

The gyro in the MPU6050 measures the rates of rotation, along the sensor X, Y and Z axes.

These have nothing at all to do with the definitions of yaw, pitch and roll angles.

Good luck with your project!

Which is depending on its implementation Yaw, Pitch and Roll!
imk

I should have mentioned that the gyro rate offsets, and hence drift after integration, depend very strongly on temperature.

So you will want to measure and/or control the temperature carefully.

Have fun!

Founds this:

Hacked the EEPROM stuff out, got calibration numbers for this gyro and applied to my project, then two hour run with adjustment of 0.0041666 per second (earth rotation correction) and have a two hour error of 1.78 deg, therefore 0.89 deg per hours. Which i think is not to bad. from 28.23 deg difference in ypr[0] output. :slight_smile: many thanks Jeff Rowberg