MPU6050 Setup and Calibration Guide

Introduction: MPU6050 Setup and Calibration Guide

About: I'm from India and love making projects on electronics, specially with arduino. Internet is the only guidance I have and I've been into these since I was 11.

MPU6050 is a 6 DoF(Degrees of freedom) IMU which stands for inertial measurement unit, a really great sensor to know the Angular acceleration through 3 Axis Gyroscope and Linear Acceleration through Linear Accelerometers.

It can be tricky at times to get started and set up, searching libraries and programs all over the internet, but do not worry now, this instructable and the video tutorial attached below will get you started in no time.

Step 1: Materials Required

1.) MPU6050 or GY521 IMU

2.) Arduino (I'm using Nano)

3.) Computer with Arduino IDE installed within

4.) USB Cable for Arduino

5.) 4 F to F Jumper Cables to connect Arduino to MPU6050

All components, original and high quality can be found at

Step 2: The MPU6050 Library

If you have any problem following this step, I highly recommend watching the video tutorial linked in the intro.

A library is a simple tool which makes it easy for beginners to use relatively complex sensors such as MPU6050 in a really simple manner, it is a layer which already takes care of many many complex things so that we could focus more on implementing the idea instead of setting up everything.

Open Arduino IDE

Go to Tools and click on Manage Libraries

A new window will open which will have a search bar, therein type MPU6050, you will be greeted with more than one results, but install the one which is bt Electronic Cats.

You're done, now lets calibrate!

Step 3: Calibration

Every sensor is different and unique, so we must find the unique Offset Values for the sensor we have.

Open Files and go to Examples in Arduino IDE.

There, you will see a new library which says MPU6050 which contains a program named - IMU_Zero open it.

Upload it to arduino and make sure the connection from Arduino to Sensor is done in following way -

SCL -- A5

SDA -- A4

Vcc -- 5V


After successful upload, open Tools And then Serial Monitor, but make sure to keep the sensor horizontal and as still as possible during this process.

A "----- done -----" line will indicate that it has done its best.
With the current accuracy-related constants (NFast = 1000, NSlow = 10000), it will take a few minutes to get there.

Along the way, it will generate a dozen or so lines of output, showing that for each of the 6 desired offsets, it is * first, trying to find two estimates, one too low and one too high, and * then, closing in until the bracket can't be made smaller.

The line just above the "done" line will look something like [567,567] --> [-1,2] [-2223,-2223] --> [0,1] [1131,1132] --> [16374,16404] [155,156] --> [-1,1] [-25,-24] --> [0,3] [5,6] --> [0,4] As will have been shown in interspersed header lines, the six groups making up this line describe the optimum offsets for the X acceleration, Y acceleration, Z acceleration, X gyro, Y gyro, and Z gyro, respectively. In the sample shown just above, the trial showed that +567 was the best offset for the X acceleration, -2223 was best for Y acceleration, and so on. Note every offset to use in the programs that you make!

That's it! simple and straightforward!

Thanks for reading!

Be the First to Share


    • Pumpkins & Gourds Speed Challenge

      Pumpkins & Gourds Speed Challenge
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Organization Contest

      Organization Contest



    4 months ago

    This article was straightforward and easy-to-follow. I was able to get the results shown. Just one question . . . WHERE DO I USE THIS OFFSET DATA? I do not see any codes that say "insert callibration data here" so I am at a standstill. Any help would be appreciated.


    Reply 4 months ago

    Nevermind;). I watched the video where the information I was seeking is clearly presented. Thanks.


    Reply 2 months ago

    Hello I m Özgür , I saw ur comment about MPU6050 ,I have the same question 😀where should I use these offset values and can u send me that video you watched about it ?

    Thanks in advance


    Reply 2 months ago

    Found it! IMU_Zero is a program found in the "MPU^)%)" library which can be downloaded through Arduino/Sketch/Include Library and typing in MPU6050 when the pop-up window opens. This will run a multiplicity of tests and return three Accelerometer and three gyro offset values. From one MPU6050, an offset for acc. can run from -4521 to 3780 and those are just the ones I have worked on.

    I then used the MPU6050_DM6 sketch and inserted the values where requested. I modified the DM6 sketch to serve my purposes and the stability is awesome from one device to another.


    Question 3 months ago on Introduction

    Thanks for the great article.
    I tried this and followed the video; everything worked until I tried to test using DMP6.
    The response seemed unusual and included a number of winding characters.

    InitiTesting device connections...
    MPU6050 connection successful
    Send any character to begin DMP programming and demo:
    ⸮<⸮أm⸮⸮1⸮⸮⸮⸮җ:[⸮b⸮⸮⸮⸮⸮⸮⸮⸮⸮)⸮ j⸮0⸮⸮Z⸮P⸮⸮⸮⸮0⸮⸮

    What does this mean?


    Question 1 year ago on Step 3

    I get an "MPU6050 connection failed" error.
    Then it just keeps pushing a new asterisks .
    Do you know what could cause this issue?

    Thank you


    Answer 7 months ago

    The exact same thing is happening to me. I don't know the answer.


    Reply 6 months ago

    Check baud rate on serial monitor. I had the same thing then matched baud rate to that specified on sketch. Instant success!


    Reply 6 months ago

    Thank you for your reply. I had the correct baud rate, the problem turned out to be a sensor that was either faulty or what is deemed to be a counterfeit. The "who am I" register contained the address 0x72 instead of 0x68. I replaced the sensor (breakout board) and the problem was solved. Thank you again.