The Sense of Balance
Just as humans use their inner ear to stay upright and know which way is down, robots use IMUs. An IMU typically combines three types of sensors: an Accelerometer (gravity/force), a Gyroscope (rotation), and often a Magnetometer (heading).
Sensor Fusion
Raw data from these sensors is noisy or drifts. Fusion algorithms (like Kalman Filters) mathematically combine them to get a clean, stable orientation.
6-Axis vs 9-Axis
6-Axis: Accel + Gyro (Good for balance/drones, but yaw drifts).
9-Axis: Adds Compass (Fixes yaw drift, gives real North).
Accelerometers
Inertial SensorMeasures proper acceleration (g-force). Essential for detecting orientation (gravity vector) and motion changes.
How it works
Micro-Electro-Mechanical Systems (MEMS) use microscopic suspended masses. When the sensor accelerates, inertia displaces the mass, changing capacitance which is measured as voltage.
Applications
Tilt detection, vibration monitoring, step counting, crash detection
Gyroscopes
Inertial SensorMeasures angular velocity (rate of rotation) in degrees per second.
How it works
Vibrating structre MEMS gyroscopes use the Coriolis effect. As the sensor rotates, a vibrating mass is pushed perpendicularly, creating a detectable signal proportional to rotation rate.
Applications
Stabilization (drones/cameras), turns tracking, angular velocity control
Magnetometers (Compass)
OrientationMeasures the strength and direction of magnetic fields, primarily Earth's magnetic field for heading.
How it works
Uses Hall Effect or Magnetoresistive elements to detect magnetic flux density. Acts as a digital compass.
Applications
Compass heading, map alignment, correcting gyroscope drift (yaw)
9-Axis IMU (AHRS)
Sensor FusionCombines Accelerometer, Gyroscope, and Magnetometer (3+3+3 axes) to provide total orientation (Roll, Pitch, Yaw).
How it works
Algorithms (Kalman Filter, Madgwick) fuse data: Accel gives gravity vector (Roll/Pitch), Mag gives North (Yaw), and Gyro provides fast updates and smoothing.
Applications
VR/AR tracking, sophisticated drone control, robot localization
Fiber Optic Gyro (FOG)
High-Grade InertialNavigation-grade gyroscope using laser light interference for extreme precision.
How it works
Based on the Sagnac effect. Two laser beams travel in opposite directions through a fiber coil. Rotation causes a phase shift between them proportional to angular velocity.
Applications
Submarine navigation, missile guidance, autonomous mining trucks, mapping without GPS
IMU Component Comparison
| Sensor | Measures | Major Drift/Error | Cost |
|---|---|---|---|
| Accelerometer | Linear Accel / Tilt | Vibration noise | Low ($) |
| Gyroscope | Rotation Rate | Bias instability | Low ($) |
| Magnetometer | Magnetic Field | Magnetic interference | Low ($) |
| 6-Axis IMU | Roll/Pitch/Rate | Accumulated error | Medium ($$) |
| 9-Axis AHRS | Full Orientation | Calibration dependant | Medium ($$$) |
IMU Selector
What do you need to measure?
#include <Wire.h>
const int MPU_ADDR = 0x68; // I2C address of the MPU-6050
int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;
void setup() {
Wire.begin();
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // Wake up the MPU-6050
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop() {
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x3B); // Starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_ADDR, 14, true); // Request 14 Registers
//Read 14 bytes (Accel High+Low, Temp, Gyro High+Low)
AcX = Wire.read()<<8|Wire.read();
AcY = Wire.read()<<8|Wire.read();
AcZ = Wire.read()<<8|Wire.read();
Tmp = Wire.read()<<8|Wire.read();
GyX = Wire.read()<<8|Wire.read();
GyY = Wire.read()<<8|Wire.read();
GyZ = Wire.read()<<8|Wire.read();
Serial.print("Accel X: "); Serial.print(AcX);
Serial.print(" | Gyro X: "); Serial.println(GyX);
// NOTE: These are RAW values. Converting to degrees requires math:
// Accel angle = atan2(AcY, AcZ) * 180/PI
// Gyro rate = GyX / 131.0
// Combine them with a Complementary Filter or Kalman Filter for stable tilt.
delay(100);
}