Description
The MPU-9250 combines a 3-axis accelerometer, a 3-axis gyroscope and a 3-axis magnetometer with an on-board Digital Motion Processor (DMP) all packaged in a high performance small module.
PACKAGE INCLUDES:
- MPU-9250 3-Axis Accel, Gyro & Mag Sensor Module
- 10-pin male header
KEY FEATURES OF MPU-9205 3-AXIS ACCEL, GRYO & MAG SENSOR MODULE:
- 3-axis MEMS 16-bit accelerometer with programmable range
- 3-axis MEMS 16-bit gyroscope to detect rotation with programmable range
- 3-axis MEMS 16-bit magnetometer to detect magnetic compass direction
- 9-axis MotionFusion Digital Motion Processor (DMP)
- Temperature sensor range of -40 to +85C
- Interrupt output
- I2C and SPI Interface
- 5V power (built-in 3.3V regulator powers MPU-9250 device)
- 3.3V logic compatible
The MPU-9250 is a high performance accelerometer, gyroscope and magnetometer option for use in applications such as gesture recognition in gaming, self-balancing robots, toys, cell phones, vehicle navigation, fitness monitoring and similar applications where detection of movement direction and magnitude along with rotation is desired.
Both the accelerometer and gyroscope each makes use of three 16-bit ADCs with four programmable ranges for high sensitivity. The magnetometer makes use of three 14-bit ADCs. A built-in temperature sensor is also provided for measuring the chip die temperature and has a wide measurement range from -40C to +85C.
Communications between the sensor and the MCU is done over either the I2C or SPI interface.
The MPU-9250 sensor operates at 3.3V. but the module contains a 3.3V regulator so the module should be supplied with 5V on the VCC pin. Since the module uses I2C which is open-drain with pull-ups to 3.3V, level translation is generally not considered necessary when using it with a 5V MCU. Using the SPI interface requires level translation.
The module is relatively easy to get up and running and capturing the raw data output of the device. Manipulating the data into something meaningful is more of a challenge, but there are some good libraries available for using the device.
Measuring Temperature
The MPU-9250 can measure temperature over the range of -40 to 85°C.
The measurement is of the die itself and will typically be near ambient. This temperature can be used to offset the calibration of the accelerometer, gyroscope and magnetometer or can provide a general indication of the ambient temperature and temperature changes.
Accuracy is about ±1°C over the entire range.
Measuring Acceleration
The MPU-9250 is able to measure acceleration using its on-chip accelerometer with four programmable full scale ranges of ±2g, ±4g, ±8g and ±16g that can be set by the user.
The integrated 16-bit ADCs simultaneously sample the 3 axis of movement (X, Y, Z).
The X, Y and Z are relative to how the chip sits on the module as shown to the right and will ultimately be dependent on the orientation of the module in your project.
Initial calibration tolerance is ±3% with non-linearity typically 0.5%.
Measuring Rotation
The MPU-9250 can measure rotation using its on-chip gyroscope with four programmable full scale ranges of ±250°/s, ±500°/s, ±1000°/s and ±2000°/s that can be set by the user.
The integrated 16-bit ADCs simultaneously sample the 3 axis of rotation around the X, Y and Z axes. The sample rate can be adjusted from 3.9 to 8000 samples per second.
The axis of rotation are relative the the X, Y and Z shown to the right.
Measuring Compass Direction
The MPU-9250 chip includes the AK8963 magnetometer die that can measure compass direction that allows the device to know its orientation relative to the magnetic north similar to how a hand-held compass works.
The integrated 16-bit ADCs simultaneously sample the 3 axis of movement (X, Y, Z).
The axis are X, Y and Z are the same as shown to the right for the accel and gyro except that the Z-axis is reversed. +Z is in the direction going going down toward earth.
Digital Motion Processor (DMP)
The MPU-9250 has an embedded Digital Motion Processor that can be used to off-load computation of motion processing algorithms from the MCU, freeing it up to be doing other things.
It uses the data from the accelerometer, gyroscope and even external sensors such as magnetometers. It can process it at high speed and make it available to the host MCU.
Using the I2C Interface
The module can use the I2C interface for communications with the MCU. It supports two different I2C addresses; 0x68 and 0x69. That allows two devices to be used on the same bus or in case there is an address conflict with another device on the bus.
The ADO pin determines the I2C address to use. This pin has a built-in 4.7K pull-down resistor on the module. If the pin is left unconnected, the line will be pulled low and the default I2C address will be 0x68. To select 0x69, connect the ADO pin to 3.3V.
The SCL and SDA pins connect to the SCL and SDA pins on the MCU.
The Auxillary I2C address with pins labeled EDA and ECL are an I2C bus controlled by the MPU-9250 so that it can communicate directly with other sensors so that it can get additional information for its internal computations.
Using the SPI Interface
The module can also use an SPI interface for communications with the MCU. These pins are shared with the I2C bus.
The SCL pin connects to the SPI Clock (SCK). SDA connects to SPI SDI (MOSI) and AD0 connects to SDO (MISO). NCS is used for the SPI chip select (CS).
The Arduino library used in the example below supports both I2C and SPI communications with the MPU-9250.
Module Connections
The module brings out the following connections.
1 x 10 Header
- VCC = 5V nominal. Connect to 5V output of the MCU
- GND = Ground
- SCL = Clock (SCL / SCK) for I2C and SPI
- SDA = Data (SDA / SDI) for I2C and SPI
- EDA = Auxillary I2C bus (SDA) for connecting external sensors
- ECL = Auxillary I2C bus (SCL) for connecting external sensors
- ADO = Address select for I2C / SDO for SPI interface
- INT = Interrupt Output
- NCS = SPI Chip Select
- FSYNC = Frame Sync (pulled to ground on the module)
Module Assembly
The module ships with the male header loose for flexibility. The straight header can be soldered to the top or bottom of the module depending on the planned use or wires can be used to make the connections which may be desirable in some final applications.
For breadboard use, we put the header on the bottom. Soldering is easiest if the header is inserted into a solderless breadboard to hold it in position during the soldering process.
OUR EVALUATION RESULTS:
The program below continually reads the sensor and reports the raw accelerometer, gyroscope, magnetometer and temperature data. It also calculates and reports the angle of pitch and roll.
This program uses the Bolder Flight MPU9250 library which can be downloaded via the IDE to keep things simple.
To test the device using the software below requires just 4 connections. Connect VCC to 5V, GND to ground and the SDA and SCL pins to the same pins on the MCU since we will be using I2C for our test.
Download the example program and open the Serial Monitor window to see the output. Ensure that the baud rate is set to 115200.
If the device is tilted, the pitch and roll numbers should reflect the angle at which the device tilted.
MPU-9250 Example Program
/* MPU-9250 Accel, Gryro and Mag Test Program This program reads and prints to the Serial Monitor window the raw X/Y/Z values for the accelerometer, gyroscope, magnetometer and temperature. It also calculates the pitch and roll values Connect VCC to 5V and GND to ground on the MCU Connect SCL to SCL and SDA to SDA on MCU Uses Bolder Flight MPU9250.h library */ #include "MPU9250.h" // an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68 MPU9250 IMU(Wire, 0x68); int status; float AcX, AcY, AcZ; float pitch, roll; //=============================================================================== // Initialization //=============================================================================== void setup() { // serial to display data Serial.begin(115200); while (!Serial) {} // start communication with IMU status = IMU.begin(); if (status < 0) { Serial.println("IMU initialization unsuccessful"); Serial.println("Check IMU wiring or try cycling power"); Serial.print("Status: "); Serial.println(status); while (1) {} } } //=============================================================================== // Main //=============================================================================== void loop() { // read the sensor IMU.readSensor(); // display the data Serial.println("\tX\tY\tZ"); Serial.print("Accel:\t"); Serial.print(IMU.getAccelX_mss(), 3); Serial.print("\t"); Serial.print(IMU.getAccelY_mss(), 3); Serial.print("\t"); Serial.println(IMU.getAccelZ_mss(), 3); Serial.print("Gyro:\t"); Serial.print(IMU.getGyroX_rads(), 3); Serial.print("\t"); Serial.print(IMU.getGyroY_rads(), 3); Serial.print("\t"); Serial.println(IMU.getGyroZ_rads(), 3); Serial.print("Mag:\t"); Serial.print(IMU.getMagX_uT(), 3); Serial.print("\t"); Serial.print(IMU.getMagY_uT(), 3); Serial.print("\t"); Serial.println(IMU.getMagZ_uT(), 3); Serial.print("Temp:\t"); Serial.println(IMU.getTemperature_C(), 3); AcX = IMU.getAccelX_mss(); AcY = IMU.getAccelY_mss(); AcZ = IMU.getAccelZ_mss(); //get pitch/roll getAngle(AcX, AcY, AcZ); Serial.println("\tAngle in Degrees"); Serial.print("Pitch:\t"); Serial.println(pitch, 6); Serial.print("Roll:\t"); Serial.println(roll, 6); Serial.println(); delay(250); } //=============================================================================== // GetAngle - Converts accleration data to pitch & roll //=============================================================================== void getAngle(float Vx, float Vy, float Vz) { float x = Vx; float y = Vy; float z = Vz; pitch = atan(x / sqrt((y * y) + (z * z))); roll = atan(y / sqrt((x * x) + (z * z))); //convert radians into degrees pitch = pitch * (180.0 / 3.14); roll = roll * (180.0 / 3.14) ; }
BEFORE THEY ARE SHIPPED, THESE MODULES ARE:
- Inspected
- Basic operation verified
- Repackaged in high quality resealable ESD bag
Notes:
- None
Technical Specifications
Operating Ratings | ||
Vcc | Module | 5V (typical) |
Accelerometer | Ranges | ±2g, ±4g, ±8g, ±16g |
Gyroscope | Ranges | ±250°/s, ±500°/s, ±1000°/s, ±2000°/s |
Magnetometer | Range | ±4800uT |
Temperature | Range | -40 to +85°C |
Shock Tolerance | Max | 10,000g |
Dimensions | L x W (PCB) | 26 x 16mm (1 x 0.63″) |
Country of Origin | China | |
Datasheet | TDK InvenSense | MPU-9250 |
FURTHER READING
Advanced library for MPU-9250: https://github.com/bolderflight/MPU9250