6.1.7.4 Running the Application

  1. 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.
  2. Connect the debugger USB port on the AVR128DB48 Curiosity Nano board to computer using a micro USB cable
  3. Change the configuration. There are two options to change the configuration:
    1. Option 1: Change the configuration manually in the code
      1. 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.
            Figure 6-24. DTMI Value from the Device Template
    2. Option 2: Change the configuration via MCC Melody.
      • For more details about Wi-Fi configurations, refer Figure 3-5.
        1. The following fields can be configured via MCC Melody Wi-Fi settings;
          1. SSID
          2. Security Type
          3. Passphrase
      • Refer Figure 3-9 to understand how to make Cloud Configuration changes
        1. The following fields can be configured via MCC Melody OTA configuration settings.
          • Scope ID
            1. Replace with ID scope of the Azure application.
            2. To get the value of ID scope:
              1. Go to “Devices”.
              2. Select the device.
              3. Select “Connect”. Refer Figure .
          • Device Template
            1. Add the JSON device template value.
            2. To get the value:
              1. Go to “Device template”.
              2. Select the required template.
              3. Select “Edit DTDL”.
              4. Copy text from @id. Refer Figure 6-24.
          • Client ID
            1. Add Serial Number (Common Name). Refer Figure .

              (Or)

              1. Go to “Devices”.
              2. Select the device.
              3. Select “Connect”. Refer Figure .
          • Username
            1. 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
            1. The format of publish topic name is devices/{registration_id}/messages/event. Replace {registration_id} with the user’s Client ID.
      • For more details on how to merge code upon regeneration, refer to the Appendix A.4 - Merging Manual Changes Into Regenerated Code.
  4. Save the changes and then build and program the project.
    Figure 6-25. Make and Program Device Main Project
  5. Connect to the “USB to UART” COM port and configure the serial settings as follows:
    1. Baud – 115200
    2. Data – 8 Bits
    3. Parity – None
    4. Stop – 1 Bit
    5. Flow Control – None
  6. 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.
    Figure 6-26. Device Interface Debug Log
    Figure 6-27. Device Interface Debug Log with Telemetry Data
  7. To see event logs on the Azure IoT application,
    1. Go to “Devices” and select the device.
    2. Select the “Raw data”.
    3. Open the message of the required type.
      Figure 6-28. Azure Event Logs
      Figure 6-29. Telemetry Message Type