DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
accelerometer

MPU6050 Tutorial: How to Program the MPU-6050 With Arduino

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The quickest reliable path is to connect an MPU-6050 breakout to your Arduino’s I2C bus, install Adafruit’s three-library stack, run its basic_readings example, and confirm acceleration, rotation and temperature in the Serial Monitor. The MPU-6050 measures three-axis acceleration and three-axis angular velocity; processed orientation output such as yaw, pitch and roll requires a more complex Digital Motion Processor (DMP) example.

What the MPU-6050 measures

The MPU-6050 is a six-degree-of-freedom (6-DoF) inertial sensor: three accelerometer axes and three gyroscope axes. The chip also includes a temperature sensor and motion-processing functions. It communicates with an Arduino as an I2C slave; the Arduino is the bus master. The manufacturer’s MPU-6000/MPU-6050 Product Specification lists a maximum I2C bus speed of 400 kHz.

An accelerometer reports linear acceleration plus the effect of gravity, while a gyroscope reports angular rate. Neither sensor directly measures yaw, pitch or roll as a finished value. Those orientation values are calculated by software, often by combining sensor data with filtering or the DMP.

Parts and compatibility checks

  • An Arduino-compatible board with I2C pins
  • An MPU-6050 breakout module
  • Four jumper wires; a breadboard is optional

Breakout boards are not electrically identical. Before wiring, read the exact module documentation and identify its VCC, GND, SDA, SCL and, if present, INT pins. A university exercise documents a setup using 3.3 V, while Adafruit documents connecting VCC to 5 V for a 5 V Arduino or 3 V for a 3 V board. These are board-specific instructions, not a universal rule for every MPU-6050 module. A regulator or level shifter on one breakout cannot be assumed on another.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
HiLetgo 3pcs GY-521 MPU-6050 MPU6050 3 Axis Accelerometer Gyroscope Module 6 DOF 6-axis Accelerometer Gyroscope Sensor Module 16 Bit AD Converter Data Output IIC I2C for Arduino
  • MPU-6050 MPU6050 6-axis Accelerometer Gyroscope Sensor
  • Communication mode: standard IIC communication protocol
  • Chip built-in 16bit AD converter, 16bit data output
  • Gyroscopes range: +/- 250 500 1000 2000 degree/sec
  • Acceleration range: ±2 ±4 ±8 ±16g

Wire the MPU-6050 to Arduino

Connect power, ground and the two I2C lines first. SDA and SCL are not the same pins on every Arduino, so use your board’s pinout rather than copying an Uno diagram blindly.

MPU-6050 pin Arduino connection Notes
VCC Voltage specified by your breakout documentation The Carnegie Mellon example uses 3.3 V; Adafruit’s referenced setup specifies 5 V for a 5 V Arduino or 3 V for a 3 V board.
GND GND Ground must be shared.
SDA Your Arduino’s SDA pin On the documented Uno-style setup, SDA is A4.
SCL Your Arduino’s SCL pin On the documented Uno-style setup, SCL is A5.
INT Leave disconnected for basic readings The DMP6 exercise connects INT to D2.

With AD0 low, the sensor’s 7-bit I2C address is 0x68 (0b1101000). With AD0 high, it is 0x69 (0b1101001), allowing two devices on one bus when the rest of the wiring supports it. These addresses and the AD0 function are specified in the manufacturer specification.

Install the Arduino libraries

  1. Open the Arduino IDE and choose Sketch → Include Library → Manage Libraries.
  2. Search for and install Adafruit MPU6050.
  3. Install its dependencies: Adafruit BusIO and Adafruit Unified Sensor.
  4. Restart the IDE if the examples do not appear immediately.

This is the Library Manager workflow documented in Adafruit’s MPU6050 Arduino guide.

Rank #2
KEAcvise 6-Pack GY-521 MPU6050 Sensor Module, 6-Axis IMU
  • Product Name MPU-6050 MPU6050 6-Axis Accelerometer Gyro Sensor, which is a key component for motion sensing applications.
  • Communication Protocol Utilizes the standard IIC communication protocol, enabling reliable data transfer between the sensor and other connected devices.
  • AD Converter and Data Output Incorporates a built-in 16-bit AD converter, providing precise 16-bit data output for accurate measurement and analysis.
  • Gyroscope Range Offers a gyroscope range of +/- 250, 500, 1000, and 2000 degrees per second, allowing for the detection of various rotational speeds and movements.
  • Acceleration Range The acceleration range spans ±2, ±4, ±8, and ±16 grams, facilitating the measurement of different levels of linear acceleration in various applications such as inertial navigation and motion tracking.

Run the first sensor-reading sketch

  1. Open File → Examples → Adafruit MPU6050 → basic_readings.
  2. Select the correct board and serial port under Tools.
  3. Upload the sketch.
  4. Open Tools → Serial Monitor and set the speed to 115200 baud.

The example prints acceleration, rotation-rate and temperature measurements. Keep the board still for a baseline, then tilt or rotate it and observe which values change. Stationary acceleration is influenced by gravity and the board’s orientation; gyro values can show a nonzero offset even when the module is not moving. The output and baud setting follow Adafruit’s documented example workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the basic output

Acceleration

Acceleration is reported independently for the X, Y and Z axes. When the board is stationary, gravity normally appears primarily on the axis pointing vertically, although the exact signs and distribution depend on how the breakout is oriented.

Rotation

Gyroscope values describe angular velocity around the three axes. A brief turn produces changing values; they should move toward the sensor’s resting offset when the board stops.

Rank #3
EC Buying GY-521 MPU6050 3 Axis Accelerometer Gyroscope Module,6DOF 3-Axis Accelerometer + 3-Axis Gyroscope Sensor Module16-Bit AD Converter Data Output IIC I2C for Arduino (3PCS)
  • ♥Product parameters: The chip used: MPU-6050 Power supply: 3-5v (internal low dropout voltage regulator) Communication method: standard IIC communication protocol Chip built-in 16bit AD converter, 16bit data output Gyroscope range: +250 500 1000 2000 °/s Acceleration range: ±2 ± 4 ± 8 ± 16g Using immersion gold PCB, machine welding process to ensure quality Pin pitch: 2.54mm
  • ♥MPU6050 Sensor Basic Features: Digitally output 6-axis or 9-axis rotation matrix, quaternion, and Euler Angle format fusion calculation data. 3-axis angular velocity sensor (gyroscope) with 131 LSBs/°/sec sensitivity and full-frame sensing ranges of ±250, ±500, ±1000, and ±2000°/sec. Programmable 3-axis accelerator with program control ranges of ±2g, ±4g, ±8g, and ±16g. Removed sensitivity between accelerator and gyroscope axes, reducing setting effects and sensor drift.
  • ♥MPU-6050 Sensor Other features: Digital Motion Processing engine can reduce a load of complex fusion calculation data, sensor synchronization, posture sensing, etc. Motion processing database supports Android, Linux, and Windows Built-in operating time deviation and magnetic sensor calibration calculation technology, eliminating the need for additional calibration by customers. Sync pin with digital input to support video electronic image stabilization technology and GPS
  • ♥ Characteristic: Temperature sensor with digital output VDD supply voltage is 2.5V±5%, 3.0V±5%, 3.3V±5%; VDDIO is 1.8V±5% Gyro operating current: 5mA, Gyro standby current: 5A; Accelerator operating current: 350A, Accelerator power-saving mode current: 20A@10Hz Fast-mode I2C up to 400kHz, or SPI serial host interface up to 20MHz The built-in frequency generator has only ±1% frequency variation in all temperature ranges (full temperature range).
  • ♥ Application: motion sensing game Augmented reality electronic image stabilization Optical image stabilization

Temperature

The temperature channel is a reading from the sensor package, not necessarily the surrounding room temperature. Treat it as a sensor measurement useful for monitoring changes rather than as a calibrated thermometer.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose between basic readings and DMP orientation

Route Best for What changes
Adafruit basic_readings Proving communication and viewing raw acceleration, rotation and temperature Library Manager installation and a short example; no interrupt wire is required for the documented workflow.
i2cdevlib DMP6-style example Exploring processed orientation output such as yaw, pitch and roll More files and setup, an interrupt connection in the cited exercise, and substantially greater memory use.

The Carnegie Mellon MPU6050 exercise connects 3.3 V, GND, A4, A5 and D2 to INT, opens Serial Monitor at 115200 baud, and notes that its DMP6 sketch uses more than half of an Arduino Uno’s available program space. That is a property of that particular library/example combination, not a guarantee for every DMP implementation. The Arduino Project Hub example also documents the 0x68/0x69 address choice and interrupt-based setup: What Is MPU6050?

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the basic example first. Move to DMP output only after I2C communication is stable, and make sure the chosen library includes every required source file and supports your Arduino board.

Rank #4
AOICRIE 3pcs GY-521 MPU 6050 MPU6050 3 Axis Accelerometer Gyroscope Module 6 DOF 6-Axis Accelerometer Gyroscope Sensor Module Pre-Soldered for Raspberry Pi Pico and Other Models
  • MPU-6050 MPU6050 Module: adopts the standard IIC communication for communication and is powered by 3V-5V for sustainable use.
  • 3 Axis Accelerometer Gyroscope Module: Gyroscope range: ± 250 500 1000 2000 ° / s; Acceleration range: ± 2 ± 4 ± 8 ± 16 g; Transmission can pass I2C up to 400kHz or SPI up to 20MHz.
  • MPU 6050 Chip built-in: with three 16-bit analog-to-digital converters (ADCs) for digitizing the gyroscope outputs and another three ones for digitizing the accelerometer outputs.
  • Universally Compatible: This sensor is easy to use with just about any microcontroller that has an I2C interface, for Raspberry Pi and ESP32 models.
  • What You Will Get: 3pcs Pre-Soldered GY-521 mpu-6050 mpu6050 3 axis accelerometer sensor. Ready to plug in and go.

Troubleshoot no data or incorrect readings

“Could not find a valid MPU6050 sensor” or no device response

  • Confirm VCC and GND, and verify that the breakout accepts the voltage you supplied.
  • Check SDA and SCL against your exact Arduino model; swapping them prevents communication.
  • Inspect the AD0 connection. A module configured high responds at 0x69, not 0x68.
  • Check for loose jumper wires and a shared ground.

The sketch will not compile

  • Install Adafruit MPU6050, Adafruit BusIO and Adafruit Unified Sensor through Library Manager.
  • Make sure the selected example belongs to the library you installed and that duplicate or obsolete MPU6050 libraries are not being chosen.

The Serial Monitor is blank or unreadable

Open the correct port, press reset after opening the monitor if necessary, and set the monitor to 115200 baud to match the documented examples.

DMP output never arrives

Recheck the INT wire and the interrupt pin required by the specific sketch, confirm that all DMP library files are present, and verify available program memory. A DMP example can fail even when the basic sensor-reading example works because it has different wiring, file and memory requirements.

What to verify before building a project

  • Record the breakout’s required VCC range and whether it includes regulation or level shifting.
  • Record your Arduino’s actual SDA and SCL pins.
  • Confirm the I2C address from AD0 before adding a second sensor.
  • Establish a stationary baseline and account for axis orientation and gyro offsets in your software.
  • Check current library documentation when moving beyond the cited examples; the manufacturer specification is Revision 3.4 (2013), and the register map is Revision 3.2 (2011).

The Bottom Line

For a first successful MPU-6050 project, use the Adafruit basic_readings example and verify power, SDA/SCL, address and Serial Monitor settings before attempting a DMP orientation sketch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.