Interfacing GY-91 (9-axis MPU9250 + BMP280) Module with Arduino


This IMU module is a small board which all the sensors required for 10 degrees of freedom are placed in. This module communicates with the Arduino or microcontrollers via the I2C interface. Using the existing FreeIMU functions and source code, you can easily use this IMU as an AHRS system in flight controls. You can use this module in VTOLs, model airplanes, UAVS, and also industrial and medical devices.

MPU9250 + BMP280 Module

GY-91 Module Pinout

This sensor has 8 pins:

  • VIN: Module power supply – 5 V
  • GND: Ground
  • 3V3: Module power supply – 3.3 V
  • SLC: I2C Clock / SPI Clock
  • SDA: I2C data / MOSI pin for SPI
  • SAO/SDO: Address adjust pin for I2C / MISO pin for SPI
  • NCS: Chip Select pin only for MPU-9250 sensor
  • CSB: Chip Select pin only for BMP280 sensor

You can see pinout of this module in the image below.

You can download the datasheet of this module here.

MPU Datasheet

BMP280 Datasheet

Required Materials

Hardware Components

Arduino UNO R3 × 1
MPU9250 + BMP280 Module × 1
Male to Female jumper wire × 1

Software Apps

Interfacing GY-91 Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to this module. Connect wires accordingly.

Step 2: Code

Install the following library on your Arduino.

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Upload the following code to your Arduino.

After uploading the code, by moving the module, you can see the output in the serial monitor.

Liked What you see?

Get updates and learn from the best

More To Explore

Interfacing 3D Printer 20X04 LCD Smart Controller with Arduino

Interfacing DS3231 Real Time Clock RTC Module with Arduino

Comments (13)

acelerometro:17:14: error: ‘SDA_PIN’ was not declared in this scope
acelerometro:17:23: error: ‘SCL_PIN’ was not declared in this scope

Just to improve your tutorial. Thank you for the post!

The code was originally written for an Arduino Board. If you’re planning to use it for an ESP32 Board, then you need to define SDA and SCL pins on your own.

Hallo, thanks for your code.
I use mCore (ATmega328) with GY-91 wired to pin SDA and SCL of port 3.
So I can read MPU9250 data but anything about BMP280.
May be I have to wire it to another PINs (I tried with 11,12,A0,A1) but I don’t know which ones.
Can you help me, please?
Thank you!

BMP280 and MPU9250 both use I2C communication protocols, but they have different I2C addresses and can use the same I2C bus for communication. So now that you have connected the GY-91 module to the I2C pins of your microcontroller, no more wiring is needed. You can access both BMP280 and MPU9250 through those pins. You just need to use the appropriate libraries for that.

Hello, great code, thank you for it.
I am using arduino Mega and GY91 bought on aliexpress.
However, only gyro’s data is changing on serial display. Do I have to modify something in libraries (adresses maybe ?) in order to access the full data ?
Thank you

Hi. The tutorial here is based on Arduino Uno, but there shouldn’t be any difference in the code when using your module with Arduino Mega. Just keep in mind that the Arduino Mega I2C pin are A20 and A21. (SDA and SCL respectively) So that’s the only difference you should pay attention to when interfacing the module with Arduino Mega, and you should get the same results as here. If you don’t, there can be something wrong with the GY-91 module. To check the functionality of the sensor, you can use i2c_scanner code provided in Arduino IDE examples → Wire → i2c_scanner and see the i2c addresses it returns.

Hello, great code,
I am using Arduino/Teensy and this module GY-91
i am getting this values for AccelX and AccelY. Here is link:
Can you help me?
Thanks .

Hello my friend,
When the values of some particular parameters don’t change, it usually means that there is something wrong with the module. Try to find some other library and code and compare the results. If nothing changed and the problem still persisted, you’ll probably need to get a new module.
Good luck.

Hello. Really nice tutorial and code.
However, I am running into one problem.
The mpu9250 is giving me good values for accel, gyro, and mag, but the bmp280 is giving me nothing. Temp reads 0.00, pressure reads 0.00 which causes the alt to read 44330.00. I have tried three different gy-91s and all three gave me the same result.
I thought at first it might be the library, so I tried a different library but received the same result. Because a library change didn’t do anything and the wiring is obviously correct since the mpu9250 works, that leaves me to conclude that the problem is in the gy-91 itself. However, I could understand one of them being defective, but all three?!
I am hoping I just missed something somewhere rather than buying 3 defective gy-91s.
Thank you for your time.

Hello. Thanks for your exhaustive explanation of your problem! According to what you have already done, there is little I can add to that. There is just one other thing you haven’t check. Use the “i2c_scanner” code to check what addresses it returns. To find this code, open the Arduino IDE. You can see the code in “File → Examples → Wire → i2c_scanner”. Using this code, you can find out what I2C devices are connected to your Arduino Board. The I2C address of the BMP280 sensor is 0x76 of 0x77. If the i2c_scanner doesn’t return an address like that, then the modules might be defective. Hope that helps! Good luck.

Joshua, your problem is possibly that you need to set the address of the BMP 280 on line 21. Change line 21 in the code above from:

bme.begin(0x76); // Assumes GY-91’s BMP 280 is at default address

This worked for me with a GY-91 attached to a TeensyDuino 3.2 after reading and running Wire — Scanner with Scanner set up for a Teensy’s I2C pins.

My mag reading is stuck at zero but that is a separate problem.

In file included from accel_WR.ino:4:0:
C:\Users\Maheek Fatima\Documents\Arduino\libraries\Adafruit_BMP280_Library/Adafruit_BMP280.h:24:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include “Adafruit_Sensor.h”
compilation terminated.
Error compiling.

if anyone can help!

I just compiled the code to make sure there is no error, and there was none. Make sure you have installed the 2 libraries discussed in the tutorial. Also, make sure you have the “Adafruit Unified Sensor” library installed on your Arduino IDE. It’s a library that a lot of other libraries such as the 2 libraries in this article use. To install it, open your Arduino IDE. Go to “Tools → Manage Libraries”. Type “Adafruit Unified Sensor” in the search box, scroll down to find the “Adafruit Unified Sensor” library and install it. That must solve your problem.