GY-521 MPU6050 3 Axis Gyroscope and Accelerometer With Arduino




Introduction: GY-521 MPU6050 3 Axis Gyroscope and Accelerometer With Arduino

About: Will write code for food. :) If you need help with any of your embedded Arduino applications please send me a message.

This video tutorial goes over the installation and setup of a GY-521 board with a MPU6050 3 Axis Gyroscope and Accelerometer with an Arduino. After some initial troubleshooting with I was able to get the component working. At first I had trouble with loose breadboard connections so I decided to solder in the pins that came with the component. That solved my problem and I was off and running. I used some 3D modeling software to illustrate the operation of the component.

Everything you need to duplicate this project can be found here:

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Solder Pins to the Component

The component came with two sets of pins which I highly recommend soldering to the component.

I tried testing with a breadboard at first but only ran into frustration as the connections were loose. I was able to get a red led on the board so my voltage and ground were connected. However, when I ran my MPU6050 software on the Arduino, my serial monitor would show the error message: "MPU6050 connection failed". Soldering the pins to the board solved the connection issue. So if you are having this error message and are using a breadboard, solder could solve the problem.

Step 2: Connect to Arduino

Now that you have your pins soldered to the component you can wire it up to the Arduino Uno.

VCC -> 5v


SCL -> A5

SDA -> A4

INT -> D2 (used for interrupt)

(the other pins do not need to be connected)

Step 3: Use I2C Scanner and MPU6050 Arduino Software

Using I2C Scanner, verify that the Arduino finds the device.

If the device is found then try using the MPU6050 example software to see if you get raw data.

The MPU6050 libraries can be downloaded here:

The I2C libraries can be downloaded here:

Note: if the output is random characters, make sure your serial connection is set to 9600 baud in the arduino setup.

Step 4: Run the MPU Teapot Example With Processor IDE

Download and install the Processor IDE.

You can download the Processor IDE here:

Then open the MPU Teapot example and change some code.


And uncomment the line: //#define OUTPUT_TEAPOT

will look like this:




You will also need to change some lines of code for the Arduino MPU6050 Teapot example:

String portName = “/dev/ttyUSB1”;.
Change "ttyUSB1" to the port where your Arduino is connected. eg. "COM3";

I had some trouble finding the Toxiclabs library needed for this demo but I eventually found it here:

You will need to modify some lines of code as detailed here:

Have Fun!

Be the First to Share


    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    5 Discussions


    3 years ago

    Hello, I am making a self balancing vehicle for my final year project using an MPU 6050, a Genuino board (might be a counterfeit), and a Cytron duo motor driver.

    However I am encountering a problem. The gyro sometimes starts giving out random absurd values and at times stops communicating. Do you think a problem with the MPU or the Arduino?


    Reply 1 year ago

    Hey anuj1993,you had read datasheet of your arduino's type which's you use it?I think that problem cause the clock frequency of arduino its small about 16Mhz until 84Mhz, when you try to run that program (MPU6050 DMP6) need more space to processing data and the timer its fastly( try to read MPU 6050.header and.c file on your folder).So, you need some module like ARM STM32Fxx with high clock frequency to processing that lrogram


    Question 1 year ago on Step 4

    Can i use something else as a model for the demonstration in processing?


    3 years ago

    hi i need the code of the MPU6050 for arduino Due.


    3 years ago

    i need help and ive seen your gyro led project, and its awesome and easy. can you instead of gyro, use the accelerometer values? example if accelx value is 2000-2500 led 1 lights up, value 2500-3000 led 1&2 lights up and so on. could you help? thanks alot!

    PS: i only need 1 accelerometer value, either x/y value.