Deploy to Azure Sphere
Set up an Azure IoT Hub for Azure Sphere
Follow the instruction to set up an Azure IoT Hub for Azure Sphere. Skip setting up the IoT Hub as it was created in the previous step.
Open the high-level predictive maintenance app
- Start Visual Studio Code
- From the Visual Studio Code main menu, select File, then select Open folder.
- Navigate to the AzureSphere folder you cloned to your computer, then select classifyHL, and open.
Select your Avnet starter kit revision
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.
Configure network and security settings
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:
- AdministratorUpdate the DeviceAuthentication property with your Azure Sphere Tenant ID.
update the CmdArgs property with your Azure DPS ID Scope.
Update the AllowedConnections property with your Azure IoT Hub Hostname.
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",
"<REPLACE_WITH_YOUR_AZURE_DPS_ID_SCOPE>"
],
"Capabilities": {
"I2cMaster": [
"$ISU2_I2C"
],
"Pwm": [
"$PWM_RGB_CONTROLLER"
],
"Adc": [
"$Adc0"
],
"Gpio": [
"$NETWORK_CONNECTED_LED",
"$APP_STATUS_LED",
"$EN",
"$NSL",
"$PH",
"$BUTTON_A",
"$BUTTON_B",
"$RELAY_2",
"$RELAY_EXT"
],
"AllowedConnections": [
"global.azure-devices-provisioning.net",
"<REPLACE_WITH_YOUR_IOT_HUB_HOSTNAME>",
],
"DeviceAuthentication": "<REPLACE_WITH_YOUR_AZURE_SPHERE_TENANT_ID>",
"AllowedApplicationConnections": [
"AF8B26DB-355E-405C-BBDE-3B851668EE23"
]
},
"ApplicationType": "Default"
}
Deploying the predictive maintenance app to Azure Sphere
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.
View debugger output
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.
Deploy the real-time movement classification app
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.
Generate fault prediction data
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.