Skip to content
A

IMU / Accelerometer

Interfacing MPU9250 IMU / Accelerometer with Arduino Uno

What is the MPU9250?

The MPU-9250 is a 9-axis inertial measurement unit (IMU) that combines a 3-axis accelerometer, 3-axis gyroscope and 3-axis AK8963 magnetometer. It measures linear acceleration, angular velocity and magnetic field, making it useful for motion tracking, orientation experiments and electronic compass projects. The sensor does not directly output a reliable heading or fused orientation; those require calibration and software processing.

Warning

**Check your exact breakout board before powering it.** The MPU-9250 IC itself requires about 2.4–3.6 V. For these examples, use 3.3 V and 3.3 V I²C pull-ups. Some breakout boards add a regulator or level shifting; others do not. Do not assume every board is 5 V tolerant.

MPU-9250 key specifications

Motion sensors
3-axis accelerometer + 3-axis gyroscope + 3-axis magnetometer (AK8963)
IC supply
2.4–3.6 V; breakout-board power input may differ
Host interface
I²C up to 400 kHz or SPI; check the datasheet/module for mode limits
I²C address
0x68 when AD0 is LOW; 0x69 when AD0 is HIGH
Accelerometer ranges
±2 g, ±4 g, ±8 g or ±16 g
Gyroscope ranges
±250, ±500, ±1000 or ±2000 °/s
Magnetometer
AK8963, 3 axes, up to ±4800 µT full scale
Digital outputs
16-bit sensor data registers
Typical use
Motion sensing, tilt experiments, compass and orientation projects

Common 8-pin MPU-9250 breakout header

PinConnection / purposeNotes
VCC3.3 V supplyFollow the breakout-board rating; the IC itself is not 5 V powered.
GNDGroundConnect to controller ground.
SCLI²C clockUno A5; classic ESP32 GPIO22 in these examples.
SDAI²C dataUno A4; classic ESP32 GPIO21 in these examples.
XDAAuxiliary I²C dataNot required for ordinary host I²C examples.
XCLAuxiliary I²C clockNot required for ordinary host I²C examples.
AD0I²C address selectGND selects 0x68; HIGH selects 0x69.
NCSInterface select / chip selectHold HIGH for I²C mode; SPI wiring differs.
INTInterrupt outputOptional; can signal data-ready or configured events.

Swipe sideways to see every column →

How the MPU-9250 works

The accelerometer measures acceleration including gravity, so a stationary sensor can estimate tilt from the gravity vector. The gyroscope measures rotation rate and is useful for responsive motion tracking, but integrating its output causes drift. The AK8963 magnetometer measures the local magnetic field and can help estimate heading after calibration. Motors, speakers, steel, magnets and current-carrying wires can distort magnetic readings.

The MPU-9250 contains several sensor subsystems. Reading acceleration and gyro data does not automatically produce a stable compass heading or full orientation. For those results, choose an appropriate sensor-fusion algorithm and calibrate the device in its installed environment.

I²C wiring and address

Use the board-specific wiring below and keep SDA/SCL wiring short. The examples connect AD0 to GND for address 0x68 and NCS to 3.3 V to select I²C mode. If AD0 is tied HIGH, change the address in the sketch to 0x69. Avoid 5 V pull-ups on the I²C bus when the breakout is not level-shifted.

Tip

**Calibration tip:** Keep the module still and level during startup gyro/accelerometer offset calibration. Magnetometer calibration is a separate step: rotate the assembled device through different orientations and compensate for hard-iron and soft-iron effects. A simple `autoOffsets()` call should not be described as complete compass calibration.

What you can build

  • Digital compass: use calibrated magnetometer readings and tilt compensation when the board is not level.
  • Motion logger: record acceleration and angular velocity for experiments or gesture recognition.
  • Orientation interface: combine the sensor data with a suitable fusion filter for a more stable attitude estimate.
  • Robot or drone prototype: use the IMU as one input to a larger control system; validate sampling, vibration isolation and calibration before relying on it.
  • Wearable and handheld projects: detect movement patterns while accounting for drift and magnetic interference.

Troubleshooting

SymptomLikely causeWhat to do
Sensor not detectedPower, address or wiring problemVerify 3.3 V, shared GND, SDA/SCL, AD0 and I²C mode; run an I²C scanner.
I²C scanner finds 0x69, code expects 0x68AD0 is HIGHSet the library address to 0x69 or connect AD0 to GND.
Magnetometer data missing or implausibleAK8963 initialization/bypass issue, clone module, or interferenceVerify the module really contains an MPU-9250, use a compatible library, and test away from magnets and steel.
Heading changes near motorsMagnetic interferenceMove the IMU away from motors and high-current wiring; recalibrate in the final assembly.
Tilt/heading driftsGyroscope integration drift or incomplete calibrationUse sensor fusion, calibrate offsets and do not treat raw gyro integration as absolute orientation.
ESP32 resets or bus behaves erraticallyIncorrect supply, long wires or 5 V I²C pull-upsUse 3.3 V logic, short wiring and a stable supply; inspect breakout pull-ups.

Swipe sideways to see every column →

Frequently asked questions

Is MPU-9250 the same as MPU-6050? No. The MPU-6050 has an accelerometer and gyroscope; the MPU-9250 adds a 3-axis AK8963 magnetometer.

Can I power it from 5 V? Only if the exact breakout board explicitly supports a 5 V input. The bare IC requires 2.4–3.6 V. The examples here use 3.3 V.

Does it provide yaw, pitch and roll directly? No. It provides raw sensor measurements. Orientation angles require processing; heading also needs magnetometer calibration and tilt compensation.

Why do some cheap modules fail the MPU-9250 check? Some visually similar boards contain MPU-6500 or other compatible-looking chips. Check the chip marking and library detection rather than assuming every clone is genuine.

Can the embedded simulator reproduce real sensor data? No. It demonstrates the circuit layout and interactive tilt visualization; it does not emulate the MPU-9250 register protocol, live AK8963 field measurements, noise, drift or sensor fusion.

Choose a board integration: MPU-9250 with Arduino Uno · MPU-9250 with ESP32

Setting Up MPU9250 with Arduino Uno

Library

MPU9250_WE by Wolfgang Ewald

Arduino IDE → Library Manager → search "MPU9250_WE"

Wiring

Component pinArduino Uno pinNote
VCC3.3VUse 3.3 V unless the exact breakout explicitly supports 5 V.
GNDGNDCommon ground.
SCLA5 / SCLUno I2C clock.
SDAA4 / SDAUno I2C data.
AD0GNDSelect I2C address 0x68.
NCS3.3VKeep HIGH for I2C mode.
XDA / XCL / INTNot connectedOptional for this example.

Swipe sideways to see every column →

Warning

The MPU-9250 IC is a 3.3 V device. Confirm your breakout's regulator and I2C pull-up circuitry; do not put 5 V on the sensor or ESP32 GPIO.

C++

Setup and calibration

  1. Install MPU9250_WE by Wolfgang Ewald from Arduino IDE Library Manager.
  2. Wire the module exactly as shown and connect AD0 to GND for address 0x68.
  3. Upload the sketch and keep the sensor motionless during startup offset calibration.
  4. Open Serial Monitor at 9600 baud and move/rotate the module to observe changes.
  5. Compass heading requires separate magnetometer calibration and compensation for nearby magnetic interference.

Library reference and source: https://github.com/wollewald/MPU9250_WE (MIT-licensed MPU9250_WE library).

Expected output

Serial Monitor prints acceleration in g, angular velocity in degrees per second, and magnetic-field readings in microtesla. Raw values are not fused pitch, roll or yaw angles.

Troubleshooting

  • No device found: check 3.3 V, GND, SDA/SCL, NCS HIGH and AD0; run an I2C scanner.
  • If AD0 is HIGH, use address 0x69.
  • Missing or implausible magnetometer values: verify the chip/module and use a compatible library; some clones contain a different IC.
  • Heading changes near motors or steel: move the sensor away from magnetic interference and calibrate in the final installation.
  • Jumpy values: secure the module, shorten I2C wires and verify the supply.

Try this circuit — SolderHub Simulator

The circuit is preloaded for exploration. Confirm simulator behavior against the real wiring and sensor datasheet before connecting hardware.

Related Components

Related Guides & Projects