nanoFramework.Iot.Device.Lis2Mdl 1.0.178

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Lis2Mdl --version 1.0.178                
NuGet\Install-Package nanoFramework.Iot.Device.Lis2Mdl -Version 1.0.178                
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.178" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.Iot.Device.Lis2Mdl --version 1.0.178                
#r "nuget: nanoFramework.Iot.Device.Lis2Mdl, 1.0.178"                
#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.
// Install nanoFramework.Iot.Device.Lis2Mdl as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Lis2Mdl&version=1.0.178

// Install nanoFramework.Iot.Device.Lis2Mdl as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Lis2Mdl&version=1.0.178                

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.327 59 6 days ago
1.0.280 95 a month ago
1.0.277 87 a month ago
1.0.260 87 a month ago
1.0.248 96 a month ago
1.0.242 67 2 months ago
1.0.223 95 2 months ago
1.0.209 100 2 months ago
1.0.201 86 3 months ago
1.0.178 103 4 months ago
1.0.161 111 5 months ago
1.0.144 110 6 months ago
1.0.136 111 6 months ago
1.0.118 120 7 months ago
1.0.106 100 7 months ago
1.0.95 121 8 months ago
1.0.78 115 8 months ago
1.0.75 120 9 months ago
1.0.41 129 4/15/2024
1.0.19 130 3/22/2024
1.0.7 124 3/1/2024
1.0.4 134 3/1/2024
1.0.1 129 2/29/2024