

The MPU9250/GY-91 is a 9-axis motion tracking device that integrates a 3-axis gyroscope, a 3-axis accelerometer, and a 3-axis magnetometer into a single compact module. This sensor is widely used in applications requiring precise orientation and motion sensing, such as robotics, drones, mobile devices, and wearable technology. Its ability to measure angular velocity, linear acceleration, and magnetic field strength makes it a versatile component for motion tracking and navigation systems.








The GY-91 breakout board typically has the following pinout:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (3.3V recommended) |
| 2 | GND | Ground connection |
| 3 | SCL | I2C clock line (or SPI clock line in SPI mode) |
| 4 | SDA | I2C data line (or SPI data input/output in SPI mode) |
| 5 | NCS | Chip select for SPI communication (active low, connect to GND for I2C mode) |
| 6 | INT | Interrupt pin (used for motion detection or data-ready signals) |
| 7 | AD0/SDO | I2C address selection (connect to GND for 0x68 or VCC for 0x69) / SPI data out |
Below is an example of how to use the MPU9250/GY-91 with an Arduino UNO via I2C:
#include <Wire.h>
#include <MPU9250.h> // Include a library for MPU9250 (e.g., SparkFun MPU-9250 library)
MPU9250 mpu; // Create an MPU9250 object
void setup() {
Serial.begin(9600); // Initialize serial communication
Wire.begin(); // Initialize I2C communication
// Initialize the MPU9250
if (mpu.begin() != INV_SUCCESS) {
Serial.println("Failed to initialize MPU9250!");
while (1); // Halt if initialization fails
}
Serial.println("MPU9250 initialized successfully!");
}
void loop() {
// Read sensor data
if (mpu.readSensor() == INV_SUCCESS) {
Serial.print("Accel (g): ");
Serial.print(mpu.getAccelX_mss(), 2); Serial.print(", ");
Serial.print(mpu.getAccelY_mss(), 2); Serial.print(", ");
Serial.println(mpu.getAccelZ_mss(), 2);
Serial.print("Gyro (deg/s): ");
Serial.print(mpu.getGyroX_rads(), 2); Serial.print(", ");
Serial.print(mpu.getGyroY_rads(), 2); Serial.print(", ");
Serial.println(mpu.getGyroZ_rads(), 2);
Serial.print("Mag (uT): ");
Serial.print(mpu.getMagX_uT(), 2); Serial.print(", ");
Serial.print(mpu.getMagY_uT(), 2); Serial.print(", ");
Serial.println(mpu.getMagZ_uT(), 2);
delay(500); // Delay for readability
} else {
Serial.println("Failed to read sensor data!");
}
}
No Communication with the Sensor:
Inaccurate Readings:
Sensor Not Initializing:
Q: Can the MPU9250/GY-91 be powered with 5V?
A: No, the module operates at 3.3V. Use a voltage regulator or level shifter if interfacing with a 5V system.
Q: How do I calibrate the magnetometer?
A: Rotate the sensor in all directions while collecting data, then use a calibration algorithm to compute offsets and scaling factors.
Q: Can I use SPI and I2C simultaneously?
A: No, the module supports either SPI or I2C, but not both at the same time. Select one protocol based on your application.
Q: What is the maximum sampling rate?
A: The MPU9250 supports a maximum sampling rate of 1 kHz for the gyroscope and accelerometer.