MicroPython QMI8658
Small dependency-free MicroPython driver for the QST QMI8658 six-axis IMU. It provides combined acceleration (g) and angular-velocity (degrees/second) samples, with no board or UI dependency.
Install
The included package.json makes the package mip-compatible. Install it on a
network-connected board with:
import mip
mip.install("github:mattytrentini/micropython-qmi8658")
For the Waveshare ESP32-C6-Touch-LCD-1.47, the IMU shares I2C(0) with touch:
from machine import I2C, Pin
from qmi8658 import QMI8658
i2c = I2C(0, sda=Pin(18), scl=Pin(19), freq=400_000)
imu = QMI8658(i2c) # QMI8658 address 0x6B
imu.configure() # checks WHO_AM_I == 0x05, resets, then enables both sensors
ax, ay, az, gx, gy, gz = imu.sample()
The default configuration is ±8 g, ±512 dps, and ODR selector 3 (about
896 Hz in six-axis mode). It includes a short post-reset settle period to
avoid a stale first sample; call configure(reset=False, settle_ms=0) only
when deliberately restoring an already-running sensor. raw(), sample(), acceleration(),
gyroscope(), temperature(), and sleep() are available.
Test
PYTHONPATH=. pytest -q
Register mapping, output format, and scales follow the QMI8658A datasheet↗ (opens in a new tab).