

The MPU-6050 is a motion tracking device that combines a 3-axis accelerometer and a 3-axis gyroscope on a single chip. It is designed to measure acceleration, angular velocity, and orientation, making it an essential component in motion sensing applications. The sensor communicates via the I2C protocol, allowing easy integration with microcontrollers and development boards like the Arduino UNO.








The MPU-6050 offers precise motion tracking capabilities with the following key specifications:
The MPU-6050 module typically has 8 pins. Below is the pinout description:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (3.3V to 5V). |
| 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 additional sensors, optional). |
| 6 | XCL | Auxiliary I2C clock line (used for connecting additional sensors, optional). |
| 7 | AD0 | I2C address selector. Connect to GND for address 0x68 or VCC for address 0x69. |
| 8 | INT | Interrupt pin. Outputs a signal when data is ready or an event occurs. |
Below is an example code to read accelerometer and gyroscope data from the MPU-6050 using the Arduino IDE:
#include <Wire.h>
#include <MPU6050.h>
// Create an MPU6050 object
MPU6050 mpu;
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
Wire.begin(); // Initialize I2C communication
// Initialize the MPU-6050
if (!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) {
Serial.println("Could not find a valid MPU6050 sensor, check connections!");
while (1); // Halt the program if the sensor is not detected
}
Serial.println("MPU6050 initialized successfully!");
}
void loop() {
// Read accelerometer and gyroscope data
Vector rawAccel = mpu.readRawAccel();
Vector rawGyro = mpu.readRawGyro();
// Print accelerometer data
Serial.print("Accel X: "); Serial.print(rawAccel.XAxis);
Serial.print(" | Y: "); Serial.print(rawAccel.YAxis);
Serial.print(" | Z: "); Serial.println(rawAccel.ZAxis);
// Print gyroscope data
Serial.print("Gyro X: "); Serial.print(rawGyro.XAxis);
Serial.print(" | Y: "); Serial.print(rawGyro.YAxis);
Serial.print(" | Z: "); Serial.println(rawGyro.ZAxis);
delay(500); // Wait for 500ms before the next reading
}
Sensor Not Detected
Inaccurate Readings
No Data Output
Interrupt Pin Not Working
Q: Can the MPU-6050 be powered with 5V?
Q: How do I calibrate the MPU-6050?
Q: Can I connect multiple MPU-6050 sensors to the same I2C bus?
Q: What is the maximum I2C speed supported by the MPU-6050?