The MPU6050 is a 6-axis motion tracking device that integrates a 3-axis gyroscope and a 3-axis accelerometer into a single chip. This compact and versatile sensor is widely used in applications requiring precise motion tracking and orientation measurement. It is commonly found in robotics, drones, gaming devices, and mobile applications to measure acceleration, angular velocity, and orientation.
The MPU6050 also features a Digital Motion Processor (DMP) that can process complex motion algorithms internally, reducing the computational load on the host microcontroller. Its I2C interface makes it easy to integrate with microcontrollers like Arduino, Raspberry Pi, and other embedded systems.
The MPU6050 has 8 primary pins for operation. Below is the pinout description:
Pin Name | Pin Number | Description |
---|---|---|
VCC | 1 | Power supply input (2.375V to 3.46V). Typically connected to 3.3V. |
GND | 2 | Ground connection. |
SCL | 3 | I2C clock line. Connect to the microcontroller's SCL pin. |
SDA | 4 | I2C data line. Connect to the microcontroller's SDA pin. |
AD0 | 5 | I2C address select. Connect to GND (address 0x68) or VCC (address 0x69). |
INT | 6 | Interrupt output. Can be used to signal data availability or motion detection. |
FSYNC | 7 | Frame synchronization input. Typically left unconnected in most applications. |
RESV | 8 | Reserved. Do not connect. |
Below is an example of how to interface the MPU6050 with an Arduino UNO using the Wire library:
#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
Wire.beginTransmission(MPU6050_ADDR);
Wire.write(ACCEL_XOUT_H); // Start reading from ACCEL_XOUT_H register
Wire.endTransmission(false);
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
Serial.print("Accel X: "); Serial.print(accelX);
Serial.print(" | Accel Y: "); Serial.print(accelY);
Serial.print(" | Accel Z: "); Serial.println(accelZ);
}
delay(500); // Delay for readability
}
No Data from the Sensor:
Inconsistent or Noisy Readings:
I2C Communication Errors:
Can the MPU6050 work with 5V logic?
How do I calibrate the MPU6050?
What is the maximum sampling rate of the MPU6050?
This concludes the documentation for the MPU6050.