MPU 6050 Yaw stability on startup/reset

Hi guys.

So I'm working on a VERY simple autopilot for a boat trolling motor, using the MPU6050 and a beefy RC servo.

Used MPU6050_DMP6.ino as a base for my script.

everything seems to be working well,

i'm using

    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);

    sensor = ypr[0];

to get the desired value (in radians, I believe). From my reading, this number should ALWAYS start at 0.00, because there is no internal magnetometer in the MPU6050 and it derives YAW or Z axis from the other two axis.

This seems to work VERY well... and there's almost zero drift, and 'startup calibration' is almost instantaneous because I've found the proper offset values using the calibration sketch.


sometimes when booting up, or resetting the arduino, the value isn't 0, or anywhere close to it.. (it's often 1.4, or -1.7... instead of 0.00 or 0.01). the number still varies as you'd expect when you move the sensor.

I've taken this into account with my programming, and subtracted the number from itself on startup, to avoid this glitch...

Does anyone know why it's not consistently starting at 0.00?

Thanks in advance

Here you have an example of how i am doing it using the mpu6050 and a pid loop code