bmm150 — BMM150 3-axis magnetometer
Driver for the Bosch BMM150 3-axis geomagnetic sensor over I2C. On construction the driver soft-resets the device, switches it into normal operating mode at the requested ODR, and reads the trim registers used by the Bosch compensation equations to convert raw readings into calibrated magnetic-field values.
Note
SPI mode is not supported by this driver; passing a non-I2C bus raises
ValueError.
Example:
import time
from machine import Pin, I2C
from bmm150 import BMM150
imu = BMM150(I2C(1, scl=Pin(15), sda=Pin(14)))
while True:
print("magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}".format(*imu.magnet()))
time.sleep_ms(100)
Classes
- class bmm150.BMM150(bus: machine.I2C, cs: machine.Pin | None = None, address: int = 0x10, magnet_odr: int = 30)
Construct a
BMM150instance, soft-reset the chip, verify its chip ID, configure it for normal mode atmagnet_odrHz and read the factory trim registers.busA configured
machine.I2Cbus the sensor is attached to.csReserved for SPI mode. Must be left as
None; SPI is not currently implemented and supplying a non-I2C bus raisesValueError.address7-bit I2C address of the device. Defaults to
0x10.magnet_odrMagnetometer output data rate in Hz. Must be one of
2,6,8,10,15,20,25or30; anything else raisesValueError.