Skip to main content

Class Lis2mdl

Represents a LIS2MDL is a low-power, high-performance 3-axis magnetometer from STMicroelectronics with a fixed full range of ±50 gauss and a 16-bit resolution

Assembly: Lis2Mdl.dll
View Source
Declaration
public class Lis2mdl : PollingSensorBase<MagneticField3D>, IObservable<IChangeResult<MagneticField3D>>, IMagnetometer, ISamplingSensor<MagneticField3D>, ISensor<MagneticField3D>, ISensor, ISamplingSensor, II2cPeripheral

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.MagneticField3D>>, Meadow.Peripherals.Sensors.Motion.IMagnetometer, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.MagneticField3D>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.MagneticField3D>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, Meadow.Hardware.II2cPeripheral

Properties

MagneticField3D

Current Magnetic Field 3D

View Source
Declaration
public MagneticField3D? MagneticField3D { get; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

Fields

i2cComms

I2C Communication bus used to communicate with the peripheral

View Source
Declaration
protected readonly II2cCommunications i2cComms

Methods

ReadSensor()

Reads data from the sensor

View Source
Declaration
protected override Task<MagneticField3D> ReadSensor()
Returns

System.Threading.Tasks.Task<Meadow.Units.MagneticField3D>: The latest sensor reading### GetOutputDataRate() Gets the output data rate (ODR) of the magnetometer.

View Source
Declaration
public Lis2mdl.OutputDataRate GetOutputDataRate()
Returns

Meadow.Foundation.Sensors.Motion.Lis2mdl.OutputDataRate enum.### SetOutputDataRate(OutputDataRate) Sets the output data rate (ODR) of the magnetometer.

View Source
Declaration
public void SetOutputDataRate(Lis2mdl.OutputDataRate odr)
Parameters
TypeNameDescription
Meadow.Foundation.Sensors.Motion.Lis2mdl.OutputDataRate enum.

GetOperatingMode()

Gets the operating mode of the magnetometer.

View Source
Declaration
public Lis2mdl.OperatingMode GetOperatingMode()
Returns

Meadow.Foundation.Sensors.Motion.Lis2mdl.OperatingMode enum.### SetOperatingMode(OperatingMode) Sets the operating mode of the magnetometer.

View Source
Declaration
public void SetOperatingMode(Lis2mdl.OperatingMode mode)
Parameters
TypeNameDescription
Meadow.Foundation.Sensors.Motion.Lis2mdl.OperatingMode enum.

GetTemperatureCompensation()

Gets the status of the temperature compensation feature.

View Source
Declaration
public bool GetTemperatureCompensation()
Returns

System.Boolean: true if temperature compensation is enabled, false otherwise.### SetTemperatureCompensation(bool) Sets the status of the temperature compensation feature.

View Source
Declaration
public void SetTemperatureCompensation(bool enable)
Parameters
TypeNameDescription
System.Booleanenabletrue to enable temperature compensation, false to disable it.

GetFastRead()

Gets the status of the Fast Read feature.

View Source
Declaration
public bool GetFastRead()
Returns

System.Boolean: true if Fast Read is enabled, false otherwise.### SetFastRead(bool) Sets the status of the Fast Read feature.

View Source
Declaration
public void SetFastRead(bool enable)
Parameters
TypeNameDescription
System.Booleanenabletrue to enable Fast Read, false to disable it.

GetBlockDataUpdate()

Gets the status of the Block Data Update (BDU) feature.

View Source
Declaration
public bool GetBlockDataUpdate()
Returns

System.Boolean: true if BDU is enabled, false otherwise.### SetBlockDataUpdate(bool) Sets the status of the Block Data Update (BDU) feature.

View Source
Declaration
public void SetBlockDataUpdate(bool enable)
Parameters
TypeNameDescription
System.Booleanenabletrue to enable BDU, false to disable it.

Implements

  • System.IObservable<Meadow.IChangeResult<Meadow.Units.MagneticField3D>>
  • Meadow.Peripherals.Sensors.Motion.IMagnetometer
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.MagneticField3D>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.MagneticField3D>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • Meadow.Hardware.II2cPeripheral