Skip to content

MPU-6050 IMU

The MPU-6050 is a 6-axis IMU (3-axis accelerometer + 3-axis gyroscope) with I²C interface.

Wiring (Raspberry Pi)

MPU-6050Raspberry Pi
VCCPin 1 (3.3V)
GNDPin 6 (GND)
SDAPin 3 (GPIO2)
SCLPin 5 (GPIO3)

Enable I²C: sudo raspi-config → Interface Options → I2C → Enable.

Python Reading

bash
pip install mpu6050-raspberrypi
python
from mpu6050 import mpu6050

sensor = mpu6050(0x68)

accel = sensor.get_accel_data()
gyro  = sensor.get_gyro_data()
temp  = sensor.get_temp()

print(f"Accel: {accel}")
print(f"Gyro:  {gyro}")
print(f"Temp:  {temp:.1f} °C")

Verify I²C Address

bash
sudo i2cdetect -y 1
# Should show 0x68 (or 0x69 if AD0 pin is HIGH)

WARNING

The MPU-6050 has significant gyroscope drift. Always complement it with an accelerometer-based tilt correction or use the DMP (Digital Motion Processor) for fused orientation.

Released under the MIT License.