This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.

GitHub:https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/NRF24L01

Image

Connect

nRF1

  • VCC - 3.3V (Best)
  • 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 (Best)
  • 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

What Contains

In NRF24L01.cs file

/// <summary>
/// Initialize
/// </summary>
public async Task InitializeAsync(); /// <summary>
/// Send
/// </summary>
/// <param name="data">Data</param>
public async void Send(byte[] data); /// <summary>
/// Receive
/// </summary>
/// <param name="length">Packet Size</param>
/// <returns>Data</returns>
public byte[] Receive(byte length);

......

How to Use

  • First, you need to create a NRF24L01 object. After that you should call InitializeAsync() to initialize.
// Create and Initialize
// CSN Pin, CE Pin, IRQ Pin, SPI Friendly Name, Receive Packet Size
NRF24L01 sender = new NRF24L01(0, 23, 24, "SPI0", 12);
NRF24L01 receiver = new NRF24L01(0, 5, 6, "SPI1", 12); await sender.InitializeAsync();
await receiver.InitializeAsync();
  • Secondly
sender.Send(Encoding.UTF8.GetBytes("ZhangGaoxing"));
receiver.ReceivedData += Receiver_ReceivedData; private void Receiver_ReceivedData(object sender, ReceivedDataEventArgs e)
{
var raw = e.Data.Skip(1).ToArray();
var res = Encoding.UTF8.GetString(raw); Debug.Write("Received Raw Data : ");
foreach (var item in raw)
{
Debug.Write($"{item} ");
}
Debug.WriteLine("");
Debug.WriteLine($"Received Data : {res}");
}
  • If you want to close the sensor, call Dispose().
sender.Dispose();
receiver.Dispose();

张高兴的 Windows 10 IoT 开发笔记:无线收发芯片 nRF24L01的更多相关文章

  1. 张高兴的 Windows 10 IoT 开发笔记:使用 ADS1115 读取模拟信号

    考虑到 Raspberry Pi 读取模拟信号是很烦人的事情,更何况是在没人玩的 Windows 10 IoT 下,所以准备正儿八经的写点东西. 需求:使用 Raspberry Pi 读取输出模拟信号 ...

  2. 张高兴的 Windows 10 IoT 开发笔记:使用 Lightning 中的软件 PWM 驱动 RGB LED

    感觉又帮 Windows 10 IoT 开荒了,所以呢,正儿八经的写篇博客吧.其实大概半年前就想写的,那时候想做个基于 Windows 10 IoT 的小车,但树莓派原生不支持 PWM 啊.百度也搜不 ...

  3. 张高兴的 Windows 10 IoT 开发笔记:HC-SR04 超声波测距模块

    HC-SR04 采用 IO 触发测距.下面介绍一下其在 Windows 10 IoT Core 环境下的用法. 项目运行在 Raspberry Pi 2/3 上,使用 C# 进行编码. 1. 准备 H ...

  4. 张高兴的 Windows 10 IoT 开发笔记:BH1750FVI 光照度传感器

    BH1750FVI 是一款 IIC 接口的数字型光强度传感器集成电路.下面介绍一下其在 Windows 10 IoT Core 环境下的用法. 项目运行在 Raspberry Pi 2/3 上,使用 ...

  5. 张高兴的 Windows 10 IoT 开发笔记:部署 ASP.NET Core 2 应用

    今天是大年初二,都去走亲戚了吧,享受一下这难得的能和亲友相聚的时光.而我就不一样了,今天一回到家就又开始瞎折腾了,哈哈哈. 问题背景 最近花了点时间用 ASP.NET Core 2 写了个个人博客,中 ...

  6. 张高兴的 Windows 10 IoT 开发笔记:串口红外编解码模块 YS-IRTM

    This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#. GitHub: https://github.c ...

  7. 张高兴的 Windows 10 IoT 开发笔记:FM 电台模块 KT0803L

    This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#. GitHub:https://github.co ...

  8. 张高兴的 Windows 10 IoT 开发笔记:0.96 寸 I2C OLED

    This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#. GitHub:https://github.co ...

  9. 张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动数码管

    This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#. GitHub:https://github.co ...

随机推荐

  1. .Net4.5新特性:正则表达式超时介绍

    “Regex” 在数据验证方面最受欢迎.考虑到您可能对“Regex”完全陌生的.请参考我介绍Regex如何运作的视频. But because of the typical parsing logic ...

  2. mvc中seeeion和cook的用法

    public ActionResult A() {     Session["test"]="123";     return View(); } public ...

  3. C#在.NET编译执行过程

    1..NET语言的编译器接受源代码文件,并生成名为程序集的输出文件. 程序集要么是可执行的,要么是DLL 程序集里的代码并不是本机代码,而是一种名称为CIL的中间语言 程序集包含如下信息: 程序的CI ...

  4. BASE64转文件下载

    你可以用HTML 5 注意:返回的文件数据必须是base 64编码的,因为您不能对二进制数据进行JSON编码 在我的AJAX我得到了如下的数据结构: <!DOCTYPE html> < ...

  5. mac系统终端sudo免输入密码技能get

    1.需要在/etc/sudoers中配置. 这个文件的权限是r/r/n,配置之前需要加写权限. sudo chmod u-w /etc/sudoers 2.打开命令窗口sudo visudo 或者 s ...

  6. Service生命周期以及应用

    Service概念及用途: Android中的服务,它与Activity不同,它是不能与用户交互的,不能自己启动的,运行在后台的程序,如果我们退出应用时,Service进程并没有结束,它仍然在后台运行 ...

  7. solr+tomcat整合

    一.solr安装 http://archive.apache.org/dist/lucene/solr/ 这个地址有各个版本的 这次我使用的是5.5.4版本和tomcat8 版本5.5.4已经内置了j ...

  8. HDU 4279 Number-------找规律题

    Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  9. [微信小程序]微信开发工具出现 1not found 编译 .wxss文件信息错误怎么办?

    错误代码: "1not found 编译 .wxss文件信息错误",如 下图 出现场景: 1.一般出现在安装新版本之后出现的状况,可能由于版本之间的兼容导致 解决办法: 1.重装整 ...

  10. js获取url中参数名也参数值

    要撮利用js获取url中参数名也参数值这个不多见了,但我今天需要这样操作,下面我来给大家介绍一下具体的实例方法.   在已知参数名的情况下,获取参数值,使用正则表达式能很容易做到. js的实现方法如下 ...