首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >张高兴的 Windows 10 IoT 开发笔记:无线收发芯片 nRF24L01

张高兴的 Windows 10 IoT 开发笔记:无线收发芯片 nRF24L01

作者头像
张高兴
发布2018-05-18 15:45:00
5780
发布2018-05-18 15:45:00
举报
文章被收录于专栏:张高兴的博客张高兴的博客

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. ```C# // 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(); * SecondlyC# 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().C# sender.Dispose(); receiver.Dispose(); ```

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-02-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Image
  • Connect
  • What Contains
  • How to Use
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档