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 www.UTsource.net

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

GND -- GND

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!

Share

    Recommendations

    • Games Contest

      Games Contest
    • Stone Concrete and Cement Contest

      Stone Concrete and Cement Contest
    • Sensors Contest

      Sensors Contest

    Discussions