6.1.8.2 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.
        • (Optional) The subscribe and publish topics are same, therefore the user can see the received messages on the terminal. The users can subscribe and publish to another topic of their choice and exchange message. Change Publish topic name in MQTT_PUB_TOPIC in rnwf_app.h.
        • (Optional) In rnwf_app.c, the user can add subscribe topic name of their choice in subscribe_list[].
    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. Publish Topic Name (Optional)
        2. Sub Topic Name (Optional)
      • 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-30. Make and Program Device Main Project
  5. Open the Terminal application (for example, Tera Term or PuTTY) on the PC.
  6. Connect to the host board’s 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
  7. Press the SW0 (Soft Reset) button on the host board.
  8. The board boots up and lists certificates available on the board. After successfully connecting with Wi-Fi, it connects to test.mosquitto.org on port 1883 (unencrypted).
  9. To demonstrate successful MQTT connection, the board subscribes to topic mchp/sample/b and publishes a message on the same topic. The received message is printed in the terminal.
    Figure 6-31. Basic Cloud Demo Logs
  10. If the user wants to change the Subscribe topic and Publish topic, make changes in the configuration, build the program, and run it again. Make a note of the Publish Topic Name and Subscribe Topic Name.
  11. Open a MQTT Client software tool (for example, MQTT.fx).
  12. Enter Subscribe topic in the tool at which the user wants to publish the message from the device. When the RNWF11 device connects to test.mosquitto.org it will publish message to the entered Publish Topic Name and the user can receive and see the messages in MQTT Client Software tool.
    Figure 6-32. Subscribe Window in MQTT Client Software
    Figure 6-33. Subscribe Topic Name in MQTT Client Software
    Figure 6-34. Message Received on Subscribed Topic
  13. Follow a similar method to receive messages on the user’s preferred Subscribe Topic Name.
    Figure 6-35. Sending Message from MQTT Client Software to the Device
    Figure 6-36. Message Received on the Device