nanoFramework.Iot.Device.Adxl345 1.2.570

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Adxl345 --version 1.2.570
NuGet\Install-Package nanoFramework.Iot.Device.Adxl345 -Version 1.2.570
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.570" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.Iot.Device.Adxl345 --version 1.2.570
#r "nuget: nanoFramework.Iot.Device.Adxl345, 1.2.570"
#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.Adxl345 as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Adxl345&version=1.2.570

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

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.570 60 6/14/2024
1.2.560 75 5/29/2024
1.2.548 63 5/15/2024
1.2.436 250 11/10/2023
1.2.416 115 11/8/2023
1.2.329 180 5/26/2023
1.2.313 175 5/12/2023
1.2.297 174 5/3/2023
1.2.253 265 2/22/2023
1.2.222 289 1/9/2023
1.2.217 325 1/6/2023
1.2.212 334 1/5/2023
1.2.208 335 1/3/2023
1.2.203 330 12/28/2022
1.2.159 379 11/14/2022
1.2.153 391 11/5/2022
1.2.141 422 10/25/2022
1.2.128 422 10/22/2022
1.2.122 453 10/12/2022
1.2.114 394 10/8/2022
1.2.95 461 9/22/2022
1.2.87 512 9/15/2022
1.2.73 448 9/8/2022
1.2.5 491 7/13/2022
1.1.141.41205 445 7/6/2022
1.1.116.8772 450 6/24/2022
1.1.113.2032 450 6/23/2022
1.1.97.17326 474 6/13/2022
1.1.92.53000 463 6/8/2022
1.1.58.10097 469 5/23/2022
1.1.27 455 4/26/2022
1.1.20 451 4/21/2022
1.1.3 476 4/15/2022
1.1.1 458 4/14/2022
1.0.300 469 3/31/2022
1.0.288-preview.114 119 3/25/2022
1.0.288-preview.113 110 3/25/2022
1.0.288-preview.106 106 3/23/2022
1.0.288-preview.104 100 3/22/2022
1.0.288-preview.100 106 3/19/2022
1.0.288-preview.99 119 3/18/2022
1.0.288-preview.98 102 3/18/2022
1.0.288-preview.93 110 3/15/2022
1.0.288-preview.87 114 3/10/2022
1.0.288-preview.86 109 3/8/2022
1.0.288-preview.73 108 2/25/2022
1.0.288-preview.65 109 2/18/2022
1.0.288-preview.48 128 2/4/2022
1.0.288-preview.41 123 1/31/2022
1.0.288-preview.29 132 1/28/2022
1.0.288-preview.20 126 1/27/2022
1.0.288-preview.19 120 1/27/2022
1.0.288-preview.5 128 1/24/2022
1.0.288-preview.1 124 1/21/2022
1.0.272 148 1/10/2022
1.0.259 304 12/9/2021
1.0.221 149 10/19/2021
1.0.219 158 10/19/2021
1.0.218 179 10/18/2021
1.0.155 153 8/31/2021
1.0.129 153 7/6/2021
1.0.125 193 7/5/2021
1.0.121 193 6/29/2021
1.0.120 173 6/29/2021
1.0.119 223 6/28/2021
1.0.9 192 5/21/2021