nanoFramework.Iot.Device.Adxl345 1.1.97.17326

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Adxl345 --version 1.1.97.17326                
NuGet\Install-Package nanoFramework.Iot.Device.Adxl345 -Version 1.1.97.17326                
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.1.97.17326" />                
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.1.97.17326                
#r "nuget: nanoFramework.Iot.Device.Adxl345, 1.1.97.17326"                
#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.1.97.17326

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

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.776 78 2/4/2025
1.2.775 69 2/4/2025
1.2.772 68 2/4/2025
1.2.759 70 1/31/2025
1.2.755 72 1/31/2025
1.2.737 69 1/13/2025
1.2.704 103 12/18/2024
1.2.696 89 12/16/2024
1.2.673 95 10/23/2024
1.2.631 104 8/28/2024
1.2.590 92 7/17/2024
1.2.570 98 6/14/2024
1.2.560 107 5/29/2024
1.2.548 94 5/15/2024
1.2.436 279 11/10/2023
1.2.416 146 11/8/2023
1.2.329 215 5/26/2023
1.2.313 193 5/12/2023
1.2.297 205 5/3/2023
1.2.253 298 2/22/2023
1.2.222 316 1/9/2023
1.2.217 353 1/6/2023
1.2.212 362 1/5/2023
1.2.208 362 1/3/2023
1.2.203 350 12/28/2022
1.2.159 419 11/14/2022
1.2.153 423 11/5/2022
1.2.141 453 10/25/2022
1.2.128 450 10/22/2022
1.2.122 490 10/12/2022
1.2.114 423 10/8/2022
1.2.95 493 9/22/2022
1.2.87 544 9/15/2022
1.2.73 483 9/8/2022
1.2.5 522 7/13/2022
1.1.141.41205 479 7/6/2022
1.1.116.8772 474 6/24/2022
1.1.113.2032 480 6/23/2022
1.1.97.17326 505 6/13/2022
1.1.92.53000 498 6/8/2022
1.1.58.10097 498 5/23/2022
1.1.27 476 4/26/2022
1.1.20 487 4/21/2022
1.1.3 514 4/15/2022
1.1.1 493 4/14/2022
1.0.300 509 3/31/2022
1.0.288-preview.114 140 3/25/2022
1.0.288-preview.113 130 3/25/2022
1.0.288-preview.106 121 3/23/2022
1.0.288-preview.104 120 3/22/2022
1.0.288-preview.100 121 3/19/2022
1.0.288-preview.99 133 3/18/2022
1.0.288-preview.98 116 3/18/2022
1.0.288-preview.93 130 3/15/2022
1.0.288-preview.87 129 3/10/2022
1.0.288-preview.86 130 3/8/2022
1.0.288-preview.73 122 2/25/2022
1.0.288-preview.65 123 2/18/2022
1.0.288-preview.48 149 2/4/2022
1.0.288-preview.41 138 1/31/2022
1.0.288-preview.29 147 1/28/2022
1.0.288-preview.20 139 1/27/2022
1.0.288-preview.19 132 1/27/2022
1.0.288-preview.5 146 1/24/2022
1.0.288-preview.1 136 1/21/2022
1.0.272 165 1/10/2022
1.0.259 339 12/9/2021
1.0.221 172 10/19/2021
1.0.219 177 10/19/2021
1.0.218 198 10/18/2021
1.0.155 174 8/31/2021
1.0.129 172 7/6/2021
1.0.125 219 7/5/2021
1.0.121 215 6/29/2021
1.0.120 192 6/29/2021
1.0.119 244 6/28/2021
1.0.9 216 5/21/2021