MPU-9250 nine-axis IMU
The InvenSense MPU-9250 on the GY-9250 board: an accelerometer, a gyroscope and an AK8963 compass, all on one I2C bus.
Aliases: MPU9250, GY-9250, 9-DOF IMU, accelerometer gyroscope magnetometer. It is an MPU6050 with a magnetometer added, so it can tell north as well as down.
Pins
| Pin | What it does |
|---|---|
VCC, GND |
Supply, 3.3 to 5 V (the board has a regulator). |
SCL, SDA |
The I2C bus. The accelerometer and gyroscope answer at 0x68. |
AD0 |
High moves the address to 0x69. Pulled low on the board. |
INT |
The interrupt output. |
EDA, ECL |
The chip's auxiliary bus. Leave them. |
NCS, FSYNC |
SPI select and frame sync. Leave them. |
Two devices on one bus
The magnetometer, an AK8963, sits behind the MPU. Setting BYPASS_EN, bit 1 of
register 0x37, connects it to the main bus, where it answers at 0x0C. Until then
an I2C scan finds only 0x68.
Reading it on an Arduino
With asukiaaa's library, which Mokxi ships as MPU9250_asukiaaa.h:
#include <MPU9250_asukiaaa.h>
MPU9250_asukiaaa imu;
void setup() {
Wire.begin();
imu.setWire(&Wire);
imu.beginAccel();
imu.beginMag();
}
void loop() {
if (imu.accelUpdate() == 0) Serial.println(imu.accelZ());
if (imu.magUpdate() == 0) Serial.println(imu.magHorizDirection());
}
While it runs
Drag the board to tip it, and drag the slider to turn it: the slider is the compass bearing of the chip's X axis.
What the model gets right
From the MPU-9250 register map: the MPU-6050's accelerometer, gyroscope and
temperature registers, WHO_AM_I reading 0x71, and the chip awake at power-up.
From the AK8963 datasheet: WIA 0x48, the field low byte first at 0.15 uT a count
(0.6 at 14 bits), DRDY, single and continuous modes, ST2 ending a read, and
the fuse ROM's sensitivity adjustment. The magnetometer's axes are turned from
the accelerometer's as the register map draws them, and the Earth's field is
20 uT north and 45 uT down.
What it does not model
The DMP and the FIFO, the auxiliary I2C master (use the bypass, as every Arduino library does), SPI, self test, noise, bias, hard and soft iron, and magnetic declination. The adjustment values are 128, a factor of one.
See it in action
Tilt compass prints the tilt and the direction. Open it at /templates.