Skip to content

LIS3MDL

Frederic Pillon edited this page May 28, 2024 · 2 revisions

LIS3MDL

Arduino library to support the LIS3MDL high-performance 3-axis magnetometer.

API

  • LIS3MDLSensor(TwoWire*, uint8_t): class constructor
    Params pointer to the I2C instance
    Params (optional) address of the component's instance

  • Enable: enable sensor
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • Disable: disable sensor
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • ReadID(uint8_t*): read ID address
    Params pointer where store the ID of the device
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • GetAxes(int32_t*): read magnetometer data
    Params pointer where to store data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • GetSensitivity(float*): read magnetometer sensitivity
    Params pointer where to store data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • GetAxesRaw(int16_t*): read magnetometer raw data
    Params pointer where to store data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • GetODR(float*): get the output data rate mode
    Params pointer where to store data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • SetODR(float): set the output data rate mode
    Params data rate to be set
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • GetFS(float*): get the magnetometer full scale
    Params pointer where to store data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • SetFS(float): set the magnetometer full scale
    Params full scale to be set
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • ReadReg(uint8_t, uint8_t*): read data from register
    Params register address
    Params pointer to register data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

  • WriteReg(uint8_t, uint8_t): write data to register
    Params register address
    Params register data
    Returns LIS3MDL_STATUS_OK in case of success, an error code otherwise

Note

This library uses the Wire library presents in the STM32 core by default.

Examples

  • DISCO_IOT_LIS3MDL_DataLog_Terminal: reads magnetometer axes values and prints them.

Source

You can find the source files at
https://github.com/stm32duino/LIS3MDL

Documentation

The LIS3MDL datasheet is available at
http://www.st.com/content/st_com/en/products/mems-and-sensors/e-compasses/lis3mdl.html

Clone this wiki locally