Mount the AVR128DB48 Curiosity Nano host
board and the RNWF11 Add On Board on Curiosity Nano base
board at respective headers. For more details about the boards placement in the Curiosity
Nano base, refer to the Figure 6-1.
Connect the debugger USB port on the
AVR128DB48 Curiosity Nano board to computer using a micro USB cable
Change the configuration. There are two
options to change the configuration:
Option 1: Change the configuration
manually in the code
Open the code in MPLAB IDE v6.00 or
higher and add Home AP and device information in the application code.
In rnwf_app.h,
add Wi-Fi configurations in HOME_AP_SSID,
HOME_AP_PASSPHRASE, HOME_AP_SECURITY.
In rnwf_app.h,
add Serial Number (Common Name) in the macro “CLIENT_ID” This value is the same
we can get as shown in Figure for “Device ID”. The user can find the value again by
navigating to “Devices”, select the device and select “Connect”. Refer Figure .
Similarly, in
rnwf_app.h “AZURE_PUB_TELEMETRY” is in format
devices/{registration_id}/messages/events/. Replace
{registration_id} with Serial number (Common Name).
In rnwf_app.h,
add ID scope in the macro “AZURE_SCOPE_ID”. To get the value of ID scope go to
“Devices”, select the device and select “Connect”. Refer Figure .
In rnwf_app.c,
username in structure mqtt_cfg is in format
{idScope}/registrations/{registration_id}/api-version=2019-03-31.
Replace {id_scope} with ID Scope and
{registration_id} with value of Client ID.
In
rnwf_mqtt_service.c, add the preferred JSON device template
value in the macro MQTT_DPS_MSG_SET_REQ. To get the template:
Go to “Device
template”.
Select the required
template.
Select “Edit DTDL”.
Copy text from @id.
Option 2: Change the configuration via
MCC Melody.
For more details about Wi-Fi
configurations, refer Figure 3-5.
The following fields can be
configured via MCC Melody Wi-Fi settings;
SSID
Security Type
Passphrase
Refer Figure 3-9 to understand how to make Cloud Configuration changes
The following fields can be
configured via MCC Melody OTA configuration settings.
The format of username
field is
{idScope}/registrations/{registration_id}/api-version=2019-03-31.
Replace {id_scope} with Scope ID and
{registration_id} with value of Client ID.
Publish Topic Name
The format of publish
topic name is devices/{registration_id}/messages/event.
Replace {registration_id} with the user’s Client
ID.
Save the changes and then build and program
the project.
Connect to the “USB to UART” COM port and
configure the serial settings as follows:
Baud – 115200
Data – 8 Bits
Parity – None
Stop – 1 Bit
Flow Control – None
The board boots up and the application
starts running. It prints Wi-Fi information, certificates on the board, Serial number of the
device, connects to Home-AP and then to Azure IoT hub. It sends telemetry data for button
press events and its count, parameters (IP address value, LED on/off, etc.) and commands.