nanoFramework.Iot.Device.Lis2Mdl 1.0.374

Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Lis2Mdl --version 1.0.374
                    
NuGet\Install-Package nanoFramework.Iot.Device.Lis2Mdl -Version 1.0.374
                    
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.Lis2Mdl" Version="1.0.374" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Lis2Mdl" Version="1.0.374" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Lis2Mdl" />
                    
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.Lis2Mdl --version 1.0.374
                    
#r "nuget: nanoFramework.Iot.Device.Lis2Mdl, 1.0.374"
                    
#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.Lis2Mdl@1.0.374
                    
#: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.Lis2Mdl&version=1.0.374
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Lis2Mdl&version=1.0.374
                    
Install as a Cake Tool

LIS2MDL - Ultra-low-power, high-performance 3-axis digital magnetic sensor

Some of the applications mentioned by the datasheet:

  • Tilt-compensated compasses
  • Map rotation
  • Intelligent power saving for handheld devices
  • Gaming and virtual reality input devices

Documentation

Usage

Important: make sure you properly setup the I2C pins especially for ESP32 before creating the I2cDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

For other devices like STM32, please make sure you're using the preset pins for the I2C bus you want to use.

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

using Lis2Mdl lis2mdlDevice = new(CreateI2cDevice());

while (true)
{
    var tempValue = lis2mdlDevice.Temperature;
    var magFieldValue = lis2mdlDevice.MagneticField;

    Debug.WriteLine($"Temperature: {tempValue.DegreesCelsius:F1}\u00B0C");
    Debug.WriteLine($"Mag. field X: {magFieldValue[0].Milligausses:F3}mG");
    Debug.WriteLine($"Mag. field Y: {magFieldValue[1].Milligausses:F3}mG");
    Debug.WriteLine($"Mag. field Z: {magFieldValue[2].Milligausses:F3}mG");

    Thread.Sleep(1000);
}

I2cDevice CreateI2cDevice()
{
    I2cConnectionSettings settings = new(1, Lis2Mdl.DefaultI2cAddress);
    return I2cDevice.Create(settings);
}

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.374 177 4/2/2025
1.0.369 165 4/2/2025
1.0.357 177 3/11/2025
1.0.351 177 3/10/2025
1.0.327 120 2/26/2025
1.0.280 119 2/4/2025
1.0.277 117 2/4/2025
1.0.260 109 1/31/2025
1.0.248 117 1/20/2025
1.0.242 91 1/13/2025
1.0.223 113 12/30/2024
1.0.209 121 12/18/2024
1.0.201 107 12/16/2024
1.0.178 123 10/23/2024
1.0.161 131 10/3/2024
1.0.144 125 9/6/2024
1.0.136 126 8/28/2024
1.0.118 138 8/9/2024
1.0.106 120 7/26/2024
1.0.95 136 7/17/2024
1.0.78 134 6/19/2024
1.0.75 135 6/14/2024
1.0.41 147 4/15/2024
1.0.19 148 3/22/2024
1.0.7 143 3/1/2024
1.0.4 148 3/1/2024
1.0.1 145 2/29/2024