04 Deploy the solution to Azure Sphere - gloveboxes/AiPoweredPredictiveMaintenance GitHub Wiki
Clone the Azure Sphere Predictive Maintenance project to a directory close to the root directory on your computer. For example, c:\GitHub, or ~/. The reason is that the Azure Sphere build process uses CMake which doesn't support long folder path names.
git clone --recurse-submodules https://github.com/gloveboxes/AzureSphereClassify
- Start Visual Studio Code
- From the Visual Studio Code main menu, select File, then select Open folder.
- Navigate to the AzureSphereClassify folder you cloned to your computer, then select classifyHL, and open.
The default board is the Avnet Starter Kit Rev 1. If this is the board and sensor you're using, then skip to the next step.
If you have an Avnet Starter Kit Rev 2 board then follow these instructions.
- Open the CMakeLists.txt file.
- Comment out the Avnet Rev 1 board with a #.
- Uncomment the Avnet Rev 2 board by removing the leading # character.
- Save the changes.
You need the configuration information saved when you completed the List your IoT Central network endpoints.
-
Open the app_manifest.json file.
-
Update the CmdArgs property with your IoT Central ID Scope.
-
Get your Azure Sphere Tenant ID. From a command prompt, run the following command.
azsphere tenant show-selected -o yaml
The output of this command will be similar to the following. The id property value is your Azure Sphere Tenant ID.
id: 9abc79eb-9999-43ce-9999-fa8888888894 name: myAzureSphereTenant roles: - Administrator
-
Update the DeviceAuthentication property with your Azure Sphere Tenant ID.
-
Update the AllowedConnections property with the IoT Central Application endpoint URLs you copied to Notepad.
-
Review your updated manifest_app.json file. It should be similar to the following.
{ "SchemaVersion": 1, "Name": "classify_solution", "ComponentId": "25025d2c-66da-4448-bae1-ac26fcdd3627", "EntryPoint": "/bin/app", "CmdArgs": [ "--ScopeID", "0ne0099999D" ], "Capabilities": { "Gpio": [ "$NETWORK_CONNECTED_LED", "$LED2" ], "AllowedApplicationConnections": [ "6583cf17-d321-4d72-8283-0b7c5b56442b" ], "AllowedConnections": [ "global.azure-devices-provisioning.net", "global.azure-devices-provisioning.net", "iotc-9999bc-3305-99ba-885e-6573fc4cf701.azure-devices.net", "iotc-789999fa-8306-4994-b70a-399c46501044.azure-devices.net", "iotc-7a099966-a8c1-4f33-b803-bf29998713787.azure-devices.net", "iotc-97299997-05ab-4988-8142-e299995acdb7.azure-devices.net", "iotc-d099995-7fec-460c-b717-e99999bf4551.azure-devices.net", "iotc-789999dd-3bf5-49d7-9e12-f6999991df8c.azure-devices.net", "iotc-29999917-7344-49e4-9344-5e0cc9999d9b.azure-devices.net", "iotc-99999e59-df2a-41d8-bacd-ebb9999143ab.azure-devices.net", "iotc-c0a9999b-d256-4aaf-aa06-e90e999902b3.azure-devices.net", "iotc-f9199991-ceb1-4f38-9f1c-13199992570e.azure-devices.net" ], "DeviceAuthentication": "9abc79eb-9999-43ce-9999-fa8888888894" }, "ApplicationType": "Default" }
Start the app build deploy process.
- Press Ctrl+Shift+P to open the Visual Studio Code command palette.
- Type and select CMake: Select Variant, then select Debug.
- Press F5 to build, deploy, and attach the debugger to the application now running the Azure Sphere device.
-
Open the Visual Studio Code Output tab to view the output from the Log_Debug statements in the code.
Pro Tip. You can open the output window by using the Visual Studio Code Ctrl+K Ctrl+H shortcut or selecting the Output tab.
-
You will see the device negotiating security with Azure IoT Central.
The easiest way to deploy the real-time movement classification app is to deploy the prebuilt image package.
-
From a command prompt, navigate to the AzureSphereClassify folder, then to the image_packages folder.
-
Run the following command to sideload the real-time app.
azsphere device sideload -p FreeRTOS_RTcore_I2C_Accelerometer.imagepackage
You can also deploy the real-time movement classification app to the Azure Sphere using Visual Studio Code.
-
Copy the AzureSphereRTCoreToolchainEdgeImpulse.cmake found in the root of the AzureSphereClassify folder to the Azure Sphere SDK CMakeFiles folder.
- On Windows the Azure Sphere SDK CMakeFiles folder is located at C:\Program Files (x86)\Microsoft Azure Sphere SDK\CMakeFiles.
- On Ubuntu the Azure Sphere SDK CMakeFiles folder is located at /opt/azurespheresdk/CMakeFiles.
-
Open the classifyRT folder with Visual Studio Code.
-
Type and select CMake: Select Variant, then select Release.
-
Press Ctrl+F5 to build and deploy the app to your Azure Sphere device.
The predictive maintenance model was trained with the following gestures.
- Keeping the device horizontal, move the device side to side, this will generate an HVAC rattle prediction.
- Generate an HVAC motor bearings prediction by moving the device with a wave gesture.
- The model has also been trained with an HVAC up and down.
- Switch back to the Azure IoT Central web portal.
- Select Devices from the IoT Central sidebar menu.
- Select the predictive Maintenance template.
- When your device enrolls into IoT Central, you may be prompted to Refresh the device list.
- Select your device, the device details page will open to display the device properties.