The SparkFun IMU Breakout - MPU-9250 is a compact, high-performance 9-axis motion tracking device that combines a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer. This integrated sensor package is ideal for a wide range of applications, including robotics, drone flight control, virtual reality, and motion analysis. The MPU-9250 communicates via I2C or SPI, offering flexibility for various microcontroller interfaces.
Pin Number | Pin Name | Description |
---|---|---|
1 | VDD | Power supply (2.4V - 3.6V) |
2 | GND | Ground connection |
3 | SDA/SDI | I2C Data Line / SPI Serial Data In |
4 | SCL/SCLK | I2C Clock Line / SPI Serial Clock |
5 | NCS | SPI Chip Select (Active Low) |
6 | INT | Interrupt Output |
7 | FSYNC | Frame Synchronization (Optional) |
8 | AD0/SDO | I2C Address Selection / SPI Serial Data Out |
To use the MPU-9250 in a circuit:
#include <Wire.h>
#include <MPU9250.h>
MPU9250 IMU(Wire, 0x68);
int status;
void setup() {
Serial.begin(115200);
while (!Serial) {} // Wait for serial port to connect
status = IMU.begin();
if (status < 0) {
Serial.println("IMU initialization unsuccessful");
Serial.println("Check IMU wiring or try cycling power");
while (1) {}
}
}
void loop() {
if (IMU.readSensor() == 0) {
Serial.print("AccelX: ");
Serial.print(IMU.getAccelX_mss(), 6);
Serial.print("\tGyroX: ");
Serial.print(IMU.getGyroX_rads(), 6);
Serial.print("\tMagX: ");
Serial.print(IMU.getMagX_uT(), 6);
Serial.println();
// Add additional print statements for other axes as needed
}
delay(100);
}
Q: Can the MPU-9250 be used with a 5V microcontroller? A: Yes, but ensure that the power supply to the MPU-9250 is within the specified range and use logic level converters for communication lines.
Q: How do I change the I2C address of the MPU-9250? A: The I2C address can be changed by connecting the AD0/SDO pin to VDD or GND.
Q: What is the default I2C address of the MPU-9250? A: The default I2C address is 0x68 when AD0/SDO is connected to GND and 0x69 when connected to VDD.
Q: How can I verify that my MPU-9250 is functioning correctly? A: Run the example code provided and check the serial output for consistent and reasonable data readings.