Contenuto principale

LIS3MDL Magnetometer Sensor

Measure magnetic field strength and temperature from LIS3MDL Magnetometer sensor

Since R2025a

  • block icon for LIS3MDL Magnetometer sensor

Libraries:
STM32 Microcontroller Blockset / (Legacy) STM32 MBED Based Boards / MBED Based Sensors
STM32 Microcontroller Blockset / (Legacy) STM32 MBED Based Boards / STM32L475VG-Discovery (B-L475E-IOT01A)

Description

The LIS3MDL Magnetometer Sensor block outputs the values of magnetic field strength along x-, y- and z- axes as measured by the LIS3MDL Magnetometer sensor connected to STM32 processor. The block also outputs the temperature as read by the LIS3MDL Magnetometer sensor.

Ports

Output

expand all

Magnetic field strength (in µT) measured by LIS3MDL sensor connected toSTM32 Processor, along the x-, y- and z- axes, specified as a row vector [x,y,z].

Dependencies

This output port appears only if you select Magnetic Field (µT) parameter.

Data Types: double

Temperature (in ℃) measured by LIS3MDL sensor connected to STM32 Processor.

Dependencies

This output port appears only if you select the Temperature (℃) parameter.

Data Types: double

Status of magnetic and temperature measurements, specified as a 1-by-2 vector. 0 indicates that the data read is new, 1 indicates that the data read is not new, and -1 indicates that the corresponding output is not selected.

Dependencies

This output port appears only if you select the Status parameter.

Data Types: int8

Parameters

expand all

Main Tab

Specify the I2C module on the board. The I2C bus frequency, serial clock (SCL) pin and serial data (SDA) pin are taken according to the corresponding I2C module entry in the configuration parameters.

Programmatic Use

Block Parameter: I2CModule

Select this parameter to set Magnetic Field as one of the output ports.

Programmatic Use

Block Parameter: IsActiveMagnetometer

Select this parameter to set Temperature as one of the output ports.

Programmatic Use

Block Parameter: IsActiveTemperature

Select this parameter to set Magnetic Field Status as one of the output ports.

Programmatic Use

Block Parameter: IsStatus

Specify how often this block reads the data from the LIS3MDL sensor. When you set this parameter to -1, Simulink determines the best sample time for the block based on the block context within the model.

Programmatic Use

Block Parameter: SampleTime

Advanced Tab

Select the full scale for measuring linear acceleration (the range of acceleration that the sensor needs to measure).

Programmatic Use

Block Parameter: MagnetometerRange

Select the output data rate at which magnetometer data is sampled.

Programmatic Use

Block Parameter: MagnetometerODR

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2025a