Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Adafruit LIS2MDL: Examples, Pinouts, and Specs

Image of Adafruit LIS2MDL
Cirkit Designer LogoDesign with Adafruit LIS2MDL in Cirkit Designer

Introduction

The Adafruit LIS2MDL (Part ID: 4488) is a high-performance 3-axis magnetometer sensor designed to measure magnetic fields with precision. It is ideal for applications such as navigation, orientation detection, augmented reality, and electronic compasses. The sensor communicates via the I2C interface, making it easy to integrate with microcontrollers and development boards like the Arduino UNO. Its low power consumption makes it particularly suitable for portable and battery-operated devices.

Explore Projects Built with Adafruit LIS2MDL

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Teensy 4.1 Based Biometric Data Acquisition System with AD8232 Heart Rate Monitor and LIS3DH Accelerometer
Image of Teensy 4.1 accelerometer: A project utilizing Adafruit LIS2MDL in a practical application
This circuit integrates a Teensy 4.1 microcontroller with an Adafruit LIS3DH Triple-Axis Accelerometer and an AD8232 Heart Rate Monitor. The accelerometer communicates with the Teensy via I2C (SCL and SDA lines), while the heart rate monitor's output and lead-off detection (LO+ and LO-) are connected to the Teensy's analog inputs. The circuit is designed to measure both acceleration and heart rate signals, likely for a wearable or health monitoring device.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Mega 2560-Based Multi-Sensor System with Distance, Magnetometer, and Camera Integration
Image of Junior Design - Sensors: A project utilizing Adafruit LIS2MDL in a practical application
This circuit features an Arduino Mega 2560 microcontroller interfaced with multiple VL53L0X distance sensors, an OV7725 camera module, and an Adafruit LIS3MDL triple-axis magnetometer. The Arduino reads data from these sensors and the camera, likely for a robotics or environmental sensing application, and processes the data for further use or transmission.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Ethernet with LSM303DLHC Accelerometer and Compass Interface
Image of Compass: A project utilizing Adafruit LIS2MDL in a practical application
This circuit connects an Adafruit LSM303DLHC Triple-axis Accelerometer+Magnetometer (Compass) to an Arduino Board Ethernet using I2C communication protocol. The SCL and SDA pins of the sensor are connected to the A5 and A4 pins of the Arduino, respectively, for serial clock and data transfer. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO R4 WiFi and Adafruit LIS3DH Accelerometer-Based Motion Detection System
Image of circuit: A project utilizing Adafruit LIS2MDL in a practical application
This circuit consists of an Arduino UNO R4 WiFi connected to an Adafruit LIS3DH Triple-Axis Accelerometer via I2C communication. The Arduino reads acceleration data from the LIS3DH sensor and outputs it to the serial monitor for further analysis or processing.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Adafruit LIS2MDL

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Teensy 4.1 accelerometer: A project utilizing Adafruit LIS2MDL in a practical application
Teensy 4.1 Based Biometric Data Acquisition System with AD8232 Heart Rate Monitor and LIS3DH Accelerometer
This circuit integrates a Teensy 4.1 microcontroller with an Adafruit LIS3DH Triple-Axis Accelerometer and an AD8232 Heart Rate Monitor. The accelerometer communicates with the Teensy via I2C (SCL and SDA lines), while the heart rate monitor's output and lead-off detection (LO+ and LO-) are connected to the Teensy's analog inputs. The circuit is designed to measure both acceleration and heart rate signals, likely for a wearable or health monitoring device.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Junior Design - Sensors: A project utilizing Adafruit LIS2MDL in a practical application
Arduino Mega 2560-Based Multi-Sensor System with Distance, Magnetometer, and Camera Integration
This circuit features an Arduino Mega 2560 microcontroller interfaced with multiple VL53L0X distance sensors, an OV7725 camera module, and an Adafruit LIS3MDL triple-axis magnetometer. The Arduino reads data from these sensors and the camera, likely for a robotics or environmental sensing application, and processes the data for further use or transmission.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Compass: A project utilizing Adafruit LIS2MDL in a practical application
Arduino Ethernet with LSM303DLHC Accelerometer and Compass Interface
This circuit connects an Adafruit LSM303DLHC Triple-axis Accelerometer+Magnetometer (Compass) to an Arduino Board Ethernet using I2C communication protocol. The SCL and SDA pins of the sensor are connected to the A5 and A4 pins of the Arduino, respectively, for serial clock and data transfer. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of circuit: A project utilizing Adafruit LIS2MDL in a practical application
Arduino UNO R4 WiFi and Adafruit LIS3DH Accelerometer-Based Motion Detection System
This circuit consists of an Arduino UNO R4 WiFi connected to an Adafruit LIS3DH Triple-Axis Accelerometer via I2C communication. The Arduino reads acceleration data from the LIS3DH sensor and outputs it to the serial monitor for further analysis or processing.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

The following table outlines the key technical specifications of the Adafruit LIS2MDL:

Parameter Value
Operating Voltage 3.3V or 5V (logic level compatible)
Communication Interface I2C
I2C Address 0x1E (default)
Magnetic Field Range ±50 gauss
Output Data Rate (ODR) 10 Hz to 100 Hz
Power Consumption 260 µA (typical)
Operating Temperature -40°C to +85°C
Dimensions 20mm x 18mm x 2mm

Pin Configuration and Descriptions

The Adafruit LIS2MDL breakout board has the following pinout:

Pin Name Description
VIN Power input (3.3V or 5V). Provides power to the sensor.
GND Ground. Connect to the ground of your circuit.
SCL I2C clock line. Connect to the SCL pin of your microcontroller.
SDA I2C data line. Connect to the SDA pin of your microcontroller.
DRDY Data Ready pin (optional). Indicates when new data is available.
INT Interrupt pin (optional). Can be configured for specific interrupt events.

Usage Instructions

Connecting the Adafruit LIS2MDL to an Arduino UNO

To use the Adafruit LIS2MDL with an Arduino UNO, follow these steps:

  1. Wiring:

    • Connect the VIN pin of the LIS2MDL to the 5V pin on the Arduino UNO.
    • Connect the GND pin of the LIS2MDL to the GND pin on the Arduino UNO.
    • Connect the SCL pin of the LIS2MDL to the A5 pin on the Arduino UNO (I2C clock line).
    • Connect the SDA pin of the LIS2MDL to the A4 pin on the Arduino UNO (I2C data line).
  2. Install the Adafruit LIS2MDL Library:

    • Open the Arduino IDE.
    • Go to Sketch > Include Library > Manage Libraries.
    • Search for "Adafruit LIS2MDL" and install the library.
  3. Upload Example Code: Use the following example code to read magnetic field data from the LIS2MDL:

    #include <Wire.h>
    #include <Adafruit_LIS2MDL.h>
    
    // Create an instance of the LIS2MDL sensor
    Adafruit_LIS2MDL lis2mdl;
    
    void setup() {
      Serial.begin(115200);
      while (!Serial) {
        delay(10); // Wait for Serial Monitor to open
      }
    
      // Initialize the LIS2MDL sensor
      if (!lis2mdl.begin_I2C()) {
        Serial.println("Failed to find LIS2MDL chip!");
        while (1) {
          delay(10); // Halt if sensor initialization fails
        }
      }
      Serial.println("LIS2MDL initialized successfully!");
    
      // Set the output data rate (ODR) to 100 Hz
      lis2mdl.setDataRate(LIS2MDL_DATARATE_100_HZ);
    }
    
    void loop() {
      // Read magnetic field data
      sensors_event_t event;
      lis2mdl.getEvent(&event);
    
      // Print magnetic field values in microteslas (µT)
      Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print(" µT, ");
      Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" µT, ");
      Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.println(" µT");
    
      delay(100); // Delay for readability
    }
    

Important Considerations and Best Practices

  • Power Supply: Ensure the sensor is powered with a stable 3.3V or 5V supply.
  • I2C Pull-Up Resistors: The breakout board includes pull-up resistors on the I2C lines. If you experience communication issues, ensure there are no conflicting pull-ups in your circuit.
  • Magnetic Interference: Avoid placing the sensor near strong magnetic fields or ferromagnetic materials, as they can affect accuracy.
  • Data Ready Pin: Use the DRDY pin for precise timing when reading data, especially in high-speed applications.

Troubleshooting and FAQs

Common Issues

  1. Sensor Not Detected:

    • Cause: Incorrect wiring or I2C address mismatch.
    • Solution: Double-check the wiring and ensure the I2C address is set to 0x1E in your code.
  2. Inaccurate Readings:

    • Cause: Magnetic interference or improper calibration.
    • Solution: Calibrate the sensor by rotating it in all directions to account for hard and soft iron distortions.
  3. No Data Output:

    • Cause: Incorrect library installation or initialization failure.
    • Solution: Verify that the Adafruit LIS2MDL library is installed and that the begin_I2C() function returns true.

FAQs

Q: Can the LIS2MDL be used with 3.3V logic microcontrollers?
A: Yes, the breakout board is compatible with both 3.3V and 5V logic levels.

Q: How do I change the I2C address of the LIS2MDL?
A: The LIS2MDL has a fixed I2C address of 0x1E and does not support address modification.

Q: What is the maximum distance between the LIS2MDL and the microcontroller?
A: The maximum distance depends on the I2C bus speed and pull-up resistor values. For standard I2C speeds (100 kHz), a distance of up to 1 meter is typically reliable.

By following this documentation, you can effectively integrate and utilize the Adafruit LIS2MDL in your projects.