Measures the acceleration of the object in three axes (x, y, z) with a range of 2g, 4g, 8g, or 16g.
Measures the acceleration of the object in three axes (x, y, z) with a range of 2g, 4g, 8g, or 16g.
Measures the angular rate of the object in three axes (x, y, z) with a range of 250/s, 500/s, 1000/s, or 2000/s.
| The module is capable of operating in various modes, including | |
| Low-Power Mode | Reduces power consumption while maintaining the accuracy of the measurements. |
| High-Dynamic Range Mode | Enables the module to measure acceleration and angular rates over a wider range. |
Key Features
Applications
| The MPU-6050 Triple-Axis Accelerometer & Gyroscope Module is suitable for various applications, including |
Enhances the stability and balance of robots, allowing them to move and maneuver with precision.
Provides accurate motion sensing and orientation data for drone stabilization and navigation.
Enables the creation of wearable devices that track movement, orientation, and activities.
Enhances gaming experiences with motion sensing and gesture recognition capabilities.
Monitors and controls the motion of industrial equipment and machinery.
Pinout and Dimensions
| The MPU-6050 module has a 24-pin QFN package with the following pinout |
Power supply pin (1.8V to 3.6V)
Ground pin
I2C clock pin
I2C data pin
Interrupt pin
| AD0 | I2C address pin |
Full-scale range select pin
| XDA, XDB, YDA, YDB, ZDA, ZDB | Analog output pins |
| V_logic | Logic voltage pin (1.8V to 3.6V) |
4 mm
4 mm
0.95 mm
Conclusion
The MPU-6050 Triple-Axis Accelerometer & Gyroscope Module is a versatile and high-performance component suitable for various applications that require motion sensing, orientation, and balance detection. Its compact design, low power consumption, and high accuracy make it an ideal choice for developers and engineers working on IoT, robotics, and wearable devices projects.
MPU-6050 Triple-Axis Accelerometer & Gyroscope Module DocumentationOverviewThe MPU-6050 is a popular, low-power, and high-performance triple-axis accelerometer and gyroscope module. It combines a 3-axis accelerometer and a 3-axis gyroscope in a single chip, providing accurate measurements of acceleration, roll, pitch, and yaw. This module is widely used in various IoT applications, such as robotics, drones, wearable devices, and gaming consoles.Pinout and ConnectionsThe MPU-6050 module typically has 8 pins:VCC: Power supply (3.3V or 5V)
GND: Ground
SCL: I2C clock
SDA: I2C data
XDA: Accelerometer data (optional)
XCL: Accelerometer clock (optional)
AD0: I2C address selection (optional)
INT: Interrupt output (optional)Code Examples### Example 1: Basic Accelerometer and Gyroscope Readings using ArduinoThis example demonstrates how to read the accelerometer and gyroscope values using the MPU-6050 library in Arduino.
```c
#include <Wire.h>
#include <MPU6050.h>MPU6050 mpu;void setup() {
Serial.begin(115200);
Wire.begin();
mpu.begin();
mpu.setAccelerometerRange(MPU6050_RANGE_2G);
mpu.setGyroRange(MPU6050_RANGE_250DEG);
mpu.setDLPFMode(MPU6050_DLPF_5HZ);
}void loop() {
int16_t ax, ay, az;
int16_t gx, gy, gz;mpu.getAcceleration(&ax, &ay, &az);
mpu.getRotation(&gx, &gy, &gz);Serial.print("Acceleration (g): ");
Serial.print(ax / 16384.0);
Serial.print(", ");
Serial.print(ay / 16384.0);
Serial.print(", ");
Serial.println(az / 16384.0);Serial.print("Gyro (deg/s): ");
Serial.print(gx / 131.0);
Serial.print(", ");
Serial.print(gy / 131.0);
Serial.print(", ");
Serial.println(gz / 131.0);delay(50);
}
```
### Example 2: Orientation Calculation using Python and Raspberry PiThis example demonstrates how to calculate the orientation of the MPU-6050 module using Python and Raspberry Pi.
```python
import smbus
import math# I2C bus and address
bus = smbus.SMBus(1)
address = 0x68# Accelerometer and gyroscope scale factors
accel_scale = 32768.0
gyro_scale = 131.0# Function to read accelerometer and gyroscope values
def read_mpu():
data = bus.read_i2c_block_data(address, 0x3B, 14)
ax = (data[0] << 8) | data[1]
ay = (data[2] << 8) | data[3]
az = (data[4] << 8) | data[5]
gx = (data[8] << 8) | data[9]
gy = (data[10] << 8) | data[11]
gz = (data[12] << 8) | data[13]
return ax, ay, az, gx, gy, gz# Function to calculate orientation
def calculate_orientation(ax, ay, az, gx, gy, gz):
roll = math.atan2(ay, az)
pitch = math.atan2(-ax, math.sqrt(ay 2 + az 2))
yaw = math.atan2(gz, gy)
return roll, pitch, yawwhile True:
ax, ay, az, gx, gy, gz = read_mpu()
roll, pitch, yaw = calculate_orientation(ax / accel_scale, ay / accel_scale, az / accel_scale,
gx / gyro_scale, gy / gyro_scale, gz / gyro_scale)
print("Roll: {:.2f}, Pitch: {:.2f}, Yaw: {:.2f}".format(math.degrees(roll), math.degrees(pitch), math.degrees(yaw)))
time.sleep(0.1)
```
### Example 3: Gesture Recognition using ESP32 and MicroPythonThis example demonstrates how to use the MPU-6050 module to recognize gestures using the ESP32 board and MicroPython.
```python
import machine
import utime
from mpu6050 import MPU6050# I2C bus and address
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=400000)
mpu = MPU6050(i2c, address=0x68)# Gesture recognition thresholds
threshold_x = 2000
threshold_y = 2000
threshold_z = 2000while True:
ax, ay, az = mpu.acceleration
if ax > threshold_x:
print("Right gesture detected!")
elif ax < -threshold_x:
print("Left gesture detected!")
elif ay > threshold_y:
print("Up gesture detected!")
elif ay < -threshold_y:
print("Down gesture detected!")
elif az > threshold_z:
print("Forward gesture detected!")
elif az < -threshold_z:
print("Backward gesture detected!")
utime.sleep(0.1)
```
These examples demonstrate how to use the MPU-6050 module in various contexts, including Arduino, Python with Raspberry Pi, and MicroPython with ESP32. By leveraging the module's accelerometer and gyroscope readings, you can develop innovative IoT projects that involve motion sensing, orientation calculation, and gesture recognition.