Skip to content

Commit 78d7984

Browse files
pyhysjhedberg
authored andcommitted
boards: shields: Add Adafruit LIS3MDL magnetometer shield
Product photo from https://learn.adafruit.com/assets/86994 Tested with the command mentioned in the index.rst file. Compile testing of the overlay file is done via the mag_polling sample. Signed-off-by: Jonas Berg <[email protected]>
1 parent c49e3fe commit 78d7984

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SHIELD_ADAFRUIT_LIS3MDL
5+
def_bool $(shields_list_contains,adafruit_lis3mdl)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2025 Jonas Berg
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/ {
7+
aliases {
8+
magn0 = &adafruit_lis3mdl;
9+
};
10+
};
11+
12+
&zephyr_i2c {
13+
status = "okay";
14+
15+
adafruit_lis3mdl: lis3mdl@1c {
16+
compatible = "st,lis3mdl-magn";
17+
reg = <0x1c>;
18+
};
19+
};
35.3 KB
Loading
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. _adafruit_lis3mdl:
2+
3+
Adafruit LIS3MDL Shield
4+
#######################
5+
6+
Overview
7+
********
8+
9+
The `Adafruit LIS3MDL Triple-Axis Magnetometer Sensor Shield`_ features
10+
a `ST LIS3MDL 3-axis magnetometer`_ and two STEMMA QT connectors.
11+
12+
.. figure:: adafruit_lis3mdl.webp
13+
:align: center
14+
:alt: Adafruit LIS3MDL Shield
15+
16+
Adafruit LIS3MDL Shield (Credit: Adafruit)
17+
18+
19+
Requirements
20+
************
21+
22+
This shield can be used with boards which provide an I2C connector, for
23+
example STEMMA QT or Qwiic connectors.
24+
The target board must define a ``zephyr_i2c`` node label.
25+
See :ref:`shields` for more details.
26+
27+
28+
Pin Assignments
29+
===============
30+
31+
+--------------+------------------------------------------------------+
32+
| Shield Pin | Function |
33+
+==============+======================================================+
34+
| SDA | LIS3MDL I2C SDA |
35+
+--------------+------------------------------------------------------+
36+
| SCL | LIS3MDL I2C SCL |
37+
+--------------+------------------------------------------------------+
38+
| INT | LIS3MDL Interrupt out |
39+
+--------------+------------------------------------------------------+
40+
| DO/AD1 | LIS3MDL I2C address select pin |
41+
+--------------+------------------------------------------------------+
42+
| CS | LIS3MDL Force I2C mode by setting it to high level. |
43+
+--------------+------------------------------------------------------+
44+
| DRDY | LIS3MDL Data ready out |
45+
+--------------+------------------------------------------------------+
46+
47+
In order to use the DRDY output you need to connect a separate wire from the
48+
shield to a GPIO pin on your microcontroller board. See
49+
:dtcompatible:`st,lis3mdl-magn` for documentation on how to adjust the
50+
devicetree file.
51+
52+
53+
Programming
54+
***********
55+
56+
Set ``--shield adafruit_lis3mdl`` when you invoke ``west build``. For example
57+
when running the :zephyr:code-sample:`magn_polling` sample:
58+
59+
.. zephyr-app-commands::
60+
:zephyr-app: samples/sensor/magn_polling
61+
:board: adafruit_feather_rp2040
62+
:shield: adafruit_lis3mdl
63+
:goals: build flash
64+
65+
.. _Adafruit LIS3MDL Triple-Axis Magnetometer Sensor Shield:
66+
https://learn.adafruit.com/lis3mdl-triple-axis-magnetometer
67+
68+
.. _ST LIS3MDL 3-axis magnetometer:
69+
https://www.st.com/en/mems-and-sensors/lis3mdl.html
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright (c) 2025, Jonas Berg
4+
5+
shield:
6+
name: adafruit_lis3mdl
7+
full_name: Adafruit LIS3MDL Triple-Axis Magnetometer Sensor Shield
8+
vendor: adafruit
9+
supported_features:
10+
- sensor

samples/sensor/magn_polling/sample.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ tests:
1414
sample.sensor.magn_polling.shields:
1515
platform_allow:
1616
- adafruit_qt_py_rp2040/rp2040 # adafruit_lis2mdl shield
17+
- adafruit_feather_rp2040/rp2040 # adafruit_lis3mdl shield
1718
- mikroe_clicker_ra4m1/r7fa4m1ab3cfm # mikroe_3d_hall_3_click shield
1819
extra_args:
1920
- platform:adafruit_qt_py_rp2040/rp2040:SHIELD="adafruit_lis2mdl"
21+
- platform:adafruit_feather_rp2040/rp2040:SHIELD="adafruit_lis3mdl"
2022
- platform:mikroe_clicker_ra4m1/r7fa4m1ab3cfm:SHIELD="mikroe_3d_hall_3_click"

0 commit comments

Comments
 (0)