nanoFramework.Iot.Device.Adxl345 1.2.590
前缀已预留
dotnet add package nanoFramework.Iot.Device.Adxl345 --version 1.2.590
NuGet\Install-Package nanoFramework.Iot.Device.Adxl345 -Version 1.2.590
此命令旨在在Visual Studio的包管理器控制台中使用,因为它使用了NuGet模块的Install-Package版本的版本。
<PackageReference Include="nanoFramework.Iot.Device.Adxl345" Version="1.2.590" />
对于支持包引用的项目,将此XML节点复制到项目文件中以引用该包。
paket add nanoFramework.Iot.Device.Adxl345 --version 1.2.590
NuGet 团队不提供对此客户端的支持。请联系其维护者以获取支持。
#r "nuget: nanoFramework.Iot.Device.Adxl345, 1.2.590"
#r指令可以在F# Interactive和Polyglot Notebooks中使用。将此内容复制到交互工具或脚本的源代码中以引用包。
// Install nanoFramework.Iot.Device.Adxl345 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Adxl345&version=1.2.590 // Install nanoFramework.Iot.Device.Adxl345 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Adxl345&version=1.2.590
NuGet 团队不提供对此客户端的支持。请联系其维护者以获取支持。
ADXL345 - 加速计
ADXL345是一款小型、轻薄、低功耗的3轴加速度计,分辨率高达(13位),可测量最大±16g的加速度。
文档
传感器图像
用法
重要:在创建 SpiDevice 之前,请确保正确设置 SPI 引脚,尤其是 ESP32 的 SPI 引脚,并确保安装 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
对于其他设备,如STM32,请确保您使用您要使用的 SPI 总线的预设引脚。芯片选择也可以预先设置。
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
}
示例
硬件需求
- ADXL345
- 公/母跳线
电路
- VCC - 3.3 V
- GND - GND
- CS - CS
- SDO - SPI1 MISO
- SDA - SPI1 MOSI
- SCL - SPI1 SCLK
代码
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);
}
}
结果
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.Runtime.Events (>= 1.11.18)
- nanoFramework.System.Buffers.Binary.BinaryPrimitives (>= 1.2.586)
- nanoFramework.System.Device.Gpio (>= 1.1.41)
- nanoFramework.System.Device.Model (>= 1.2.586)
- nanoFramework.System.Device.Spi (>= 1.3.52)
- nanoFramework.System.Math (>= 1.5.43)
- nanoFramework.System.Numerics (>= 1.2.586)
NuGet 包
此包未被任何 NuGet 包使用。
GitHub 仓库
此包未被任何流行 GitHub 仓库使用。
版本 | 下载 | 最后更新 |
---|---|---|
1.2.590 | 70 | 7/17/2024 |
1.2.570 | 68 | 6/14/2024 |
1.2.560 | 80 | 5/29/2024 |
1.2.548 | 68 | 5/15/2024 |
1.2.436 | 251 | 11/10/2023 |
1.2.416 | 117 | 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 | 266 | 2/22/2023 |
1.2.222 | 290 | 1/9/2023 |
1.2.217 | 328 | 1/6/2023 |
1.2.212 | 335 | 1/5/2023 |
1.2.208 | 336 | 1/3/2023 |
1.2.203 | 333 | 12/28/2022 |
1.2.159 | 385 | 11/14/2022 |
1.2.153 | 395 | 11/5/2022 |
1.2.141 | 423 | 10/25/2022 |
1.2.128 | 423 | 10/22/2022 |
1.2.122 | 455 | 10/12/2022 |
1.2.114 | 395 | 10/8/2022 |
1.2.95 | 462 | 9/22/2022 |
1.2.87 | 514 | 9/15/2022 |
1.2.73 | 449 | 9/8/2022 |
1.2.5 | 495 | 7/13/2022 |
1.1.141.41205 | 447 | 7/6/2022 |
1.1.116.8772 | 452 | 6/24/2022 |
1.1.113.2032 | 454 | 6/23/2022 |
1.1.97.17326 | 476 | 6/13/2022 |
1.1.92.53000 | 465 | 6/8/2022 |
1.1.58.10097 | 469 | 5/23/2022 |
1.1.27 | 455 | 4/26/2022 |
1.1.20 | 457 | 4/21/2022 |
1.1.3 | 476 | 4/15/2022 |
1.1.1 | 464 | 4/14/2022 |
1.0.300 | 469 | 3/31/2022 |
1.0.288-preview.114 | 121 | 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 | 101 | 3/22/2022 |
1.0.288-preview.100 | 108 | 3/19/2022 |
1.0.288-preview.99 | 119 | 3/18/2022 |
1.0.288-preview.98 | 103 | 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 | 111 | 3/8/2022 |
1.0.288-preview.73 | 109 | 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 | 134 | 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 | 129 | 1/24/2022 |
1.0.288-preview.1 | 125 | 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 | 160 | 10/19/2021 |
1.0.218 | 180 | 10/18/2021 |
1.0.155 | 153 | 8/31/2021 |
1.0.129 | 154 | 7/6/2021 |
1.0.125 | 194 | 7/5/2021 |
1.0.121 | 196 | 6/29/2021 |
1.0.120 | 175 | 6/29/2021 |
1.0.119 | 227 | 6/28/2021 |
1.0.9 | 197 | 5/21/2021 |