Skip to content

TeamSunride/Arduino-LIS3MDL

Folders and files

NameName
Last commit message
Last commit date
Mar 7, 2023
Mar 11, 2023
Mar 11, 2023
Dec 19, 2022
Sep 21, 2022
Sep 22, 2022
Mar 7, 2023
Mar 10, 2023
Dec 19, 2022
Sep 21, 2022
Mar 11, 2023

Repository files navigation

Arduino-LIS3MDL

An Arduino / platformIO library for the LIS3MDL 3-axis magnetometer.

img.png

image credit: Adafruit

Developed by Sam Scott

Namespace

The class and it's registers are scoped within the LIS3MDL namespace.

E.g LIS3MDL::REGISTER::STATUS_REG, LIS3MDL::OUTPUT_DATA_RATES::ODR_1000_HZ

Usage

  • SPI constructor (recommended)
#define LIS_CS 37
LIS3MDL::LIS3MDL LIS(LIS_CS, SPI, 4000000);
  • I2C constructor
LIS3MDL::LIS3MDL LIS(&Wire, 1000000);

Wiring guide:

Loading
graph TD;
    mcu[MCU] -- SCK  ---LIS3MDL[LIS3MDL];
    mcu-- MOSI  ---LIS3MDL[LIS3MDL]
    mcu-- MISO  ---LIS3MDL[LIS3MDL]
    mcu-- CS  ---LIS3MDL[LIS3MDL] 
    
    mcu2[MCU] -- SCL  ---LIS3MDL_2[LIS3MDL];
    mcu2 -- SDA  ---LIS3MDL_2[LIS3MDL]

It is recommended to call LIS.default_configuration() in your setup function. Individual settings can then be changed as required. E.g.

LIS.set_mag_ODR(LIS3MDL::OUTPUT_DATA_RATES::ODR_1000_HZ);

Interrupts Graphic

img.png