Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use MPU9250/GY -91: Examples, Pinouts, and Specs

Image of MPU9250/GY -91Design with MPU9250/GY -91 in Cirkit Designer

Introduction

The MPU9250/GY-91 is a 9-axis motion tracking device that integrates a 3-axis gyroscope, a 3-axis accelerometer, and a 3-axis magnetometer into a single compact module. This sensor is widely used in applications requiring precise orientation and motion sensing, such as robotics, drones, mobile devices, and wearable technology. Its ability to measure angular velocity, linear acceleration, and magnetic field strength makes it a versatile component for motion tracking and navigation systems.

Explore Projects Built with MPU9250/GY -91

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of ESP32-Based Accident Detection and GPS Tracking System with GSM Notifications: A project utilizing MPU9250/GY -91 in a practical application
ESP32-Based Accident Detection and GPS Tracking System with GSM Notifications

This circuit features an ESP32 microcontroller interfaced with an MPU6050 accelerometer/gyroscope, a Neo 6M GPS module, and a SIM800L GSM module. The ESP32 communicates with the MPU6050 via I2C (SCL and SDA lines) to detect potential accidents based on acceleration thresholds, with the GPS module providing location data via a serial connection (RX0 and TX0). The SIM800L GSM module is connected to the ESP32 through another serial interface (RX2 and TX2) to send SMS alerts with location information in case of an accident detection.

Open Project in Cirkit Designer
Image of Battery-Powered ESP32 and MPU-6050 Motion Sensor: A project utilizing MPU9250/GY -91 in a practical application
Battery-Powered ESP32 and MPU-6050 Motion Sensor

This circuit consists of an ESP32 microcontroller connected to an MPU-6050 accelerometer and gyroscope sensor, powered by a Li-ion battery. The ESP32 communicates with the MPU-6050 via I2C protocol, with the SDA and SCL lines connected to D21 and D22 pins of the ESP32, respectively. The circuit is designed for motion sensing and data acquisition applications.

Open Project in Cirkit Designer
Image of Arduino Nano and MPU-9250 Based 9-DoF Sensor Fusion System: A project utilizing MPU9250/GY -91 in a practical application
Arduino Nano and MPU-9250 Based 9-DoF Sensor Fusion System

This circuit interfaces an Arduino Nano with an MPU-9250 sensor to capture and process 9-axis motion data, including accelerometer, gyroscope, and magnetometer readings. The Arduino Nano runs a sketch that initializes the sensor, performs self-tests, calibrates the sensor, and processes the motion data using Madgwick and Mahony filter algorithms for sensor fusion.

Open Project in Cirkit Designer
Image of ESP32-Controlled Multi-MPU6050 and MPU9250 IMU Data Aggregator: A project utilizing MPU9250/GY -91 in a practical application
ESP32-Controlled Multi-MPU6050 and MPU9250 IMU Data Aggregator

This circuit features an ESP32 microcontroller interfaced with multiple MPU-6050 sensors and a single MPU-9250 sensor through an Adafruit TCA9548A I2C multiplexer, allowing for the reading of multiple inertial measurement units (IMUs) over the same I2C bus. The ESP32 collects and processes acceleration and gyroscopic data from the sensors to calculate angles in the X and Y axes. Power management is handled by a TP4056 charging module and an AMS1117 voltage regulator, which together with two 18650 Li-ion batteries, provide a stable power supply for the microcontroller and sensors.

Open Project in Cirkit Designer

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

The GY-91 breakout board typically has the following pinout:

Pin Name Description
1 VCC Power supply input (3.3V recommended)
2 GND Ground connection
3 SCL I2C clock line (or SPI clock line in SPI mode)
4 SDA I2C data line (or SPI data input/output in SPI mode)
5 NCS Chip select for SPI communication (active low, connect to GND for I2C mode)
6 INT Interrupt pin (used for motion detection or data-ready signals)
7 AD0/SDO I2C address selection (connect to GND for 0x68 or VCC for 0x69) / SPI data out

Usage Instructions

How to Use the MPU9250/GY-91 in a Circuit

  1. Power the Module: Connect the VCC pin to a 3.3V power source and GND to ground.
  2. Select Communication Protocol:
    • For I2C: Connect the SCL and SDA pins to the corresponding I2C pins on your microcontroller. Ensure the NCS pin is connected to GND.
    • For SPI: Connect the SCL, SDA, NCS, and AD0/SDO pins to the appropriate SPI pins on your microcontroller.
  3. Set the I2C Address: If using I2C, connect the AD0 pin to GND for the default address (0x68) or to VCC for the alternate address (0x69).
  4. Add Pull-Up Resistors: If not already present on the breakout board, add 4.7kΩ pull-up resistors to the SCL and SDA lines for I2C communication.
  5. Initialize the Sensor: Use a library or write custom code to configure the sensor and read data.

Important Considerations and Best Practices

Example Code for Arduino UNO

Below is an example of how to use the MPU9250/GY-91 with an Arduino UNO via I2C:

#include <Wire.h>
#include <MPU9250.h> // Include a library for MPU9250 (e.g., SparkFun MPU-9250 library)

MPU9250 mpu; // Create an MPU9250 object

void setup() {
  Serial.begin(9600); // Initialize serial communication
  Wire.begin();       // Initialize I2C communication

  // Initialize the MPU9250
  if (mpu.begin() != INV_SUCCESS) {
    Serial.println("Failed to initialize MPU9250!");
    while (1); // Halt if initialization fails
  }
  Serial.println("MPU9250 initialized successfully!");
}

void loop() {
  // Read sensor data
  if (mpu.readSensor() == INV_SUCCESS) {
    Serial.print("Accel (g): ");
    Serial.print(mpu.getAccelX_mss(), 2); Serial.print(", ");
    Serial.print(mpu.getAccelY_mss(), 2); Serial.print(", ");
    Serial.println(mpu.getAccelZ_mss(), 2);

    Serial.print("Gyro (deg/s): ");
    Serial.print(mpu.getGyroX_rads(), 2); Serial.print(", ");
    Serial.print(mpu.getGyroY_rads(), 2); Serial.print(", ");
    Serial.println(mpu.getGyroZ_rads(), 2);

    Serial.print("Mag (uT): ");
    Serial.print(mpu.getMagX_uT(), 2); Serial.print(", ");
    Serial.print(mpu.getMagY_uT(), 2); Serial.print(", ");
    Serial.println(mpu.getMagZ_uT(), 2);

    delay(500); // Delay for readability
  } else {
    Serial.println("Failed to read sensor data!");
  }
}

Troubleshooting and FAQs

Common Issues

  1. No Communication with the Sensor:

    • Cause: Incorrect wiring or I2C address mismatch.
    • Solution: Double-check the connections and ensure the AD0 pin is set correctly for the desired I2C address.
  2. Inaccurate Readings:

    • Cause: Lack of calibration or external interference.
    • Solution: Perform accelerometer, gyroscope, and magnetometer calibration. Avoid placing the sensor near magnetic or metallic objects.
  3. Sensor Not Initializing:

    • Cause: Incorrect power supply voltage or faulty module.
    • Solution: Verify the power supply voltage is 3.3V. Test with another module if necessary.

FAQs