nanoFramework.Iot.Device.Nrf24l01 1.2.570
前缀已保留
dotnet add package nanoFramework.Iot.Device.Nrf24l01 --version 1.2.570
NuGet\Install-Package nanoFramework.Iot.Device.Nrf24l01 -Version 1.2.570
命令旨在在 Visual Studio 的包管理器控制台中使用,因为它使用 NuGet 模块的 Install-Package 版本。
<PackageReference Include="nanoFramework.Iot.Device.Nrf24l01" Version="1.2.570" />
对于支持 PackageReference 的项目,请将此 XML 节复制到项目文件中以引用此包。
paket add nanoFramework.Iot.Device.Nrf24l01 --version 1.2.570
NuGet 团队不提供对此客户端的支持。请联系其 维护者 以获取支持。
#r "nuget: nanoFramework.Iot.Device.Nrf24l01, 1.2.570"
#r 指令可用于 F# Interactive 和 Polyglot Notebooks。请将此内容复制到交互式工具或脚本的源代码中以引用该包。
// Install nanoFramework.Iot.Device.Nrf24l01 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Nrf24l01&version=1.2.570 // Install nanoFramework.Iot.Device.Nrf24l01 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Nrf24l01&version=1.2.570
NuGet 团队不提供对此客户端的支持。请联系其 维护者 以获取支持。
nRF24L01 - 单片 2.4 GHz 收发器
nRF24L01 是一个用于全球 2.4 - 2.5 GHz ISM 波段的单片无线电收发器。
文档
- 绑定数据表可在此处找到 这里
电路板
注意:以下图表使用 Raspberry Pi。这可以用任何具有 2 个可用 SPI 的 MCU 实现。
用法
硬件要求
- nRF24L01 × 2
- 公/母跳线
nRF1 连接
- VCC - 3.3V (最佳)
- GND - GND
- MOSI - SPI0 MOSI (GPIO 10)
- MISO - SPI0 MISO (GPIO 9)
- SCK - SPI0 SCLK (GPIO 11)
- CSN - SPI0 CS0 (GPIO 8)
- CE - GPIO 23
- IRQ - GPIO 24
nRF2 连接
- VCC - 3.3V (最佳)
- GND - GND
- MOSI - SPI1 MOSI (GPIO 20)
- MISO - SPI1 MISO (GPIO 19)
- SCK - SPI1 SCLK (GPIO 21)
- CSN - SPI1 CS0 (GPIO 16)
- CE - GPIO 5
- IRQ - GPIO 6
代码
重要:在创建 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 senderSettings = new SpiConnectionSettings(1, 42)
{
ClockFrequency = Nrf24l01.SpiClockFrequency,
Mode = Nrf24l01.SpiMode
};
SpiConnectionSettings receiverSettings = new SpiConnectionSettings(2, 44)
{
ClockFrequency = Nrf24l01.SpiClockFrequency,
Mode = Nrf24l01.SpiMode
};
var senderDevice = SpiDevice.Create(senderSettings);
var receiverDevice = SpiDevice.Create(receiverSettings);
// SPI Device, CE Pin, IRQ Pin, Receive Packet Size
using (Nrf24l01 sender = new Nrf24l01(senderDevice, 23, 24, 20))
{
using (Nrf24l01 receiver = new Nrf24l01(receiverDevice, 5, 6, 20))
{
// Set sender send address, receiver pipe0 address (Optional)
byte[] receiverAddress = Encoding.UTF8.GetBytes("NRF24");
sender.Address = receiverAddress;
receiver.Pipe0.Address = receiverAddress;
// Binding DataReceived event
receiver.DataReceived += Receiver_ReceivedData;
// Loop
while (true)
{
sender.Send(Encoding.UTF8.GetBytes("Hello! .NET Core IoT"));
Thread.Sleep(2000);
}
}
}
private static void Receiver_ReceivedData(object sender, DataReceivedEventArgs e)
{
var raw = e.Data;
var msg = Encoding.UTF8.GetString(raw);
Debug.Write("Received Raw Data: ");
foreach (var item in raw)
{
Debug.Write($"{item} ");
}
Debug.WriteLine();
Debug.WriteLine($"Message: {msg}");
Debug.WriteLine();
}
结果
产品 | 版本 兼容和额外的计算目标框架版本。 |
---|---|
.NET Framework | net 兼容。 |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.Runtime.Events (>= 1.11.18)
- nanoFramework.System.Device.Gpio (>= 1.1.41)
- nanoFramework.System.Device.Spi (>= 1.3.52)
NuGet 包
此包不被任何 NuGet 包使用。
GitHub 仓库
此包不被任何流行的 GitHub 仓库使用。
版本 | 下载 | 最后更新 |
---|---|---|
1.2.570 | 83 | 6/14/2024 |
1.2.560 | 86 | 5/29/2024 |
1.2.548 | 52 | 5/15/2024 |
1.2.436 | 226 | 11/10/2023 |
1.2.329 | 151 | 5/26/2023 |
1.2.313 | 132 | 5/12/2023 |
1.2.297 | 137 | 5/3/2023 |
1.2.203 | 305 | 12/28/2022 |
1.2.141 | 391 | 10/25/2022 |
1.2.122 | 403 | 10/12/2022 |
1.2.114 | 346 | 10/8/2022 |
1.2.95 | 427 | 9/22/2022 |
1.2.87 | 482 | 9/15/2022 |
1.2.73 | 395 | 9/8/2022 |
1.2.5 | 416 | 7/13/2022 |
1.1.141.41205 | 428 | 7/6/2022 |
1.1.113.2032 | 421 | 6/23/2022 |
1.1.58.10097 | 416 | 5/23/2022 |
1.1.27 | 414 | 4/26/2022 |
1.1.20 | 422 | 4/21/2022 |
1.1.1 | 430 | 4/14/2022 |
1.0.300 | 402 | 4/1/2022 |
1.0.277-preview.125 | 115 | 3/25/2022 |
1.0.277-preview.111 | 109 | 3/18/2022 |
1.0.277-preview.106 | 112 | 3/15/2022 |
1.0.277-preview.98 | 118 | 3/8/2022 |
1.0.277-preview.85 | 112 | 2/25/2022 |
1.0.277-preview.77 | 108 | 2/18/2022 |
1.0.277-preview.68 | 116 | 2/9/2022 |
1.0.277-preview.60 | 129 | 2/4/2022 |
1.0.277-preview.41 | 123 | 1/28/2022 |
1.0.277-preview.32 | 128 | 1/27/2022 |
1.0.277-preview.17 | 131 | 1/24/2022 |
1.0.277-preview.15 | 119 | 1/21/2022 |
1.0.277-preview.1 | 124 | 1/11/2022 |
1.0.259 | 275 | 12/9/2021 |
1.0.221 | 147 | 10/19/2021 |
1.0.219 | 162 | 10/19/2021 |
1.0.218 | 188 | 10/18/2021 |
1.0.155 | 156 | 8/31/2021 |
1.0.136 | 232 | 7/17/2021 |
1.0.135 | 154 | 7/16/2021 |
1.0.134 | 161 | 7/15/2021 |
1.0.133 | 191 | 7/14/2021 |
1.0.129 | 154 | 7/6/2021 |
1.0.125 | 187 | 7/5/2021 |
1.0.121 | 190 | 6/29/2021 |
1.0.119 | 220 | 6/28/2021 |
1.0.58 | 203 | 5/25/2021 |