First step is to build a basic Windows 10 IoT Core background task which can receive and display messages sent from a variety of devices across an nRF24L01 wireless link.
If you create a new “Windows IoT Core” “Background Application” project then copy this code into StartupTasks.cs the namespace has to be changed in the C# file, project properties\library\Default namespace and “Package.appxmanifest”\declarations\Entry Point.
/* Copyright ® 2017 December devMobile Software, All Rights Reserved THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. http://www.devmobile.co.nz */ using System; using System.Diagnostics; using System.Text; using Radios.RF24; using Windows.ApplicationModel.Background; namespace devmobile.IoTCore.nRF24BackgroundTask { public sealed class StartupTask : IBackgroundTask { private const byte ChipEnablePin = 25; private const byte ChipSelectPin = 0; private const byte nRF24InterruptPin = 17; private const string BaseStationAddress = "Base1"; private const byte nRF24Channel = 10; private RF24 Radio = new RF24(); private BackgroundTaskDeferral deferral; public void Run(IBackgroundTaskInstance taskInstance) { Radio.OnDataReceived += Radio_OnDataReceived; Radio.OnTransmitFailed += Radio_OnTransmitFailed; Radio.OnTransmitSuccess += Radio_OnTransmitSuccess; Radio.Initialize(ChipEnablePin, ChipSelectPin, nRF24InterruptPin); Radio.Address = Encoding.UTF8.GetBytes(BaseStationAddress); Radio.Channel = nRF24Channel; Radio.PowerLevel = PowerLevel.High; Radio.DataRate = DataRate.DR250Kbps; Radio.IsEnabled = true; Debug.WriteLine("Address: " + Encoding.UTF8.GetString(Radio.Address)); Debug.WriteLine("PA: " + Radio.PowerLevel); Debug.WriteLine("IsAutoAcknowledge: " + Radio.IsAutoAcknowledge); Debug.WriteLine("Channel: " + Radio.Channel); Debug.WriteLine("DataRate: " + Radio.DataRate); Debug.WriteLine("IsDynamicAcknowledge: " + Radio.IsDyanmicAcknowledge); Debug.WriteLine("IsDynamicPayload: " + Radio.IsDynamicPayload); Debug.WriteLine("IsEnabled: " + Radio.IsEnabled); Debug.WriteLine("Frequency: " + Radio.Frequency); Debug.WriteLine("IsInitialized: " + Radio.IsInitialized); Debug.WriteLine("IsPowered: " + Radio.IsPowered); deferral = taskInstance.GetDeferral(); Debug.WriteLine("Run completed"); } private void Radio_OnDataReceived(byte[] data) { // Display as Unicode string unicodeText = Encoding.UTF8.GetString(data); Debug.WriteLine("Unicode - Payload Length {0} Unicode Length {1} Unicode text {2}", data.Length, unicodeText.Length, unicodeText); // display as hex Debug.WriteLine("Hex - Length {0} Payload {1}", data.Length, BitConverter.ToString(data)); } private void Radio_OnTransmitSuccess() { Debug.WriteLine("Transmit Succeeded!"); } private void Radio_OnTransmitFailed() { Debug.WriteLine("Transmit Failed!"); } } }
This was displayed in the output window of Visual Studio
Address: Base1
PA: 15
IsAutoAcknowledge: True
Channel: 10
DataRate: DR250Kbps
IsDynamicAcknowledge: False
IsDynamicPayload: True
IsEnabled: True
Frequency: 2410
IsInitialized: True
IsPowered: True
Run completed
…
Interrupt Triggered: FallingEdge
Unicode – Payload Length 19 Unicode Length 19 Unicode text T 23.8,H 73,V 3.26
Hex – Length 19 Payload 54-20-32-33-2E-38-2C-48-20-20-37-33-2C-56-20-33-2E-32-36
Interrupt Triggered: RisingEdge
Note the odd formatting of the Temperature and humidity values which is due to the way dtostrf function in the Atmel AVR library works.
Also noticed the techfooninja nRF24 library has configurable output power level which I will try to retrofit onto the Gralin NetMF library.
Next, several simple Arduino, devDuino V2.2, Seeeduino V4.2 and Netduino 2/3 clients (plus possibly some others)
Pingback: Windows 10 IoT Core BorosRf2 – Dual nRF24L01 pHat/Hat | devMobile's blog