The MPU6050 is a 6 Degrees of Freedom (6DOF) inertial measurement unit (IMU) manufactured by DFRobot. It combines a 3-axis gyroscope and a 3-axis accelerometer, making it an essential component for applications requiring motion tracking and orientation sensing. This versatile sensor is widely used in robotics, drones, gaming devices, and wearable technology.
Parameter | Value |
---|---|
Supply Voltage | 2.3V - 3.4V |
Operating Current | 3.9mA (typical) |
Gyroscope Range | ±250, ±500, ±1000, ±2000 °/s |
Accelerometer Range | ±2g, ±4g, ±8g, ±16g |
Communication | I2C (up to 400kHz) |
Operating Temperature | -40°C to +85°C |
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply (2.3V - 3.4V) |
2 | GND | Ground |
3 | SCL | I2C Clock Line |
4 | SDA | I2C Data Line |
5 | XDA | Auxiliary I2C Data Line (optional) |
6 | XCL | Auxiliary I2C Clock Line (optional) |
7 | AD0 | I2C Address Select (connect to GND for 0x68, |
connect to VCC for 0x69) | ||
8 | INT | Interrupt (optional) |
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
void setup() {
Wire.begin();
Serial.begin(9600);
// Initialize MPU6050
Serial.println("Initializing MPU6050...");
if (!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) {
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
while (1);
}
// Calibrate gyroscope
Serial.println("Calibrating gyroscope...");
mpu.calibrateGyro();
// Set threshold sensibility. Default 3.
// If you don't want use threshold, comment this line or set 0.
mpu.setThreshold(3);
}
void loop() {
Vector rawAccel = mpu.readRawAccel();
Vector normAccel = mpu.readNormalizeAccel();
Serial.print(" Xraw = ");
Serial.print(rawAccel.XAxis);
Serial.print(" Yraw = ");
Serial.print(rawAccel.YAxis);
Serial.print(" Zraw = ");
Serial.println(rawAccel.ZAxis);
Serial.print(" Xnorm = ");
Serial.print(normAccel.XAxis);
Serial.print(" Ynorm = ");
Serial.print(normAccel.YAxis);
Serial.print(" Znorm = ");
Serial.println(normAccel.ZAxis);
delay(500);
}
No Communication with MPU6050:
Inaccurate Readings:
Sensor Not Detected:
Q: Can the MPU6050 be used with a 5V microcontroller?
Q: How do I calibrate the MPU6050?
MPU6050
for Arduino often include calibration functions.Q: What is the maximum sampling rate of the MPU6050?
This documentation provides a comprehensive guide to using the MPU6050 6DOF IMU. Whether you are a beginner or an experienced user, following these instructions and best practices will help you effectively integrate this sensor into your projects.