04 Deploy the solution to Azure Sphere - gloveboxes/AiPoweredPredictiveMaintenance GitHub Wiki

Deploy the predictive maintenance app to Azure Sphere

Clone the predictive maintenance project

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

Open the high-level predictive maintenance app in Visual Studio Code

  1. Start Visual Studio Code
  2. From the Visual Studio Code main menu, select File, then select Open folder.
  3. Navigate to the AzureSphereClassify 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.

  1. Open the CMakeLists.txt file.
  2. Comment out the Avnet Rev 1 board with a #.
  3. Uncomment the Avnet Rev 2 board by removing the leading # character.
  4. Save the changes.

Configure network and security settings

You need the configuration information saved when you completed the List your IoT Central network endpoints.

  1. Open the app_manifest.json file.

  2. Update the CmdArgs property with your IoT Central ID Scope.

  3. 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
  4. Update the DeviceAuthentication property with your Azure Sphere Tenant ID.

  5. Update the AllowedConnections property with the IoT Central Application endpoint URLs you copied to Notepad.

  6. 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"
    }
    

Deploying the predictive maintenance app to Azure Sphere

Start the app build deploy process.

  1. Press Ctrl+Shift+P to open the Visual Studio Code command palette.
  2. Type and select CMake: Select Variant, then select Debug.
  3. Press F5 to build, deploy, and attach the debugger to the application now running the Azure Sphere device.

View debugger output

  1. 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.

  2. 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.

  1. From a command prompt, navigate to the AzureSphereClassify folder, then to the image_packages folder.

  2. 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.

  1. 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.
  2. Open the classifyRT folder with Visual Studio Code.

  3. Type and select CMake: Select Variant, then select Release.

  4. 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.

  1. Keeping the device horizontal, move the device side to side, this will generate an HVAC rattle prediction.
  2. Generate an HVAC motor bearings prediction by moving the device with a wave gesture.
  3. The model has also been trained with an HVAC up and down.

View your device on the IoT Central Dashboard

  1. Switch back to the Azure IoT Central web portal.
  2. Select Devices from the IoT Central sidebar menu.
  3. Select the predictive Maintenance template.
  4. When your device enrolls into IoT Central, you may be prompted to Refresh the device list.
  5. Select your device, the device details page will open to display the device properties.

This image shows the About, Overview and Raw Data tabs

⚠️ **GitHub.com Fallback** ⚠️