

The MPU6050 is a 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer on a single chip. This compact and versatile sensor is widely used in applications requiring motion sensing and orientation detection. Its ability to measure angular velocity and linear acceleration makes it an essential component in robotics, drones, mobile devices, and gaming controllers. Additionally, the MPU6050 features an onboard Digital Motion Processor (DMP) for advanced motion processing.








The MPU6050 has 8 primary pins for operation. Below is the pinout description:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (2.375V to 3.46V). Typically connected to 3.3V. |
| 2 | GND | Ground connection. |
| 3 | SCL | I2C clock line. Connect to the SCL pin of the microcontroller. |
| 4 | SDA | I2C data line. Connect to the SDA pin of the microcontroller. |
| 5 | XDA | Auxiliary I2C data line (used for connecting external sensors). |
| 6 | XCL | Auxiliary I2C clock line (used for connecting external sensors). |
| 7 | AD0 | I2C address selection pin. Connect to GND for address 0x68, or VCC for 0x69. |
| 8 | INT | Interrupt output pin. Used to signal data availability or motion detection. |
0x68, or to VCC for the alternate address 0x69.Below is an example of how to interface the MPU6050 with an Arduino UNO using the I2C protocol:
#include <Wire.h>
// MPU6050 I2C address (default is 0x68 when AD0 is connected to GND)
const int MPU6050_ADDR = 0x68;
// MPU6050 register addresses
const int PWR_MGMT_1 = 0x6B; // Power management register
const int ACCEL_XOUT_H = 0x3B; // Accelerometer X-axis high byte
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Initialize serial communication for debugging
// Wake up the MPU6050 (it starts in sleep mode)
Wire.beginTransmission(MPU6050_ADDR);
Wire.write(PWR_MGMT_1); // Access power management register
Wire.write(0); // Set to 0 to wake up the sensor
Wire.endTransmission();
Serial.println("MPU6050 initialized");
}
void loop() {
// Request accelerometer data from the MPU6050
Wire.beginTransmission(MPU6050_ADDR);
Wire.write(ACCEL_XOUT_H); // Start reading from ACCEL_XOUT_H register
Wire.endTransmission(false); // Send repeated start condition
Wire.requestFrom(MPU6050_ADDR, 6); // Request 6 bytes (X, Y, Z high and low)
if (Wire.available() == 6) {
int16_t accelX = (Wire.read() << 8) | Wire.read(); // Combine high and low bytes
int16_t accelY = (Wire.read() << 8) | Wire.read();
int16_t accelZ = (Wire.read() << 8) | Wire.read();
// Print accelerometer values to the serial monitor
Serial.print("Accel X: "); Serial.print(accelX);
Serial.print(" | Accel Y: "); Serial.print(accelY);
Serial.print(" | Accel Z: "); Serial.println(accelZ);
}
delay(500); // Wait 500ms before the next reading
}
No Data from the Sensor:
0x68 unless AD0 is connected to VCC).Inaccurate Readings:
I2C Communication Errors:
Q: Can the MPU6050 operate at 5V?
A: No, the MPU6050 operates at a maximum of 3.46V. Use a voltage regulator or level shifter if interfacing with a 5V system.
Q: How do I calibrate the MPU6050?
A: Calibration involves measuring and compensating for offsets in the accelerometer and gyroscope readings. Libraries like MPU6050 or MPU6050_DMP for Arduino often include calibration functions.
Q: Can I connect multiple MPU6050 sensors to the same I2C bus?
A: Yes, but each sensor must have a unique I2C address. Use the AD0 pin to set different addresses (0x68 or 0x69).
By following this documentation, you can effectively integrate the MPU6050 into your projects for reliable motion sensing and orientation detection.