Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions lib/lis2mdl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ It provides low-level register access, automatic calibration, heading computatio

---

## 🧭 Features

* Full **I²C driver** for LIS2MDL
* Supports **10 / 20 / 50 / 100 Hz** output data rates
* **Temperature-compensated** and **low-power** modes
* Read **raw**, **scaled**, or **calibrated** magnetic field data
* **2D and 3D calibration** routines (auto min/max method)
* **Heading computation** (flat or tilt-compensated)
* **Compass direction labels** (N, NE, E, …)
* Built-in **digital low-pass filter** and **offset cancellation** control
* Diagnostic utilities:
## Features

* Full **I²C driver** for LIS2MDL
* Supports **10 / 20 / 50 / 100 Hz** output data rates
* **Temperature-compensated** and **low-power** modes
* Read **raw**, **scaled**, or **calibrated** magnetic field data
* **2D and 3D calibration** routines (auto min/max method)
* **Heading computation** (flat or tilt-compensated)
* **Compass direction labels** (N, NE, E, …)
* Built-in **digital low-pass filter** and **offset cancellation** control
* Diagnostic utilities:

* Register dump
* Calibration quality metrics
* Self-test and temperature readout

---

## ⚙️ Hardware Requirements
## Hardware Requirements

* **LIS2MDL** 3-axis magnetometer (STMicroelectronics)
* **MicroPython/CircuitPython board**, e.g.:
Expand All @@ -37,7 +37,7 @@ It provides low-level register access, automatic calibration, heading computatio

---

## 🔌 Wiring Example (ESP32)
## Wiring Example (ESP32)

| LIS2MDL Pin | ESP32 Pin | Description |
| ----------- | --------- | ------------ |
Expand All @@ -58,7 +58,7 @@ mag = LIS2MDL(i2c)

---

## 🚀 Quick Start
## Quick Start

### Read magnetic field

Expand Down Expand Up @@ -87,7 +87,7 @@ heading = mag.heading_with_tilt_compensation(read_accel)

---

## ⚖️ Calibration
## Calibration

Calibration is essential to obtain accurate compass readings.
The driver provides **automated routines** for both 2D (flat) and 3D calibration.
Expand Down Expand Up @@ -124,7 +124,7 @@ mag.calibrate_reset()

---

## 🧰 Configuration Examples
## Configuration Examples

### Output rate and power

Expand Down Expand Up @@ -154,7 +154,7 @@ mag.set_bdu(True)

---

## 🧮 Heading Filtering
## Heading Filtering

You can apply a **smoothing filter** on the heading angle to stabilize the readings:

Expand All @@ -168,7 +168,7 @@ mag.set_heading_filter(alpha=0.2) # Light smoothing

---

## 🔍 Diagnostics & Debug
## Diagnostics & Debug

### Read sensor ID

Expand Down Expand Up @@ -200,7 +200,7 @@ print("Register dump:", regs)

---

## 🧠 Internal Methods Overview
## Internal Methods Overview

| Method | Description |
| ---------------------------------- | ------------------------------ |
Expand All @@ -215,7 +215,7 @@ print("Register dump:", regs)

---

## 🧪 Example: Continuous Compass Loop
## Example: Continuous Compass Loop

```python
from machine import I2C, Pin
Expand All @@ -234,9 +234,9 @@ while True:

---

## 📚 References
## References

* [STMicroelectronics LIS2MDL Datasheet](https://www.st.com/resource/en/datasheet/lis2mdl.pdf)
* [MicroPython Documentation](https://docs.micropython.org/en/latest/library/machine.I2C.html)

---
---
Loading