Issue link: https://resources.mouser.com/i/1442841
29 / Update Application Source Code Files for Medium One Account Parameters Set Wi-Fi Connection Parameters In MPLAB X open project file Header Files/MCC Generated Files/config/conf_winc.h in the editor. Find these constants and set them to your own Wi-Fi SSID and password info: • CFG_MAIN_WLAN_SSID • CFG_MAIN_WLAN_AUTH • CFG_MAIN_WLAN_PSK Set Medium One Connection Parameters Open project file Header Files/MCC Generated Files/config/ IoT_Sensor_Node_config.h in the editor. Find these constants and set them to your own Medium One MQTT parameter strings as described earlier: • CFG_MQTT_USERNAME • CFG_MQTT_PASSWORD • CFG_MQTT_TOPIC – everything except the final Device ID field, which will be added at runtime NOTE: The current version of the PIC-IoT code is not able to connect to the Medium One MQTT broker over TLS and this project uses unencrypted MQTT communications between the PIC-IoT and Medium One MQTT broker. The MQTT username and password are sent over the internet in the clear and neither the credentials nor the sensor data are encrypted. Save the modified file and then build the project. Verify the code compiles without errors. If you see compilation errors, check the changes you made to the conf_winc.h and IoT_ Sensor_Node_config.h files. Run the Application Make sure the PIC-IoT board is connected to the PC through USB. Build the program and then download to the PIC-IoT board. The program should be downloaded to the board and start running. You can connect a serial terminal program such as Tera Term to the USB serial comm port if necessary to monitor debug messages from the PIC-IoT while it's running. Set the serial parameters to 9600,N,8,1. How the Application Program Works This program is derived from the PIC-IoT WG Sensor Node example application with the following changes and enhancements: • Connect to the Medium One MQTT broker instead of Google Cloud. • Add MQTT username. • Use the ATECC608A unique ID as the Device ID in the MQTT topic name. • Use unencrypted MQTT connection. • Add iteration count data element. • Set data measurement interval to 5 seconds. • Generate a JSON formatted MQTT payload message and send to Medium One MQTT broker. MQTT Payload Format MQTT messages are formatted as JSON strings according to the Medium One MQTT payload specification. Here's an example message: {"event_data":{"light":40,"tempc":31.87,"iteration":32}} Fields: • light = light sensor value • tempc = temperature in degrees Celsius • iteration = application loop counter Try heating or cooling the temperature sensor and covering the light sensor to see the data values change. Figure 5: Newly created user ID with auto-generated MQTT ID. (Source: Mouser Electronics) Figure 7: Newly Created API Key. (Source: Mouser Electronics) Figure 6: Project MQTT ID. (Source: Mouser Electronics)