Component · Sensor

MPU-6050 IMU

The MPU-6050 is a 6-axis IMU that senses tilt, rotation, and acceleration over I²C—how a robot knows its orientation for balancing and turning.

What it is

The MPU-6050 is how a robot feels its own motion. It is a 6-axis inertial measurement unit—a gyroscope and an accelerometer on one chip—that reports how the robot is tilted, how fast it’s spinning, and how it’s accelerating. Where an ultrasonic sensor looks outward at the world, an IMU looks inward at the robot’s own body, which is what a self-balancing robot or a dead-reckoning navigator needs.

Labelled diagram of an MPU-6050 IMU breakout (GY-521 board): a purple PCB with the MPU-6050 chip and passives in the centre, an X/Y/Z axes indicator showing the three sensing directions, and an 8-pin header (VCC, GND, SCL, SDA, XDA, XCL, AD0, INT) along the bottom.
A gyroscope and accelerometer on one chip sense rotation and tilt around all three axes, read over I²C. Download SVG

How it works

Inside are two sensors. The accelerometer measures linear acceleration on X, Y, and Z—at rest, that’s just gravity, which tells the robot which way is down (its tilt). The gyroscope measures how fast the robot is rotating about each axis. You read both over I²C (SCL/SDA).

Neither sensor is enough alone: integrate the gyro to get an angle and it slowly drifts; trust the accelerometer and it’s noisy whenever the robot moves. The fix is sensor fusion—blend them so the accelerometer corrects the gyro’s drift and the gyro smooths the accelerometer’s noise. That technique is exactly what sensor noise, bias, and filtering covers.

When to use it

Reach for an MPU-6050 when a robot needs to know its own orientation or motion:

  • Self-balancing robots — the tilt angle the control loop fights to keep at zero.
  • Heading and dead reckoning — sensing turns to improve odometry between encoder readings.
  • Motion detection / gestures — reacting to being picked up, tipped, or shaken.

For measuring distance to things (walls, obstacles), you want a ranging sensor like the HC-SR04 or VL53L0X instead—an IMU senses the robot, not the world.

Wiring and gotchas

  • I²C, 3.3–5 V. Most breakouts (the purple GY-521) have a regulator, so 5 V is fine; the raw chip is 3.3 V only.
  • Fuse the gyro and accel—don’t steer on a raw reading. A single accelerometer sample under motion is unusable as a tilt angle.
  • Yaw drifts without a magnetometer; use the MPU-6050 for pitch/roll and short-term turns, not absolute compass heading.
  • Keep it rigid and level-mounted; a loose sensor adds vibration the filter can’t remove.

Explore the graph

Used in these builds

Projects, learning paths, and simulators that include the MPU-6050 IMU.

Questions

MPU-6050 IMU FAQ

What is the MPU-6050 sensor?

The MPU-6050 is a 6-axis inertial measurement unit (IMU) on a small breakout board. It combines a 3-axis gyroscope and a 3-axis accelerometer, so a robot can sense how it is tilted, how fast it is rotating, and how it is accelerating—all read over the I²C bus.

How does the MPU-6050 work?

Inside are two sensors. The accelerometer measures linear acceleration—at rest that's just gravity, which tells the robot which way is down (its tilt). The gyroscope measures rotation rate about each axis. You read both over I²C, then fuse them to get a stable orientation neither gives alone.

What is the MPU-6050 used for?

Sensing a robot's own motion—keeping a self-balancing robot upright, estimating heading and improving odometry between encoder readings, and detecting being tipped, picked up, or shaken. It senses the robot itself, not the world around it, so it complements a ranging sensor rather than replacing one.

How do you calibrate an MPU-6050?

At rest, the gyro and accelerometer read small non-zero offsets. Calibrate by averaging a few hundred samples while the sensor sits perfectly still, then subtract those offsets from every reading. The gyro especially needs this—uncalibrated bias is what makes the estimated angle drift fastest.

How do you connect an MPU-6050 to an ESP32 or Arduino?

Over I²C—wire SDA and SCL to the board's I²C pins, plus power and ground. The purple GY-521 breakout has a regulator, so it runs from 3.3 V on an ESP32 or 5 V on an Arduino Uno. A library then reads the gyroscope and accelerometer registers for you.

Further reading

References