This application allows the RNWF02 board to act as MQTT client and connect to (and communicate) Azure IoT application. The module comes with the required X.509 certificates that simplify TLS handshake protocol with Microsoft Azure. It only needs secure device certificate on Azure for individual enrollment. Then, using AT+commands, user can connect the RNWF02 to Azure IoT Hub
To build this application, open the project file (apps/azure_demo/firmware/azure_demo_sam_e54_xpro_rnwf02.X
) in MPLAB X IDE. For more details on opening the project file in MPLAB X IDE, refer to the Opening the Project file. The following table provides details on the project file.
Project Name | Description |
---|---|
azure_demo_sam_e54_xpro_rnwf02.X |
MPLAB X project for SAM E54 Xplained Pro evaluation kit and RNWF02 Add On Board |
- This application demonstrates the Azure Plug and Play connection with the Azure IoT Central. Using this application, most users can connect their Microchip RNWF02 to Azure Cloud/Azure IoT Hub in a few minutes.
-
Create a Root of Trust Chain for RNWF Devices:
The demo application includes a set of tools in
../apps/azure_demo/tools
folder. It enables easy creation of certificate infrastructure and individual device certificates with very minimal user inputs.Note:
- On Windows Operating Systems, make sure the GitBash is installed to run these tools.
- These scripts are based on the Azure's Create and Upload Certificates for Testing tutorial.
-
Device Certificate
-
Run the
create_device_certificate.sh
to create individual device certificate. It requests the user to provide Subordinate/Intermediate CA folder name and a unique device id (Common Name).Note:
-
On successful execution of device certificate, a new folder is created inside the
../tools/devcerts
folder as illustrated in following figureNote: Note down the information of certificate and key file names (by default device ID or common name) for use later in the Azure TLS configuration
-
Use the PC companion mode of the setup and program the .pem and * .key* files (highlighted/marked below) using file_upload tools.
-
-
Uploading a Certificate to Microsoft Azure Cloud
-
For new users, create a new Azure Account
-
Log into the Azure Portal using the new/existing account
-
From the Azure homepage, select + Create a resource > Categories > Internet of Things > IoT Hub. Figure . Azure Home Page - Create a Resource
-
In Basics tab, enter the project details as shown in the following figure.
- Select the Subscription and Resource group for the IoT hub.
-
To create a new resource group, select “Create new” and provide a custom name. Use unique alphanumeric characters for the IoT hub name.
-
In the Networking tab, set Connectivity configuration and TLS version.
Note: Once the IoT hub is created, TLS version can not be updated. The user can select the default setting 1.0.
-
As per the user’s choice, set access permissions from the Management, Add-ons and Tags tabs.
-
Click Review + create to review choices and then select Create to start deployment of new hub.
-
Go to the newly created IoT hub and select Devices under Device management from the left navigation pane.
-
Click Add Device to register your device certificate. In the Create a device window:
-
Enter the Device ID. It is the ID that is given as “Issued To” in the Device Certificate (see following figure).
-
Select Authentication type as “X.509 Self-Signed”.
-
To get the Primary Thumbprint and Secondary Thumbprint value:
- Double-click on the device certificate, go to Details tab and scroll down to Thumbprint.
- Copy and paste the thumbprint value to both ‘Primary Thumbprint’ and ‘Secondary Thumbprint’.
- Select Enable to connect the device to an IoT hub.
11.Click Save. The device will be added to the IoT hub and it will also be displayed in the list of devices.
-
Connect the debugger USB port on the SAM E54 Xplained Pro evaluation kit to computer using a micro USB cable
-
Open the project and launch MCC with Harmony3.
-
Configure Home-AP credentials for STA mode, using the Wi-Fi settings configuration. For more details about the Wi-Fi settings configuration, See Figure 3-52.
-
Update the Azure Cloud configuration with following details. For more details about the Azure Cloud configuration, See Figure 3-58
- The following fields can be configured via MCC settings.
-
Cloud URL :
-
Client ID :
-
Username :
- The format of username field is {iothub broker url}/{registration_id}/?api-version=2021-04-12. Replace {iothub broker url} with IoT hub’s URL and {registration_id} with Serial Number (Common Name)
-
Publish Topic Name :
- The format of publish topic name is devices/{registration_id}/messages/event. Replace {registration_id} with the user’s Client ID.
-
- The following fields can be configured via MCC settings.
-
Generate the code as illustrated below
-
Build and program the code to the hardware using MPLABX IDE
-
Open the Terminal application (for example, Tera Term or PuTTY) on the PC Connect to the "EDBG Virtual COM Port" and configure the serial settings as follows:
- Baud: 115200
- Data: 8 Bits
- Parity: None
- Stop: 1 Bit
- Flow Control: None
-
Press the Reset button on the host board, see Figure 6-1.
-
As the board boots up, application will list available certificates and keys on RNWF02 board. The board will connect to Home-AP configured. After this, the demo will attempt to connect to Azure IoT Hub (using link configured it sends telemetry data for button press events and its count to the cloud).To verify the device-to-cloud and cloud-to-device telemetry, use Azure IoT Explorer application.
-