#accelerometer #imu #dmp #magnetometer #gyroscope #mpu9250


Library for the MPU-9250 IMU and Digital Motion Processor

1 stable release

Uses old Rust 2015

1.0.0 Oct 11, 2018

#1141 in Math

MIT license

1.5K SLoC

MPU-9250 Library for Rust Latest Version Documentation

A library for the MPU-9250 9-axis IMU. Only supports the i2c interface (no SPI). Includes a minimal interface to the onboard Digital Motion Processor.


  • Adjustable full scale range (2G..16G) and low-pass-filter bandwidth.
  • Adjustable sample rate.
  • Adjustable fifo population rate.
  • Setup of DMP interrupt and fifo.
  • Quaternion output from the DMP.

Note: Heading Estimation

Because the quaternions are computed from a 6-axis measurement (accelerometer and gyroscope, no magnetometer), it suffers from significant yaw drift. If you require accurate heading, it's best to ignore the quaternion output and instead use a separate 9-axis filter such as Madgwick.

Note: Crate Quality

This crate was built to do performance testing on the MPU-9250 after which usage of this crate was halted. The code isn't under active development and hasn't been cleaned up. Because there are few examples of using the DMP out there I thought it would still be valuable to share this with others.


See examples/scan.rs and examples/scan_dmp.rs. Use -h to see parameters for i2c, sample rate, and interrupt pin.


By default, uses i2c bus=1 and addr=0x68, and expects a WHOAMI register value of 0x71. To override, use these environment variables:

MPU9250_I2C_BUS=1 MPU9250_I2C_ADDR=104 MPU9250_WHOAMI=115 cargo test



There are no plans to do these.

  • Expose temperature readings in Mpu9250Sample.
  • DMP configurations such as orientation and tap detection.


~91K SLoC