Skip to main content

Class Lis3mdl

Represents a Lis3mdl, a low-power, high-performance 3-axis magnetometer from STMicroelectronics with a selectable full range of ±4 to ±16 gauss and a 16-bit resolution

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

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT> -> Meadow.Foundation.SamplingSensorBase<UNIT> -> Meadow.Foundation.PollingSensorBase<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
public MagneticField3D? MagneticField3D { get; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
public byte DefaultI2cAddress { get; }

Fields

i2cComms

I2C Communication bus used to communicate with the peripheral

View Source
protected readonly II2cCommunications i2cComms

Methods

ReadSensor()

Reads data from the sensor

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

System.Threading.Tasks.Task<Meadow.Units.MagneticField3D>: The latest sensor reading### GetFullScale() Gets the full scale range of the magnetometer.

View Source
public Lis3mdl.FullScale GetFullScale()
Returns

Meadow.Foundation.Sensors.Motion.Lis3mdl.FullScale: The full scale range as a Meadow.Foundation.Sensors.Motion.Lis3mdl.FullScale enum.### SetFullScale(FullScale) Sets the full scale range of the magnetometer.

View Source
public void SetFullScale(Lis3mdl.FullScale scale)
Parameters
TypeNameDescription
Meadow.Foundation.Sensors.Motion.Lis3mdl.FullScalescaleThe desired full scale range as a Meadow.Foundation.Sensors.Motion.Lis3mdl.FullScale enum.

GetOutputDataRate()

Gets the output data rate (ODR) of the magnetometer.

View Source
public Lis3mdl.OutputDataRate GetOutputDataRate()
Returns

Meadow.Foundation.Sensors.Motion.Lis3mdl.OutputDataRate: The output data rate as a Meadow.Foundation.Sensors.Motion.Lis3mdl.OutputDataRate enum.### SetOutputDataRate(OutputDataRate) Sets the output data rate (ODR) of the magnetometer.

View Source
public void SetOutputDataRate(Lis3mdl.OutputDataRate odr)
Parameters
TypeNameDescription
Meadow.Foundation.Sensors.Motion.Lis3mdl.OutputDataRateodrThe desired output data rate as a Meadow.Foundation.Sensors.Motion.Lis3mdl.OutputDataRate enum.

GetOperatingMode()

Gets the operating mode of the magnetometer.

View Source
public Lis3mdl.OperatingMode GetOperatingMode()
Returns

Meadow.Foundation.Sensors.Motion.Lis3mdl.OperatingMode: The operating mode as a Meadow.Foundation.Sensors.Motion.Lis3mdl.OperatingMode enum.### SetOperatingMode(OperatingMode) Sets the operating mode of the magnetometer.

View Source
public void SetOperatingMode(Lis3mdl.OperatingMode mode)
Parameters
TypeNameDescription
Meadow.Foundation.Sensors.Motion.Lis3mdl.OperatingModemodeThe desired operating mode as a Meadow.Foundation.Sensors.Motion.Lis3mdl.OperatingMode enum.

GetFastRead()

Gets the status of the Fast Read feature.

View Source
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
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
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
public void SetBlockDataUpdate(bool enable)
Parameters
TypeNameDescription
System.Booleanenabletrue to enable BDU, false to disable it.

GetTemperatureSensorEnable()

Gets the status of the temperature sensor feature.

View Source
public bool GetTemperatureSensorEnable()
Returns

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

View Source
public void SetTemperatureSensorEnable(bool enable)
Parameters
TypeNameDescription
System.Booleanenabletrue to enable the temperature sensor, 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