In this tutorial, you learn how to run a sample app on your DevKit to send sensor data to your Azure IoT Suite.

What you need

Finish the Getting Started Guide to:

  • Have your DevKit connected to Wi-Fi
  • Prepare the development environment

An active Azure subscription. If you do not have one, you can register via one of these two methods:

Step 1. Create an Azure IoT Suite

  1. Go to Azure IoT Suite site and click Create a new solution.

remote-monitoring-azure-iot-suite-solution-types

Notice: By default, this creates an S2 IoT Hub after it creates one IoT Suite. If this IoT hub will not be used with massive number of devices, we highly recommend you downgrade it from S2 to S1, and delete the IoT Suite–the IoT Hub will also be deleted–when you no longer need it. This will save you money:).

  1. Select Remote monitoring.

  2. Enter a solution name, select a subscription and a region, and then click Create solution. The solution may take a while to be provisioned.

remote-monitoring-azure-iot-suite-new-solution

  1. After the provision is completed, click Launch. Some simulated devices are created for the solution during the provision process. Click DEVICES to check them out.

remote-monitoring-azure-iot-suite-new-solution-created

remote-monitoring-azure-iot-suite-console

  1. Click ADD A DEVICE.

  2. Click Add New for Custom Device.

remote-monitoring-azure-iot-suite-add-new-device

  1. Click Let me define my own Device ID, enter AZ3166, and then click Create.

remote-monitoring-azure-iot-suite-new-device-configuration

  1. Make a note of IoT Hub Hostname, and click Done.

Step 2. Open the RemoteMonitoring sample

  1. Disconnect the DevKit from your computer, if it is connected.

  2. Start VS Code.

  3. Connect the DevKit to your computer. VS Code automatically detects your DevKit and opens the following pages:
    • The DevKit introduction page.
    • Arduino Examples: Hands-on samples to get started with DevKit.
  4. Expand left side ARDUINO EXAMPLES section, browse to Examples for MXCHIP AZ3166 > AzureIoT, and select RemoteMonitoring. This will open a new VS Code window with a project folder in it.

mini-solution-vscode

If you happen to close the pane, you can reopen it. Use Ctrl+Shift+P (macOS: Cmd+Shift+P) to open the command palette, type Arduino, and then find and select Arduino: Examples.

Step 3. Provision required Azure services

In the solution window, run your task through Ctrl+P (macOS: Cmd+P) by entering task cloud-provision in the provided text box:

In the VS Code terminal, an interactive command line guides you through provisioning the required Azure services:

remote-monitoring-provision

Notice: If the page hangs in the loading status when trying to sign in to Azure, please check this FAQ steps to resolve the issue.

Step 4. Build and upload the device code

Windows

  1. Use Ctrl+P to run task device-upload.
  2. The terminal prompts you to enter configuration mode. To do so, hold down button A, then push and release the reset button. The screen displays the DevKit id and ‘Configuration’.

This sets the connection string that is retrieved from the task cloud-provision step.

VS Code then starts verifying and uploading the Arduino sketch to the DevKit:

device-upload

The DevKit reboots and starts running the code.

Notice: Occasionally, you may get an “Error: AZ3166: Unknown package” error message. This occurs when the board package index is not refreshed correctly. Check this FAQ steps to resolve this issue.

macOS

  1. Put the DevKit into configuration mode: Hold down button A, then push and release the reset button. The screen displays ‘Configuration’.
  2. Use Cmd+P to run task device-upload.

This sets the connection string that is retrieved from the task cloud-provision step.

It then starts verifying and uploading the Arduino sketch to the DevKit:

device-upload

The DevKit reboots and starts running the code.

Notice: Occasionally, you may get an “Error: AZ3166: Unknown package” error message. This occurs when the board package index is not refreshed correctly. Check this FAQ steps to resolve the issue.

Test the project

When the sample app runs, DevKit sends sensor data over Wi-Fi to your Azure IoT Suite. To see the result, follow these steps:

  1. Go to your Azure IoT Suite, and click DASHBOARD.

  2. On the Azure IoT Suite solution console, you will see your DevKit sensor status.

Connect to Wi-Fi Send sensor data View sensor status
View sensor information within Azure IoT Suite.

Problems and feedback

If you encounter problems, please refer to FAQs or reach out to us from the channels below.

Updated: