Nine-axis IMU, MPU-9250
An MPU6050 with a compass inside: set BYPASS_EN and the AK8963 answers at 0x0C. Drag it to tip it.
- 10 pins
- 4 settings
- In 1 project

The Nine-axis IMU, MPU-9250 in brief
What it is, and every setting the properties panel gives it.
The MPU-9250 packs three sensors into one small package, usually sold on the GY-9250 board: an accelerometer, a gyroscope and a compass. The first two are the same design as the MPU6050 and answer at 0x68. The compass, an AK8963, is a second chip inside the package, hidden behind the first; a sketch sets the bypass bit and it appears on the same two wires at 0x0C. That is why an I2C scan of a fresh module shows only one address. In Mokxi you drag the board on the canvas to tip it and move a slider to turn it, so the accelerometer sees gravity shift between its axes and the compass sees the Earth’s field turn. The model gives WHO_AM_I as 0x71, reads the magnetometer at its datasheet scale, applies its sensitivity adjustment and leaves out the DMP, the FIFO, hard and soft iron effects and magnetic declination.
- Family
- Sensors
- Pins
- 10
- pitch
- 0
- roll
- 0
- heading
- 0
- temperature
- 25
10 pins
Named as the editor names them, so a wire lands where you expect it.
How to read the MPU-9250 compass and tilt on an Arduino
The tilt compass project runs on a Mega, because asukiaaa’s library, its floating point and atan2() together outgrow what Mokxi allows an Uno example. Four wires: VCC to 5 V (the board has a regulator), GND to GND, SDA to the Mega’s SDA (pin 20) and SCL to SCL (pin 21). AD0 stays unwired, so the motion sensor is at 0x68.
imu.beginAccel() starts the accelerometer, and imu.beginMag() sets the bypass so the AK8963 answers. Each loop, accelUpdate() and magUpdate() return 0 when they have fresh numbers. Pitch and roll come from atan2 of the accelerometer axes; magHorizDirection() is the angle of north from the chip’s X axis. Drag the heading slider and the direction follows. Then tip the board: the heading changes too, because the Earth’s field also points down into the ground, and only a tilt-compensated calculation, using the accelerometer, removes that.
On an ESP32 the same sketch fits with room to spare; Wire uses GPIO 21 and 22 unless you name other pins.
imu.setWire(&Wire);
imu.beginAccel(ACC_FULL_SCALE_2_G);
imu.beginMag(); // sets the bypass: the AK8963 at 0x0C
if (imu.accelUpdate() == 0) {
float pitch = atan2(-imu.accelX(), imu.accelZ()) * 180.0 / PI;
}
if (imu.magUpdate() == 0) {
float heading = imu.magHorizDirection();
}Common Nine-axis IMU, MPU-9250 errors and fixes
Questions and answers
What is the difference between the MPU-9250 and the MPU6050?
The MPU-9250 adds a three-axis magnetometer, so it can find north as well as down. Its accelerometer and gyroscope registers match the MPU6050’s, and WHO_AM_I reads 0x71 instead of 0x68.
Which Arduino library reads the MPU-9250 here?
asukiaaa’s MPU9250 library, included as MPU9250_asukiaaa.h, is the one the tilt compass uses. Any library that reaches the compass through the bypass, as most do, finds it the same way.
Does the simulator run the MPU-9250’s DMP?
No. The digital motion processor, the FIFO and the chip’s own auxiliary I2C master are left out; sketches read the raw registers and do the math themselves.
Why does the tilt compass project use a Mega and not an Uno?
The library, floating point and atan2() make the program larger than Mokxi allows a built-in Uno example. A real Uno can run a trimmed version; the wiring is the same.
What is true about the Nine-axis IMU, MPU-9250, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
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.
Not modeled
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.
From MPU-9250 nine-axis IMU, in full.
See the Nine-axis IMU, MPU-9250 in a project
One built-in project uses it. It opens in the editor, already wired.
The boards it is shown on
This board has a built-in project with the Nine-axis IMU, MPU-9250 in it.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Nine-axis IMU, MPU-9250
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.