Reference
MPU6050
6-axis accelerometer and gyroscope.
- Connects over
- I²C
- Address
- 0x68 (or 0x69)
- Made by
- TDK InvenSense
- Datasheet
- invensense.tdk.com
Use it
hardware {
device mpu6050: MPU6050
}
every 1s {
let value: float = mpu6050.accel_x()
log("mpu6050", "accel_x={value}")
}
On its own, the declaration puts the MPU6050 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x68. To choose the pins or the address, declare the bus and attach the device: device mpu6050: MPU6050 on i2c0 at 0x69 with i2c i2c0(sda: 21, scl: 22).
Methods
-
mpu6050.accel_x() -> float
X acceleration in g
-
mpu6050.accel_y() -> float
Y acceleration in g
-
mpu6050.accel_z() -> float
Z acceleration in g
-
mpu6050.gyro_x() -> float
X rotation °/s
-
mpu6050.gyro_y() -> float
Y rotation °/s
-
mpu6050.gyro_z() -> float
Z rotation °/s
-
mpu6050.temperature() -> float
Die temperature in °C
Wiring
| Pin | Connect to |
|---|---|
VCC | 3.3V ONLY — 5V damages the chip |
GND | Ground |
SDA | Pull-up to 3.3V |
SCL | Pull-up to 3.3V |
INT | Data-ready / motion interrupt |
AD0 | Address: 0x68 (GND) or 0x69 (VCC) |
Specifications
- Voltage
- 2.375V – 3.46V (NOT 5V tolerant on bare chip — breakouts have a regulator)
- Current
- 3.9 mA active
- Accel range
- ±2g, ±4g, ±8g, ±16g
- Gyro range
- ±250, ±500, ±1000, ±2000 dps
- Sample rate
- Up to 1 kHz
Tips
- DMP (Digital Motion Processor) inside is officially undocumented; most libraries upload Invensense's binary blob.
- Cheap modules are often relabeled clones — quality varies wildly.
- Combine with a magnetometer (HMC5883L / QMC5883L) for a 9-DoF absolute orientation system.
Alternatives worth knowing:
- MPU9250: MPU6050 + magnetometer in one chip — discontinued but still available.
- ICM-20948: Modern Invensense 9-DoF — successor to MPU9250.
- BNO055: Bosch — has built-in sensor fusion (gives quaternions directly).