Jump to content
I2Cdevlib Forums

MPU-6050 DMP random Z offset on startup (Solved?)

Recommended Posts


I've been struggling with a couple of MPU-6050's and I think I've found a solution for my problem so I'd like to share this..

I'm using the teapot arduino sketch as the base for my project.
After calibrating offsets (there are some topics about this on the forum) the first MPU-6050 worked really good but the other two had some problem.

I'm using quaternions and most of the time it started with a Z value near zero (like 0.008830) but sometimes it started with a random Z value (like 0.403030, 0.94000, etc).
I've tried compiling the skecth enabling DEBUG on MPU6050_6Axis_MotionApps20.h and the problem dissapeared. 

It seems that there is a timing problem on the initialization function but it only affects some modules.
I've solved my problem in a quick and dirty way by disabling DEBUG and adding an small delay in each DEBUG_PRINT* function.

Something like this:

#ifdef DEBUG
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTF(x, y) Serial.print(x, y)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #define DEBUG_PRINTLNF(x, y) Serial.println(x, y)
    #define DEBUG_PRINT(x)    delay(1)
    #define DEBUG_PRINTF(x, y)  delay(1)
    #define DEBUG_PRINTLN(x)  delay(1)
    #define DEBUG_PRINTLNF(x, y)  delay(1)

I know it requires further investigation but for now the problem is solved, at least in my case.
I Hope this is useful for someone else.






Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...