Table of Contents

Class Bmm150

Namespace
Iot.Device.Magnetometer
Assembly
Iot.Device.Bmm150.dll

Bmm150 class implementing a magnetometer.

[Interface("Bmm150 class implementing a magnetometer")]
public sealed class Bmm150
Inheritance
Bmm150

Constructors

Bmm150(I2cDevice)

Initializes a new instance of the Bmm150 class.

public Bmm150(I2cDevice i2CDevice)

Parameters

i2CDevice I2cDevice

The I2C device.

Bmm150(I2cDevice, Bmm150I2cBase, bool)

Initializes a new instance of the Bmm150 class.

public Bmm150(I2cDevice i2cDevice, Bmm150I2cBase bmm150Interface, bool shouldDispose = true)

Parameters

i2cDevice I2cDevice

The I2C device.

bmm150Interface Bmm150I2cBase

The specific interface to communicate with the Bmm150.

shouldDispose bool

True to dispose the I2C device when class is disposed.

Fields

PrimaryI2cAddress

Primary I2C address for the Bmm150 In the official sheet (P36) states that address is 0x13. Visit https://github.com/m5stack/M5_BMM150/blob/master/src/M5_BMM150_DEFS.h#L16.3 for more information.

public const byte PrimaryI2cAddress = 19

Field Value

byte

SecondaryI2cAddress

Secondary I2C address for the Bmm150 In the official sheet (P36) states that address is 0x13, alhtough for m5stack is 0x10.

public const byte SecondaryI2cAddress = 16

Field Value

byte

Properties

CalibrationCompensation

Gets or sets Magnetometer calibration compensation vector.

public Vector3 CalibrationCompensation { get; set; }

Property Value

Vector3

DefaultTimeout

Gets or sets default timeout to use when timeout is not provided in the reading methods.

[Property]
public TimeSpan DefaultTimeout { get; set; }

Property Value

TimeSpan

HasDataToRead

True if there is a data to read.

public bool HasDataToRead { get; }

Property Value

bool

IsVersionCorrect

Check if the version is the correct one (0x32). This is fixed for this device.

public bool IsVersionCorrect { get; }

Property Value

bool

Returns true if the version match.

Methods

CalibrateMagnetometer(int)

Calibrate the magnetometer. Please make sure you are not close to any magnetic field like magnet or phone Please make sure you are moving the magnetometer all over space, rotating it. Visit https://platformio.org/lib/show/12697/M5_BMM150 for more information.

public void CalibrateMagnetometer(int numberOfMeasurements = 100)

Parameters

numberOfMeasurements int

Number of measurement for the calibration, default is 100.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetDeviceInfo()

Get the device information.

public byte GetDeviceInfo()

Returns

byte

The device information.

ReadMagnetometer(bool)

Read the magnetometer with bias correction and can wait for new data to be present.

[Telemetry("Magnetometer")]
public Vector3 ReadMagnetometer(bool waitForData = true)

Parameters

waitForData bool

true to wait for new data.

Returns

Vector3

The data from the magnetometer.

ReadMagnetometer(bool, TimeSpan)

Read the magnetometer with compensation calculation and can wait for new data to be present.

public Vector3 ReadMagnetometer(bool waitForData, TimeSpan timeout)

Parameters

waitForData bool

true to wait for new data.

timeout TimeSpan

Timeout for waiting the data, ignored if waitForData is false.

Returns

Vector3

The data from the magnetometer.

ReadMagnetometerWithoutCorrection(bool)

Read the magnetometer without Bias correction and can wait for new data to be present.

public Vector3 ReadMagnetometerWithoutCorrection(bool waitForData = true)

Parameters

waitForData bool

true to wait for new data.

Returns

Vector3

The data from the magnetometer.

ReadMagnetometerWithoutCorrection(bool, TimeSpan)

Read the magnetometer without Bias correction and can wait for new data to be present Visit https://github.com/BoschSensortec/BMM150-Sensor-API/blob/a20641f216057f0c54de115fe81b57368e119c01/bmm150.c#L921 for more information.

public Vector3 ReadMagnetometerWithoutCorrection(bool waitForData, TimeSpan timeout)

Parameters

waitForData bool

true to wait for new data.

timeout TimeSpan

Timeout for waiting the data, ignored if waitForData is false.

Returns

Vector3

The data from the magnetometer.