MPU6050 — Accel / Gyro¶
I2C address 0x68. 3-axis accelerometer, 3-axis gyroscope, and die temperature.
Connect and read¶
from eyes17 import eyes
from eyes17.SENSORS import MPU6050
p = eyes.open()
imu = MPU6050.connect(p.I2C) # address=0x68 by default
print(imu.getRaw())
# [Ax, Ay, Az, Temp_C, Gx, Gy, Gz]
Or via auto-detect:
sens = p.guess_sensor()
# pick the MPU6050 instance from the list
Configuration¶
| Method | Options |
|---|---|
setAccelRange(rs) |
2, 4, 8, 16 (g) |
setGyroRange(rs) |
250, 500, 1000, 2000 (°/s) |
KalmanFilter(opt) |
0.01…10000, or 'OFF' |
powerUp(...) |
wake device |
imu.setAccelRange(4)
imu.setGyroRange(500)
ax, ay, az, temp, gx, gy, gz = imu.getRaw()
print(f'Temp={temp:.1f} C Accel=({ax:.3f},{ay:.3f},{az:.3f}) g')
Helpers: getAccel(), getGyro() return 3-vectors when you do not need temperature.