sts1_sensors.edu.BMM150

Module Contents

class BMM150(address=None, bus=None)

Geomagnetic sensor.

Builds on top of the library bmm150.

Parameters:
  • address (hexadecimal) – Physical address of the sensor on the board (see i2cdetect command). Allowed values: [0x10, 0x11, 0x12, 0x13]. If None, the environment variable STS1_SENSOR_ADDRESS_BMM150 will be used. If environment variable is not found, 0x10 will be used.

  • bus (SMBus) – A SMBus object. If None, this class will generate its own, defaults to None.

Example:

mag = BMM150()
x, y, z = mag.get_magnetic_data()
print(f"{x=:.2f} µT, {y=:.2f} µT, {z=:.2f} µT")
print(f"Heading: {mag.get_heading():.2f}°")
property address
get_raw_magnetic_data()

Get raw magnetic data in µT.

get_magnetic_data()

Get magnetic data in µT.

get_heading()

Get heading direction in degrees. Uses only x and y for calculation (z is ignored).