nanoFramework.Iot.Device.Lis3Mdl 1.0.1

Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Lis3Mdl --version 1.0.1
                    
NuGet\Install-Package nanoFramework.Iot.Device.Lis3Mdl -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Lis3Mdl" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Lis3Mdl" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Lis3Mdl" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Lis3Mdl --version 1.0.1
                    
#r "nuget: nanoFramework.Iot.Device.Lis3Mdl, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Lis3Mdl@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Lis3Mdl&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Lis3Mdl&version=1.0.1
                    
Install as a Cake Tool

LIS3MDL - three-axis digital magnetometer

The LIS3MDL is a low-power, high-performance magnetic sensor with selectable full-scale ranges from plus or minus 4 gauss to plus or minus 16 gauss. It is included on boards such as the ST B-L475E-IOT01A Discovery kit.

Documentation

Usage

The on-board LIS3MDL on the B-L475E-IOT01A uses address 0x1E, exposed as SecondaryI2cAddress. It is connected to the board's sensor I2C bus. The sample uses bus 2; adjust the bus number if your firmware maps that peripheral differently.

External LIS3MDL modules commonly use address 0x1C, exposed as DefaultI2cAddress. For ESP32 targets, configure the selected I2C pins before creating the device.

using Iot.Device.Lis3Mdl;
using System.Device.I2c;
using System.Diagnostics;
using System.Threading;

I2cConnectionSettings settings = new(2, Lis3Mdl.SecondaryI2cAddress);
using Lis3Mdl sensor = new(I2cDevice.Create(settings));

sensor.MagneticInductionScale = MagneticInductionScale.Scale04G;
sensor.DataRate = DataRate.Rate10Hz;

while (true)
{
    var field = sensor.MagneticField;
    Debug.WriteLine($"X: {field.X:F2} mG, Y: {field.Y:F2} mG, Z: {field.Z:F2} mG");
    Debug.WriteLine($"Temperature: {sensor.Temperature.DegreesCelsius:F1} C");
    Thread.Sleep(1000);
}

MagneticField returns a Vector3 whose components are measured in milligauss. MagneticFieldX, MagneticFieldY, and MagneticFieldZ return UnitsNet values. The driver also exposes continuous, single-shot, and power-down operation modes, four performance modes, and output rates from 0.625 Hz to 1000 Hz.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 104 9/25/2026