+ Range | 250/s |
+ Resolution | 16 bits |
+ Bandwidth | 100 Hz to 10 kHz |
+ Range | 250/s |
+ Resolution | 16 bits |
+ Bandwidth | 100 Hz to 10 kHz |
+ Range | 2g to 16g |
+ Resolution | 16 bits |
+ Bandwidth | 10 Hz to 1 kHz |
2.4 V to 3.6 V
3.2 mA (active mode), 10 A (sleep mode)
I2C or SPI (selectable)
-40C to +85C
3 mm x 3 mm QFN
Applications
The MPU-9250 6-Axis Attitude Gyro and Accelero Sensor Module is suitable for a wide range of applications, including |
Robotics and drone navigation
Autonomous vehicles and GPS systems
IoT and smart home devices
Wearable devices and fitness trackers
Industrial automation and process control
Gaming and virtual reality systems
MPU-9250 6-Axis Attitude Gyro and Accelerometer Sensor Module (Without Magnetometer) Documentation
Overview
The MPU-9250 is a 6-axis attitude gyro and accelerometer sensor module that combines a 3-axis gyroscope, a 3-axis accelerometer, and a digital motion processing unit (DMP) in a single chip. This module is widely used in robotics, drone, and IoT applications that require precise motion tracking and stabilization. The MPU-9250 does not include a magnetometer, which is typically used for magnetic field measurements.
Pinouts and Interface
The MPU-9250 module typically comes with a 16-pin interface, including:
VCC: Power supply (3.3V or 5V)
GND: Ground
SCL: I2C clock
SDA: I2C data
INT: Interrupt
AD0: Address pin (optional)
FSYNC: Frame sync pin (optional)
Communication Protocol
The MPU-9250 uses the I2C (Inter-Integrated Circuit) protocol for communication with microcontrollers or other devices. The I2C bus consists of two wires: SCL (clock) and SDA (data).
Code Examples
### Example 1: Basic I2C Communication with Arduino
This example demonstrates how to read accelerometer and gyroscope data from the MPU-9250 using an Arduino board.
```cpp
#include <Wire.h>
#define MPU9250_ADDRESS 0x68 // default address of MPU-9250
void setup() {
Serial.begin(9600);
Wire.begin(); // initialize I2C bus
}
void loop() {
// read accelerometer data
int16_t ax, ay, az;
Wire.beginTransmission(MPU9250_ADDRESS);
Wire.write(0x3B); // start address for accelerometer data
Wire.endTransmission();
Wire.requestFrom(MPU9250_ADDRESS, 6);
ax = Wire.read() << 8 | Wire.read();
ay = Wire.read() << 8 | Wire.read();
az = Wire.read() << 8 | Wire.read();
// read gyroscope data
int16_t gx, gy, gz;
Wire.beginTransmission(MPU9250_ADDRESS);
Wire.write(0x43); // start address for gyroscope data
Wire.endTransmission();
Wire.requestFrom(MPU9250_ADDRESS, 6);
gx = Wire.read() << 8 | Wire.read();
gy = Wire.read() << 8 | Wire.read();
gz = Wire.read() << 8 | Wire.read();
Serial.print("Accelerometer: ");
Serial.print(ax); Serial.print(" ");
Serial.print(ay); Serial.print(" ");
Serial.println(az);
Serial.print("Gyroscope: ");
Serial.print(gx); Serial.print(" ");
Serial.print(gy); Serial.print(" ");
Serial.println(gz);
delay(100);
}
```
### Example 2: DMP (Digital Motion Processing) with Raspberry Pi (Python)
This example demonstrates how to use the MPU-9250's DMP feature to calculate the device's orientation (quaternion) and temperature using a Raspberry Pi and Python.
```python
import smbus
import time
# MPU-9250 I2C address
MPU9250_ADDRESS = 0x68
# DMP-related registers
DMP_BANK = 0x04
DMP_START_ADDR = 0x32
DMP_GET_QUAT = 0x52
DMP_GET_TEMP = 0x51
bus = smbus.SMBus(1) # use I2C bus 1 on Raspberry Pi
def read quaternion():
bus.write_byte(MPU9250_ADDRESS, DMP_BANK)
bus.write_byte(MPU9250_ADDRESS, DMP_GET_QUAT)
data = bus.read_i2c_block_data(MPU9250_ADDRESS, DMP_START_ADDR, 16)
return data
def read_temperature():
bus.write_byte(MPU9250_ADDRESS, DMP_BANK)
bus.write_byte(MPU9250_ADDRESS, DMP_GET_TEMP)
data = bus.read_byte(MPU9250_ADDRESS, DMP_START_ADDR)
return data
while True:
quat = read_quaternion()
temp = read_temperature()
print("Quaternion: w={}, x={}, y={}, z={}".format(quat[0], quat[1], quat[2], quat[3]))
print("Temperature: {}C".format(temp))
time.sleep(0.1)
```
Note: These examples are for illustration purposes only and may require modifications to work with specific hardware configurations or firmware versions. Always consult the official datasheet and documentation for the MPU-9250 and your microcontroller or development board for more information.