An IMU (Inertial Measurement Unit) sensor measures acceleration, rotation, and sometimes magnetic heading — the fundamental data needed for drones, robots, motion tracking, and gesture recognition. The MPU6050 is the most popular IMU for Arduino projects, but the MPU9250 and BNO055 offer compelling upgrades for specific applications. This guide compares all three IMU sensors, explains sensor fusion, and shows you how to get reliable orientation data from each.
What is an IMU and Why Do You Need One?
An IMU combines multiple motion sensors in one package:
- Accelerometer — Measures linear acceleration along 3 axes (X, Y, Z). Tells you which direction is “down” (gravity) and detects vibration, tilt, and impacts.
- Gyroscope — Measures angular velocity (rotation speed) around 3 axes. Tells you how fast the device is turning. Essential for stabilisation and orientation tracking.
- Magnetometer (on 9-axis IMUs) — Measures the Earth’s magnetic field along 3 axes. Provides absolute heading (compass direction), solving gyroscope drift problems.
Common applications include drone flight controllers, robot self-balancing, game controllers, step counters, fall detection systems, VR headset tracking, and camera stabilisation gimbals.
MPU6050 vs MPU9250 vs BNO055
| Feature | MPU6050 | MPU9250 | BNO055 |
|---|---|---|---|
| Axes | 6 (Accel + Gyro) | 9 (Accel + Gyro + Mag) | 9 (Accel + Gyro + Mag) |
| Onboard Fusion | DMP (basic) | No | Yes (full) |
| Interface | I2C / SPI | I2C / SPI | I2C / UART |
| Accel Range | ±2/4/8/16 g | ±2/4/8/16 g | ±2/4/8/16 g |
| Gyro Range | ±250-2000°/s | ±250-2000°/s | ±125-2000°/s |
| Heading Accuracy | Drifts over time | ±2° (with software fusion) | ±3° (hardware fusion) |
| Price (₹) | 120-200 | 250-450 | 800-1,500 |
MPU6050: The Budget Champion
The InvenSense (now TDK) MPU6050 combines a 3-axis accelerometer and 3-axis gyroscope in one chip with I2C interface. It’s been the go-to IMU for Arduino projects for over a decade, with enormous community support and dozens of libraries.
Key Features
- 16-bit ADC resolution on all axes
- Configurable accelerometer (±2g to ±16g) and gyroscope (±250°/s to ±2000°/s) ranges
- Onboard Digital Motion Processor (DMP) that can handle basic sensor fusion, reducing Arduino processing load
- Built-in temperature sensor
- I2C addresses: 0x68 (AD0 low) or 0x69 (AD0 high) — maximum 2 per bus
Arduino Code: Raw Data Reading
#include <Wire.h>
const int MPU_ADDR = 0x68;
int16_t ax, ay, az, gx, gy, gz;
void setup() {
Serial.begin(115200);
Wire.begin();
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x6B); // Power management register
Wire.write(0); // Wake up MPU6050
Wire.endTransmission(true);
}
void loop() {
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x3B); // Starting register for accel data
Wire.endTransmission(false);
Wire.requestFrom(MPU_ADDR, 14, true);
ax = Wire.read() << 8 | Wire.read();
ay = Wire.read() << 8 | Wire.read();
az = Wire.read() << 8 | Wire.read();
Wire.read(); Wire.read(); // Skip temperature
gx = Wire.read() << 8 | Wire.read();
gy = Wire.read() << 8 | Wire.read();
gz = Wire.read() << 8 | Wire.read();
// Convert to physical units (±2g range, ±250°/s range)
float accelX = ax / 16384.0; // g
float accelY = ay / 16384.0;
float accelZ = az / 16384.0;
float gyroX = gx / 131.0; // degrees/s
float gyroY = gy / 131.0;
float gyroZ = gz / 131.0;
Serial.print("Accel: ");
Serial.print(accelX, 2); Serial.print(", ");
Serial.print(accelY, 2); Serial.print(", ");
Serial.print(accelZ, 2);
Serial.print(" | Gyro: ");
Serial.print(gyroX, 1); Serial.print(", ");
Serial.print(gyroY, 1); Serial.print(", ");
Serial.println(gyroZ, 1);
delay(50);
}
When to Use the MPU6050
Self-balancing robots, basic drone stabilisation, step counters, vibration monitoring, tilt sensors, and any project where you need acceleration and rotation data without absolute heading. Its main limitation is gyroscope drift — over time, the calculated orientation accumulates error because there’s no magnetometer to provide an absolute reference.
MPU9250: Adding the Compass
The MPU9250 adds an AK8963 3-axis magnetometer to the MPU6050’s accelerometer and gyroscope, giving you 9 degrees of freedom. This allows absolute heading determination — critical for navigation and mapping applications.
Why the Magnetometer Matters
A 6-axis IMU (gyro + accel) can determine pitch and roll accurately using gravity as a reference. But yaw (rotation around the vertical axis) has no gravity reference — the gyroscope drifts and there’s nothing to correct it. The magnetometer provides an absolute yaw reference by measuring Earth’s magnetic field, similar to a compass.
Magnetic Interference in India
India’s magnetic declination varies from about -1° in the south to +3° in the northeast. More practically, indoor use presents challenges: steel reinforcement in RCC buildings, metal furniture, and nearby electronics create local magnetic disturbances. Calibrate the magnetometer after installation, and keep it at least 20 cm from motors, speakers, and steel structures.
When to Use the MPU9250
Compass-based navigation (outdoor robots, drones), heading-stabilised camera gimbals, indoor positioning systems, and any project where knowing which direction is north matters. If you don’t need heading information, save money with the MPU6050.
BNO055: Sensor Fusion Built In
Bosch’s BNO055 is a 9-axis IMU with an onboard ARM Cortex-M0 processor running proprietary sensor fusion algorithms. Instead of giving you raw accelerometer, gyroscope, and magnetometer data that you need to fuse in software, the BNO055 outputs ready-to-use orientation data as Euler angles (heading, roll, pitch) or quaternions.
Why This Matters
Sensor fusion — combining noisy data from three different sensor types into a stable orientation estimate — is mathematically complex. Popular algorithms like Madgwick and Mahony require tuning and consume processor time. The BNO055 handles all of this internally, outputting clean orientation data that you can use directly. This makes it significantly easier to work with, especially on resource-constrained platforms like Arduino Uno.
Calibration Status
The BNO055 self-calibrates but indicates its calibration status for each sensor (0 = uncalibrated, 3 = fully calibrated). To calibrate the magnetometer, rotate the sensor slowly through a figure-8 pattern. The accelerometer calibrates by placing the sensor in several different orientations. The gyroscope calibrates by holding the sensor still.
#include <Wire.h>
#include <Adafruit_BNO055.h>
#include <Adafruit_Sensor.h>
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28);
void setup() {
Serial.begin(115200);
if (!bno.begin()) {
Serial.println("BNO055 not detected!");
while (1);
}
bno.setExtCrystalUse(true);
}
void loop() {
sensors_event_t event;
bno.getEvent(&event);
Serial.print("Heading: ");
Serial.print(event.orientation.x, 1);
Serial.print(" | Roll: ");
Serial.print(event.orientation.y, 1);
Serial.print(" | Pitch: ");
Serial.print(event.orientation.z, 1);
// Calibration status
uint8_t sys, gyro, accel, mag;
bno.getCalibration(&sys, &gyro, &accel, &mag);
Serial.print(" | Cal: S");
Serial.print(sys);
Serial.print(" G");
Serial.print(gyro);
Serial.print(" A");
Serial.print(accel);
Serial.print(" M");
Serial.println(mag);
delay(100);
}
When to Use the BNO055
Projects where you need reliable orientation without deep knowledge of sensor fusion: robot arm positioning, VR controller tracking, drone autopilot integration, marine compass systems, and rehabilitation devices. The premium price (₹800-1,500) is justified by the hours of development time saved on sensor fusion implementation.
Understanding Sensor Fusion
If you use the MPU6050 or MPU9250 (without onboard fusion), you need to combine accelerometer, gyroscope, and optionally magnetometer data into a stable orientation estimate. Here’s a simplified explanation:
- Accelerometer alone — Gives tilt (pitch/roll) from gravity but is noisy and affected by vibration or linear acceleration.
- Gyroscope alone — Gives smooth, fast rotation data but drifts over time because you’re integrating angular velocity.
- Complementary filter — The simplest fusion: trust the gyroscope for short-term changes and the accelerometer for long-term stability.
angle = 0.98 * (angle + gyroRate * dt) + 0.02 * accelAngle - Madgwick/Mahony filter — More sophisticated algorithms that handle all three sensor inputs. Available as ready-to-use Arduino libraries.
- Kalman filter — The mathematically optimal approach, but computationally heavy for Arduino Uno. Works well on ESP32 or Arduino Due.
// Simple complementary filter example for MPU6050
float roll = 0, pitch = 0;
unsigned long lastTime = 0;
void updateOrientation(float ax, float ay, float az, float gx, float gy) {
unsigned long now = millis();
float dt = (now - lastTime) / 1000.0;
lastTime = now;
// Accelerometer angles
float accelRoll = atan2(ay, az) * 180.0 / PI;
float accelPitch = atan2(-ax, sqrt(ay*ay + az*az)) * 180.0 / PI;
// Complementary filter
roll = 0.98 * (roll + gx * dt) + 0.02 * accelRoll;
pitch = 0.98 * (pitch + gy * dt) + 0.02 * accelPitch;
}
Project Applications
Self-Balancing Robot
The classic MPU6050 project. Read pitch angle, feed it into a PID controller, and drive two motors to keep the robot upright. This teaches PID control, sensor fusion, and real-time motor control in one engaging project.
Drone Flight Controller
All drone flight controllers use IMUs for stabilisation. The MPU6050 works for basic quadcopters; the MPU9250 adds heading hold; the BNO055 adds plug-and-play orientation but may be too slow (100 Hz max) for aggressive flight — racing drones typically need 1000+ Hz IMU updates.
Gesture Controller
Strap an MPU6050 to your hand and map accelerometer/gyroscope readings to control inputs. Tilt left to steer left, shake to trigger an action, rotate to scroll through menus. Works well with Bluetooth modules for wireless control of robots or media players.
Step Counter / Pedometer
The accelerometer detects the repetitive up-down motion of walking. Count peaks above a threshold in the vertical axis. The MPU6050 is ideal for this — no magnetometer needed, and it draws minimal power in low-power mode.
Frequently Asked Questions
Which IMU is best for a drone?
For learning and a first build, the MPU6050 is sufficient and has extensive drone-specific tutorials (MultiWii, Cleanflight). For GPS-assisted drones that need heading hold, the MPU9250 is the standard choice. The BNO055 is easy to use but its maximum 100 Hz output rate can be limiting for high-performance flight controllers that expect 1000 Hz.
Why does my MPU6050 yaw angle keep drifting?
Without a magnetometer, yaw drift is unavoidable with a 6-axis IMU. The gyroscope provides relative yaw changes, but tiny biases accumulate over time. Solutions: (1) Use the DMP firmware which has better internal filtering, (2) upgrade to a 9-axis IMU (MPU9250 or BNO055), or (3) accept the drift if your application doesn’t need absolute yaw (e.g., a self-balancing robot only needs pitch).
Can I use two MPU6050 sensors on the same Arduino?
Yes. Connect one with AD0 pin low (address 0x68) and the other with AD0 high (address 0x69). Both share the same I2C bus (SDA/SCL) but respond to different addresses.
Is the MPU9250 still being manufactured?
InvenSense (TDK) discontinued the MPU9250, but compatible alternatives are widely available. The ICM-20948 is the official replacement with similar specifications. For Arduino projects, the MPU9250 breakout boards are still widely sold and work perfectly with existing code.
How do I reduce vibration noise from motors?
In drone and robot applications, motor vibrations contaminate accelerometer readings. Use soft mounting (foam tape or rubber grommets) between the IMU board and the frame. Apply a low-pass filter in software. The MPU6050’s built-in digital low-pass filter (DLPF) can be configured from 5 Hz to 260 Hz bandwidth — set it to the lowest value that still responds fast enough for your control loop.
Conclusion
For most Arduino projects, start with the MPU6050 — at ₹120-200, it delivers 6-axis motion data with excellent library support. If your project requires compass heading (navigation, mapping), step up to the MPU9250 or its ICM-20948 replacement. And if you want clean orientation data without implementing sensor fusion algorithms, the BNO055 saves significant development time for a premium price. All three connect via I2C and work with Arduino, ESP32, and Raspberry Pi.
Find IMU sensors and motion modules at Zbotic’s sensor modules store.
Add comment