nanoFramework.Iot.Device.Hmc5883l 1.0.288-preview.1

Prefix Reserved
This is a prerelease version of nanoFramework.Iot.Device.Hmc5883l.
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Hmc5883l --version 1.0.288-preview.1
                    
NuGet\Install-Package nanoFramework.Iot.Device.Hmc5883l -Version 1.0.288-preview.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.Hmc5883l" Version="1.0.288-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Hmc5883l" Version="1.0.288-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Hmc5883l" />
                    
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.Hmc5883l --version 1.0.288-preview.1
                    
#r "nuget: nanoFramework.Iot.Device.Hmc5883l, 1.0.288-preview.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.Hmc5883l@1.0.288-preview.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.Hmc5883l&version=1.0.288-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Hmc5883l&version=1.0.288-preview.1&prerelease
                    
Install as a Cake Tool

HMC5883L - 3 Axis Digital Compass

HMC5883L is a surface-mount, multi-chip module designed for low-field magnetic sensing with a digital interface for applications such as lowcost compassing and magnetometry.

Documentation

sensor

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.

I2cConnectionSettings settings = new I2cConnectionSettings(1, Hmc5883l.DefaultI2cAddress);
I2cDevice device = I2cDevice.Create(settings);

using (Hmc5883l sensor = new Hmc5883l(device))
{
    // read direction vector
    Vector3 directionVector = sensor.DirectionVector;
    // read heading
    double heading = sensor.Heading;
    // read status
    Status status = sensor.DeviceStatus;
}

From the HMC5883L sample, you can go further with the following:

I2cConnectionSettings settings = new I2cConnectionSettings(1, Hmc5883l.DefaultI2cAddress);
I2cDevice device = I2cDevice.Create(settings);

using (Hmc5883l sensor = new Hmc5883l(device))
{
    while (true)
    {
        // read heading
        Debug.WriteLine($"Heading: {sensor.Heading.ToString("0.00")} °");
        Debug.WriteLine();

        // wait for a second
        Thread.Sleep(1000);
    }
}

Hardware Required

  • HMC5883L
  • Male/Female Jumper Wires

Circuit

circuit

  • SCL - SCL
  • SDA - SDA
  • VCC - 5V
  • GND - GND

Result

running result

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.2.931 208 11/10/2025
1.2.907 180 10/2/2025
1.2.869 245 4/2/2025
1.2.864 220 4/2/2025
1.2.852 237 3/11/2025
1.2.822 180 2/26/2025
1.2.775 198 2/4/2025
1.2.772 168 2/4/2025
1.2.755 189 1/31/2025
1.2.737 171 1/13/2025
1.2.704 192 12/18/2024
1.2.696 180 12/16/2024
1.2.673 190 10/23/2024
1.2.631 192 8/28/2024
1.2.590 187 7/17/2024
1.2.570 185 6/14/2024
1.2.436 315 11/10/2023
1.2.416 148 11/8/2023
1.2.329 287 5/26/2023
1.2.313 259 5/12/2023
1.2.297 252 5/3/2023
1.2.253 361 2/22/2023
1.2.222 395 1/9/2023
1.2.217 439 1/6/2023
1.2.212 412 1/5/2023
1.2.208 432 1/3/2023
1.2.203 429 12/28/2022
1.2.159 479 11/14/2022
1.2.153 466 11/5/2022
1.2.141 502 10/25/2022
1.2.128 483 10/22/2022
1.2.87 616 9/15/2022
1.2.82 619 9/14/2022
1.1.116.8772 593 6/24/2022
1.1.113.2032 568 6/23/2022
1.1.97.17326 573 6/13/2022
1.1.92.53000 547 6/8/2022
1.1.58.10097 568 5/23/2022
1.1.3 633 4/15/2022
1.1.1 586 4/14/2022
1.0.300 584 3/31/2022
1.0.288-preview.114 227 3/25/2022
1.0.288-preview.113 216 3/25/2022
1.0.288-preview.106 222 3/23/2022
1.0.288-preview.104 220 3/22/2022
1.0.288-preview.100 224 3/19/2022
1.0.288-preview.98 224 3/18/2022
1.0.288-preview.95 225 3/15/2022
1.0.288-preview.93 222 3/15/2022
1.0.288-preview.87 220 3/10/2022
1.0.288-preview.65 228 2/18/2022
1.0.288-preview.48 242 2/4/2022
1.0.288-preview.41 244 1/31/2022
1.0.288-preview.29 244 1/28/2022
1.0.288-preview.20 241 1/27/2022
1.0.288-preview.1 244 1/21/2022
1.0.259 456 12/9/2021
1.0.155 436 8/31/2021
1.0.130 283 7/6/2021
1.0.129 275 7/6/2021
1.0.125 306 7/5/2021
1.0.121 312 6/29/2021
1.0.119 350 6/28/2021
1.0.32 283 5/24/2021