Interfacing MPU-9250 9-DOF Sensor with Arduino

Interfacing MPU-9250 9-DOF Sensor with Arduino


Hello guys, today we're gonna dive into how to hook up the MPU-9250 9-DOF sensor with an Arduino! This sensor is the real deal and can measure acceleration, rotation, and magnetic fields in all three axes. we're gonna give you a step-by-step guide on how to get this baby up and running, complete with all the code you need to get started. By the end of this blog, you'll have a dope understanding of how to use the MPU-9250 sensor in your own Arduino projects. Let's get to it!


MPU-9250 is a 9-axis Inertial measurement module that is a Micro Electro Mechanical Systems configuration (MEMS). IMUs are used as real-time tracking devices to give acceleration, angular velocity, and magnetic field information on all three dimensions (x, y, and z) with high speed and accuracy. Despite its size, it is rated for high-performance and has an analog to digital converter with 16 bit resolution. It features an I2C interface with a data rate of 400 kHz for the 9- DOF Detector module, a Serial Peripheral Interface for fast mode is provided in the module with a rate up to 20 MHz. 

MPU-9250 is perfect for applications where motion and accelerations needs to be tracked like VR headsets or even as an accurate vibration sensor in an industrial environment.


MPU-9250 9-DOF Sensor



Some of the features of the MPU 9-DOF MEMS device Module are listed below

  1. It has a triple axis on accelerometer, gyro and magnetometer as well
  2. Digital-output measuring device with programmable range of ¬Ī 2g, ¬Ī 4g, ¬Ī 8g, and ¬Ī 16g for accelerometer.
  3. Digital-output measuring device with programmable range of ¬Ī 250, ¬Ī 500, ¬Ī 1000, and ¬Ī 2000 ¬į/ sec for gyroscope.
  4. 3-axis silicon monolithic Hall-effect magnetic sensor with magnetic concentrator
  5. VDD supply voltage range of 2.4‚Äď3.6V

read more : How 433MHz RF Module Works & Interfacing With Arduino


Features and Peripherals




SPI Data rate

1 Mz

SPI Fast Data Reading Rate


I2C Data Rate

400 Mhz

Shock tolerance

400 Khz

FIFO buffer

10,000 g

Auxiliary I2C interface

512 Bytes





Operating Voltage

2.4 - 3.6 Volts

Operating current

3.5 mA

Magnetometer output data resolution

14-bit (0.6¬ĶT/LSB)

low-pass filter and wake-on-motion interrupt

low power mode



Digital Output Temperature Sensor


Cross - Sensitivity


User - Programmable Digital Filter


Package Type



3 x 3 x 1 mm

Gyroscope operating current


Accelerometer Operating current


Magnetometer Operating current:




read more : Interfacing MAX30100 Pulse Oximeter with Arduino


construction of MPU9250


The MEMS Sensor module consists mainly of five components: I/ O heads, pull- up resistors, a LDO, and a decoupling capacitor.

MPU9250 chip:

Digital Motion Processor is a multi-purpose processor introduced by Asahi Kasei Microdevices Corporation. This is the main IC and  is equipped with an accelerometer, gyroscope, and magnetometer.




I/ O heads:

The input and output pins will be used to serve the purpose of connectivity and data transmission with the microcontroller unit.


Pull-up Resistors:

The pull up resistors are placed for I2C machine to source current and establish default state.



An LDO voltage regulator is provided to lower the voltage to 3.3V in order for the IC to function in its rated voltage.


Decoupling Capacitors:

Depending on the power source (5V, 3.3V, etc.) and ground, decoupling capacitors can temporarily act as power sources. These are known as bypass capacitors. Signals are filtered by these capacitors to remove unwanted noise.


read more : Arduino Interfacing with Ultrasonic Sensor


Pin Configuration

Pin Configuration MPU9250






Interrupt pin


I2C Master Serial Clock 


I2C Address/Serial data out pin


Frame Synchronisation input pin


Power supply pin


Ground pin


I2C Serial Data input 


Chip selection pin


I2C Serial Clock/SPI Serial Clock pin


I2C Serial Data/SPI Serial Data pin



read more : How to connect ZMPT101B to Arduino

Interfacing MPU-9250 9-DOF Sensor with Arduino


Interfacing with Arduino UNO



Arduino of 5 V - Vcc of the MPU-9250

Arduino of GND - GND of the MPU-9250

Arduino of A4 - SDA of the MPU-9250

Arduino of A5 - SCL of the MPU-9250

Connections between the MPU- 9250 detector module and Arduino UNO are shown in above fig.

Arduino Code:

To use the library, first download and install the MPU9250 into the Arduino IDE. After installation, include the library to sketch the code, also follow these way to get code from the library by clicking Files> Examples> MPU 9250> Calibration or you can also copy the below code to your IDE.

#include "MPU9250.h"

MPU9250 mpu;


void setup() {





    if (!mpu.setup(0x68)) {  // change to your own address

        while (1) {

            Serial.println("There was a problem connecting to MPU. If you are not sure about your connection, please check it with *connection_check*.");





    // calibrate anytime you want to

    Serial.println("wait 5sec it will start.");

    Serial.println("The device should not be moved from the flat plane.");





    Serial.println("Mag calibration will start in 5sec.");

    Serial.println("Wave the device in a figure eight until it is finished");








void loop() {



void print_calibration() {

    Serial.println("< calibration parameters >");

    Serial.println("accel bias [g]: ");

    Serial.print(mpu.getAccBiasX() * 1000.f / (float)MPU9250::CALIB_ACCEL_SENSITIVITY);

    Serial.print(", ");

    Serial.print(mpu.getAccBiasY() * 1000.f / (float)MPU9250::CALIB_ACCEL_SENSITIVITY);

    Serial.print(", ");

    Serial.print(mpu.getAccBiasZ() * 1000.f / (float)MPU9250::CALIB_ACCEL_SENSITIVITY);


    Serial.println("gyro bias [deg/s]: ");

    Serial.print(mpu.getGyroBiasX() / (float)MPU9250::CALIB_GYRO_SENSITIVITY);

    Serial.print(", ");

    Serial.print(mpu.getGyroBiasY() / (float)MPU9250::CALIB_GYRO_SENSITIVITY);

    Serial.print(", ");

    Serial.print(mpu.getGyroBiasZ() / (float)MPU9250::CALIB_GYRO_SENSITIVITY);


    Serial.println("mag bias [mG]: ");


    Serial.print(", ");


    Serial.print(", ");



    Serial.println("mag scale []: ");


    Serial.print(", ");


    Serial.print(", ");





In this blog post, we have learned that Interfacing the MPU-9250 9-DOF sensor with Arduino opens up a world of possibilities for building innovative projects that require precise motion tracking and orientation sensing. With its easy-to-use library and robust capabilities, the MPU-9250 sensor can be integrated into a wide range of applications, from drones and robotics to virtual reality and gaming. By following the simple steps outlined in this guide, you can get started on your journey to creating your own sensor-based projects and taking your skills to the next level. So, grab your Arduino and MPU-9250 sensor and get ready to unleash your creativity!



If you appreciate our work don't forget to share this post and leave your opinion in the comment box.


Please do check out other blog posts about Interfacing ACS712 with Arduino , Arduino Interfacing with Ultrasonic Sensor , LED Interfacing with Arduino , Interfacing GSM Module with Arduino , Interfacing MAX30100 Pulse Oximeter with Arduino , IR Sensor Interfacing with Arduino , How to connect ZMPT101B to Arduino and  How to use Buzzer with Arduino.


Make sure you check out our wide range of products and collections (we offer some exciting deals!)

You may also like to read

Frequently Asked Questions

1. What is a MPU-9250?

MPU-9250 is a dope little piece of tech that's got everything you need for motion tracking in one package. It's got a 3-axis gyroscope, a 3-axis accelerometer, and a 3-axis magnetometer all rolled up into a single chip. People are using it in all kinds of sick applications, from drones to VR headsets to gaming devices that use motion control. And the best part? It's small and low-power, so you can take it with you anywhere without worrying about it draining your battery.

read more : IR Sensor Interfacing with Arduino

2. What is the use of MPU-9250?

The MPU-9250 sensor module is a  combination of a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer in one compact package. This thing is perfect for projects that need precise motion tracking and orientation sensing, like drones, robots, and virtual reality systems. It gives you super accurate data and can connect to microcontrollers using interfaces like SPI or I2C. No wonder it's a go-to choice for a lot of projects.


Back to blog

Leave a comment

Please note, comments need to be approved before they are published.

You may also like to read