Source: https://mokxi.com/parts/lis3mdl
Updated: 2026-11-19

Part

# Magnetometer, LIS3MDL

The Earth's field on three axes, up to 6842 counts a gauss, for a compass heading.

See every part

- 6 pins
- 4 settings
- In 1 project

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Magnetometer, LIS3MDL in brief

What it is, and every setting the properties panel gives it.

The LIS3MDL is ST’s three-axis magnetometer, read over I2C at 0x1C, up to 6842 counts a gauss: the sensor of a digital compass. Flat on the bench it reads the Earth’s field, about 20 microtesla toward magnetic north and 45 down at mid-northern latitudes, and atan2 of the two horizontal readings is the heading. VIN and GND take 3 V to 5 V on the board, SCL and SDA are I2C with the pull-ups on the board, DRDY is low while a new sample waits and INT is the threshold interrupt, left high-impedance by the model. The part’s pitch, roll and heading are sliders, and address is 28, which is 0x1C.

Family

Sensors

Pins

6

address

28

pitch

0

roll

0

heading

0

Pins

## 6 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

VIN

Supply, 3 to 5 V on the board.

GND

Ground.

SCL

I2C. The board carries the pull-ups.

SDA

I2C. The board carries the pull-ups.

DRDY

Low while a new sample waits.

INT

The threshold interrupt, left high-Z by the model.

How to use it

## How to read an LIS3MDL magnetometer with an Arduino

The magnetometer’s VIN goes to 5 V, GND to GND, SDA to A4 and SCL to A5, at address 0x1C. The project puts an LSM6DSOX accelerometer and gyroscope beside it on the same bus: the three sensors a drone or a head tracker needs, which way is down, how fast it turns and which way is north. Pitch comes from the accelerometer alone, and the gyroscope reads the turn rate only while the board is moving.

The heading comes from atan2 of the two horizontal field readings. Drag the heading slider on the LIS3MDL, and the pitch and heading sliders on the LSM6DSOX to see the gyro move. The sketch uses the Adafruit LSM6DSOX and LIS3MDL libraries.

Part pin

Board pin

VIN

5 V

GND

GND

SDA

A4

SCL

A5

DRDY, INT

Not wired

The board takes 3 V to 5 V, so a 3.3 V board such as an ESP32 or a Pico drives it directly. Use that board’s I2C pins; the address is 0x1C.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Common errors

## Common Magnetometer, LIS3MDL errors and fixes

What goes wrong

The fix

The heading is off by a fixed amount.

It is relative to magnetic north, not true north, and anything magnetic nearby bends it. Keep the sensor flat and away from motors and magnets.

The sensor is not found.

It answers at 0x1C. Check SDA and SCL against the table; the board carries the pull-ups.

The tilted heading is wrong.

The simple atan2 of the two horizontal readings holds only when the board is flat. Tilt needs the accelerometer’s pitch and roll.

Questions

## Questions and answers

### What is the I2C address of the LIS3MDL?

0x1C.

### How do I get a compass heading from a magnetometer?

Take atan2 of the two horizontal readings while the board is flat. Flat on the bench it reads about 20 microtesla toward magnetic north.

### How sensitive is the LIS3MDL?

Up to 6842 counts a gauss.

How it is modeled

## What is true about the Magnetometer, LIS3MDL, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Not modeled

The interrupt threshold, the self-test, offsets, noise, and nearby magnets.

From LIS3MDL magnetometer, in full.

Projects

## See the Magnetometer, LIS3MDL in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

## The boards it is shown on

This board has a built-in project with the Magnetometer, LIS3MDL in it.

- Arduino Uno R3

Keep going

## Keep going

- I2C Scanner for Arduino and ESP32, and Fixes
- Arduino MPU6050: Accelerometer and Tilt
- Accelerometer and gyroscope, MPU6050
- Nine-axis IMU, MPU-9250
- Accelerometer, ADXL345

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Magnetometer, LIS3MDL

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
