Interfacing MPU-9250 9-DOF Sensor with Arduino

Introduction

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

Specification:

Features and Peripherals

Availability

Structure

MEMS

SPI Data rate

1 Mz

SPI Fast Data Reading Rate

20Mhz

I2C Data Rate

400 Mhz

Shock tolerance

400 Khz

FIFO buffer

10,000 g

Auxiliary I2C interface

512 Bytes

SPI

1

I2C

1

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

VDDIO

Yes

Digital Output Temperature Sensor

Yes

Cross - Sensitivity

Minimum

User - Programmable Digital Filter

Yes

Package Type

QFN

Dimensions

3 x 3 x 1 mm

Gyroscope operating current

3.2mA

Accelerometer Operating current

450¬ĶA

Magnetometer Operating current:

280¬ĶA


Constructions

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.

 

LDO: 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.

Pin Configuration

Pin Configuration MPU9250

PIN NAME

FUNCTION

INT

Interrupt pin

ECL

I2C Master Serial Clock 

AD0/SD0

I2C Address/Serial data out pin

FSYNC

Frame Synchronisation input pin

VCC

Power supply pin

GND

Ground pin

EDA

I2C Serial Data input 

nCS

Chip selection pin

SCL/SCLK

I2C Serial Clock/SPI Serial Clock pin

SDA/SDI

I2C Serial Data/SPI Serial Data pin


Interfacing MPU-9250 9-DOF Sensor with Arduino

Interfacing with Arduino UNO

Connection:

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() {

    Serial.begin(115200);

    Wire.begin();

    delay(2000);

 

    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*.");

            delay(5000);

        }

    }

 

    // calibrate anytime you want to

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

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

    mpu.verbose(true);

    delay(5000);

    mpu.calibrateAccelGyro();

 

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

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

    delay(5000);

    mpu.calibrateMag();

 

    print_calibration();

    mpu.verbose(false);

}

 

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();

    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();

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

    Serial.print(mpu.getMagBiasX());

    Serial.print(", ");

    Serial.print(mpu.getMagBiasY());

    Serial.print(", ");

    Serial.print(mpu.getMagBiasZ());

    Serial.println();

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

    Serial.print(mpu.getMagScaleX());

    Serial.print(", ");

    Serial.print(mpu.getMagScaleY());

    Serial.print(", ");

    Serial.print(mpu.getMagScaleZ());

    Serial.println();

}

Conclusion

Using this MPU9250 detector we can obtain the acceleration, angular velocity, and magnetic field on all 3 dimensions (x, y, and z) at high frequency and great accuracy.

Leave a comment

Please note, comments must be approved before they are published