nanoFramework.Iot.Device.Adxl345 1.2.869

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

ADXL345 - Accelerometer

ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16g.

Documentation

In Chinese

In English

Sensor Image

sensor

Usage

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

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the SPI GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(22, DeviceFunction.SPI1_MISO);
Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK);
// Make sure as well you are using the right chip select

For other devices like STM32, please make sure you're using the preset pins for the SPI bus you want to use. The chip select can as well be pre setup.

SpiConnectionSettings settings = new SpiConnectionSettings(1, 42)
{
    ClockFrequency = Adxl345.SpiClockFrequency,
    Mode = Adxl345.SpiMode
};

var device = SpiDevice.Create(settings);

// set gravity measurement range ±4G
using (Adxl345 sensor = new Adxl345(device, GravityRange.Range04))
{
    // read acceleration
    Vector3 data = sensor.Acceleration;

    //use sensor
}

Example

Hardware Required

  • ADXL345
  • Male/Female Jumper Wires

Circuit

cicuit

  • VCC - 3.3 V
  • GND - GND
  • CS - CS
  • SDO - SPI1 MISO
  • SDA - SPI1 MOSI
  • SCL - SPI1 SCLK

Code

SpiConnectionSettings settings = new SpiConnectionSettings(1, 42)
{
    ClockFrequency = Adxl345.SpiClockFrequency,
    Mode = Adxl345.SpiMode
};
var device = SpiDevice.Create(settings);

// Set gravity measurement range ±4G
using (Adxl345 sensor = new Adxl345(device, GravityRange.Range04))
{
    // loop
    while (true)
    {
        // read data
        Vector3 data = sensor.Acceleration;

        Debug.WriteLine($"X: {data.X.ToString("0.00")} g");
        Debug.WriteLine($"Y: {data.Y.ToString("0.00")} g");
        Debug.WriteLine($"Z: {data.Z.ToString("0.00")} g");
        Debug.WriteLine();

        // wait for 500ms
        Thread.Sleep(500);
    }
}

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.869 228 4/2/2025
1.2.864 196 4/2/2025
1.2.852 220 3/11/2025
1.2.822 155 2/26/2025
1.2.776 169 2/4/2025
1.2.775 148 2/4/2025
1.2.772 146 2/4/2025
1.2.759 147 1/31/2025
1.2.755 152 1/31/2025
1.2.737 154 1/13/2025
1.2.704 163 12/18/2024
1.2.696 162 12/16/2024
1.2.673 153 10/23/2024
1.2.631 159 8/28/2024
1.2.590 146 7/17/2024
1.2.570 152 6/14/2024
1.2.560 162 5/29/2024
1.2.548 148 5/15/2024
1.2.436 308 11/10/2023
1.2.416 171 11/8/2023
1.2.329 289 5/26/2023
1.2.313 253 5/12/2023
1.2.297 265 5/3/2023
1.2.253 359 2/22/2023
1.2.222 378 1/9/2023
1.2.217 415 1/6/2023
1.2.212 428 1/5/2023
1.2.208 425 1/3/2023
1.2.203 413 12/28/2022
1.2.159 482 11/14/2022
1.2.153 486 11/5/2022
1.2.141 519 10/25/2022
1.2.128 531 10/22/2022
1.2.122 557 10/12/2022
1.2.114 487 10/8/2022
1.2.95 559 9/22/2022
1.2.87 610 9/15/2022
1.2.73 550 9/8/2022
1.2.5 593 7/13/2022
1.1.141.41205 551 7/6/2022
1.1.116.8772 547 6/24/2022
1.1.113.2032 553 6/23/2022
1.1.97.17326 596 6/13/2022
1.1.92.53000 572 6/8/2022
1.1.58.10097 573 5/23/2022
1.1.27 554 4/26/2022
1.1.20 574 4/21/2022
1.1.3 592 4/15/2022
1.1.1 571 4/14/2022
1.0.300 588 3/31/2022
1.0.288-preview.114 221 3/25/2022
1.0.288-preview.113 209 3/25/2022
1.0.288-preview.106 199 3/23/2022
1.0.288-preview.104 201 3/22/2022
1.0.288-preview.100 201 3/19/2022
1.0.288-preview.99 213 3/18/2022
1.0.288-preview.98 196 3/18/2022
1.0.288-preview.93 210 3/15/2022
1.0.288-preview.87 222 3/10/2022
1.0.288-preview.86 224 3/8/2022
1.0.288-preview.73 203 2/25/2022
1.0.288-preview.65 221 2/18/2022
1.0.288-preview.48 230 2/4/2022
1.0.288-preview.41 221 1/31/2022
1.0.288-preview.29 231 1/28/2022
1.0.288-preview.20 220 1/27/2022
1.0.288-preview.19 213 1/27/2022
1.0.288-preview.5 228 1/24/2022
1.0.288-preview.1 217 1/21/2022
1.0.272 247 1/10/2022
1.0.259 421 12/9/2021
1.0.221 263 10/19/2021
1.0.219 260 10/19/2021
1.0.218 286 10/18/2021
1.0.155 257 8/31/2021
1.0.129 257 7/6/2021
1.0.125 303 7/5/2021
1.0.121 298 6/29/2021
1.0.120 274 6/29/2021
1.0.119 327 6/28/2021
1.0.9 299 5/21/2021