Windows 10 IoT Core on RPI based nRF24L01 field gateway which enables sensor nodes to securely & reliably upload telemetry to AzureIoT Hubs.
Overview
For school Internet of Things (IoT) projects I needed a robust field gateway for uploading telemetry data from a number âcheap n cheerfulâ sensor nodes to a Microsoft Azure IoT Hub or Microsoft IoT Central. (Microsoftâs Platform As A Service (Paas) IoT solution)
The distances involved were modest 5M (indoors) to 600M (outdoors) so a mix of Low & high power nRF24L01 wireless modules looked like a suitable choice.
After looking at several Cloud IoT Services, Microsoft IoT Central looked like it had sufficient flexibility and scale. The security model (Feb 2018) will have some challenges in education deployments as you canât make a dataset publicly accessible. The Microsoft IoT Central also appears to be a work in progress with disabled buttons indicating future additional functionality.
Building it
Initially, I am using AMQP, but getting an HTTP endpoint (fine for telemetry) white-listed in a school environment is easier so the configuration also supports HTTP (Should do MQTT as well)
I also had some issues with the current (Feb 2018) version of the Microsoft.Azure.Devices.Client NuGet package so upgrade with caution.
The field gateway hardware is Raspberry PI 2/3 based with an âoff the shelfâ shield (with some simple modifications)
The Field Gateway configuration is stored in a JSON file (a sample file is provided in the Github repo).
{
"AzureIoTHubDeviceConnectionString": "Azure Iot Hub connection string goes here",
"AzureIoTHubTransportType": "Amqp",
"RF24Address": "Base1",
"RF24Channel": 10,
"RF24DataRate": "DR250Kbps",
"RF24PowerLevel": "High",
"RF24AutoAcknowledge": true,
"RF24DynamicAcknowledge": false,
"RF24DynamicPayload": true
}
The Azure IoT Hub connection string needs to be updated then the file uploaded to the LocalState directory in application folder.
User Folders\LocalAppData\Azure.IoTHub.IoTCore.FieldGateway.NRF24L01-uwp_1.0.0.0_arm__nmn3tag1rpsaw \LocalState\
I use the device portal âApps\File Explorerâ
[Edit:2018-03-09] The application now generates a sample configuration file if one is not found (so the GitHub sample is no longer necessary). Start the program, download the configuration file add your Azure IoT Hub connection string and change any other settings then upload,
The Windows 10 IoT Core device logs useful information via Realtime ETW Tracing which can be viewed in the Device Portal Debug\ETW after enabling the âMicrosoft-Windows-Diagnostics-LoggingChannelâ provider.
Once the application is configured and tested you can use the Device Portal\Apps Manager to set the program to run on device startup
I have created several sample sensor nodes which use the same SeeedStudio Grove temperature and humidity sensor
For an enclosure I use an off the shelf box from a local electrical supplies wholesaler.
Settings
The JSON configuration file has the following settings
AzureIoTHubDeviceConnectionString â copy this from
- IoT Hub\IotDevices\DeviceDetails blade in the Azure Portal
- âConnect this deviceâ on the âDevice Detailsâ page in Microsoft IoT Central.
AzureIoTHubTransportType
Amqp
Http1
Amqp_WebSocket_Only
Amqp_Tcp_Only
Mqtt
Mqtt_WebSocket_Only
Mqtt_Tcp_Only
RF24Address â 3 to 5 characters long
RF24Channel â 0 â 127
RF24DataRate
DR1Mbps
DR2Mbps
DR250Kbps
RF24PowerLevel options
Minimum
Low
High
Max
RF24AutoAcknowledge
True
False
RF24DynamicAcknowledge
True
False
RF24DynamicPayload
True
False
The Internet of Things Show has a video which shows how to setup devices in Microsoft IoT Central.
My code is just over 300 lines of C# (including comments, © Notice and white space). I have some additional features planned (local queuing, support for cloud to device messaging, âautomagicâ device provision etc.) but I was pleasantly surprised by how little code it took.
Schematics
Source: Azure IoT Hub nRF24L01 Windows 10 IoT Core Field Gateway