Skip to content

Arduino Uno MPU6050: Get I2C motion readings | ShillehTek

October 22, 2023

Video Tutorial (Optional)

Watch first if you want to follow the full Arduino Uno + MPU6050 setup in real time.

Project Overview

In this project, you connect an Arduino Uno to an MPU6050 (GY-521) 6-axis accelerometer + gyroscope module and upload an example sketch to get live motion readings over I2C in the Serial Monitor.

The MPU6050 combines a 3-axis accelerometer, a 3-axis gyroscope, and a temperature sensor in a compact module. It is commonly used for orientation, motion, and tilt detection in robotics and interactive projects.

  • Time: 15 to 30 minutes
  • Skill level: Beginner
  • What you will build: A working Arduino Uno + MPU6050 I2C setup that outputs accelerometer and gyroscope readings

Parts List

From ShillehTek

External

Note: Use discount code SHILLEHTEK for 30% off on ShillehTek. The MPU6050 VCC pin typically supports 3.3V or 5V depending on the breakout, and this guide uses the common 4-wire I2C pins (VCC, GND, SDA, SCL).

Step-by-Step Guide

Step 1 - Physical setup (wire MPU6050 to Arduino Uno)

Goal: Connect the MPU6050 to the Arduino Uno using I2C so the board can read motion data.

What to do: Use four jumper wires and wire the MPU6050 pins to the Arduino Uno as shown in the diagram.

Pin meanings:

  • GND - ground reference for the circuit
  • VCC - power input (typically 3.3V or 5V depending on the module)
  • SCL - I2C clock line
  • SDA - I2C data line

The MPU6050 also has additional pins that are not used in this tutorial:

  • XDA - auxiliary I2C data
  • XCL - auxiliary I2C clock
  • ADO - I2C address select
  • INT - interrupt output
Arduino Uno wired to an MPU6050 (GY-521) module with four I2C jumper wires (VCC, GND, SDA, SCL)
Wiring diagram for connecting the MPU6050 to the Arduino Uno using I2C.
Close-up photo of an MPU6050 (GY-521) motion sensor module used with Arduino
MPU6050 module example.
Infographic showing micro-soldering concept related to sensor module header pins
ShillehTek MPU6050 modules are pre-soldered to save time during assembly.

Expected result: The MPU6050 is powered and connected to the Arduino Uno via SDA/SCL and is ready for code upload.

Step 2 - Code setup in the Arduino IDE

Goal: Install the required library and upload an example sketch that prints MPU6050 readings.

What to do: This tutorial assumes you already have the Arduino IDE installed and know how to connect your Arduino Uno.

  • In the Arduino IDE, go to Tools and select the correct Board and Port for your Arduino Uno.
  • Open the Library Manager (left side of the Arduino IDE) and install the Adafruit MPU6050 library along with its dependencies.
  • Go to File > Examples, then scroll to Adafruit MPU6050 and open the included example sketch.
  • Select basic_readings.ino and upload it to the Arduino Uno using the Upload button.
Arduino IDE Tools menu showing Arduino Uno board and serial port selection
Select the correct board and port in the Arduino IDE.
Arduino IDE Library Manager showing Adafruit MPU6050 library installation
Install the Adafruit MPU6050 library and required dependencies.
Arduino IDE File Examples menu highlighting Adafruit MPU6050 example sketches
Open the example sketch from File > Examples > Adafruit MPU6050.
Arduino IDE example sketch selection showing basic_readings.ino for the MPU6050
Select and upload the basic_readings.ino example.

Expected result: The sketch uploads successfully, and you can open the Serial Monitor to see continuous motion sensor readings.

Step 3 - Verify readings in the Serial Monitor

Goal: Confirm the Arduino Uno is receiving live accelerometer and gyroscope data from the MPU6050.

What to do: Open the Serial Monitor after uploading the example sketch and watch the output.

Arduino IDE Serial Monitor showing live MPU6050 accelerometer and gyroscope readings from an Arduino Uno
Example output showing sensor readings.

Expected result: You see a stream of values updating in real time as the MPU6050 moves.

Conclusion

You just connected an Arduino Uno to an MPU6050 over I2C and used the Adafruit example sketch to get live accelerometer and gyroscope readings. This is a solid starting point for projects that need orientation, motion tracking, or tilt detection.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project for a robot, product demo, or a larger system, check out our IoT consulting services. You can also watch the full video on YouTube.