Connect an IoT DevKit device to the Remote Monitoring solution accelerator

In this tutorial, you implement a Chiller device that sends the following telemetry to the Remote Monitoring solution accelerator:

  • Temperature
  • Pressure
  • Humidity

For simplicity, the code generates sample telemetry values for the Chiller. You could extend the sample by connecting real sensors to your device and sending real telemetry.

The sample device also:

  • Sends metadata to the solution to describe its capabilities.
  • Responds to actions triggered from the Devices page in the solution.
  • Responds to configuration changes send from the Devices page in the solution.

To complete this tutorial, you need an active Azure account. If you don't have an account, you can create a free trial account in just a couple of minutes. For details, see Azure Free Trial.

Before you start

Before you write any code for your device, deploy your Remote Monitoring solution accelerator and add a new real device to the solution.

Deploy your Remote Monitoring solution accelerator

The Chiller device you create in this tutorial sends data to an instance of the Remote Monitoring solution accelerator. If you haven't already provisioned the Remote Monitoring solution accelerator in your Azure account, see Deploy the Remote Monitoring solution accelerator

When the deployment process for the Remote Monitoring solution finishes, click Launch to open the solution dashboard in your browser.

The solution dashboard

Add your device to the Remote Monitoring solution

Note

If you have already added a device in your solution, you can skip this step. However, the next step requires your device connection string. You can retrieve a device's connection string from the Azure portal or using the az iot CLI tool.

For a device to connect to the solution accelerator, it must identify itself to IoT Hub using valid credentials. You have the opportunity to save the device connection string that contains these credentials when you add the device to the solution. You include the device connection string in your client application later in this tutorial.

To add a device to your Remote Monitoring solution, complete the following steps on the Device Explorer page in the solution:

  1. Choose + New device, and then choose Real as the Device type:

    Add a real device

  2. Enter Physical-chiller as the Device ID. Choose the Symmetric Key and Auto generate keys options:

    Choose device options

  3. Choose Apply. Then make a note of the Device ID, Primary Key, and Connection string primary key values:

    Retrieve credentials

You've now added a real device to the Remote Monitoring solution accelerator and noted its device connection string. In the following sections, you implement the client application that uses the device connection string to connect to your solution.

The client application implements the built-in Chiller device model. A solution accelerator device model specifies the following about a device:

  • The properties the device reports to the solution. For example, a Chiller device reports information about its firmware and location.
  • The types of telemetry the device sends to the solution. For example, a Chiller device sends temperature, humidity, and pressure values.
  • The methods you can schedule from the solution to run on the device. For example, a Chiller device must implement Reboot, FirmwareUpdate, EmergencyValveRelease, and IncreasePressure methods.

This how-to guide shows you how to run a sample application on your IoT DevKit device. The sample code sends telemetry from the sensors on the DevKit device to your solution accelerator.

The MXChip IoT DevKit is an all-in-one Arduino compatible board with rich peripherals and sensors. You can develop for it using Azure IoT Device Workbench or Azure IoT Tools extension pack in Visual Studio Code. The projects catalog contains sample applications to help you prototype IoT solutions.

Before you begin

To complete the steps in this tutorial, first do the following tasks:

Open sample project

To open the Remote Monitoring sample in VS Code:

  1. Make sure your IoT DevKit isn't to your computer. Start VS Code first, and then connect the DevKit to your computer.

  2. Click F1 to open the command palette, type and select Azure IoT Device Workbench: Open Examples.... Then select IoT DevKit as board.

  3. Find Remote Monitoring and click Open Sample. A new VS Code window opens showing the project folder:

    IoT Workbench, select Remote Monitoring example

Configure the device

To configure IoT Hub device connection string on your DevKit device:

  1. Switch the IoT DevKit into Configuration mode:

    • Hold down button A.
    • Push and release the Reset button.
  2. The screen displays the DevKit ID and Configuration.

    IoT DevKit Configuration Mode

  3. Press F1 to open the command palette, type and select Azure IoT Device Workbench: Configure Device Settings... > Config Device Connection String.

  4. Paste the connection string you copied previously and press Enter to configure the device.

Build the code

To build and upload the device code:

  1. Press F1 to open the command palette, type and select Azure IoT Device Workbench: Upload Device Code:

  2. VS Code compiles and uploads the code to your DevKit device:

    IoT Workbench: Device - > Uploaded

  3. The DevKit device reboots and runs the code you uploaded.

Test the sample

To verify that the sample application you uploaded to the DevKit device is working, complete the following steps:

View the telemetry sent to Remote Monitoring solution

When the sample app runs, the DevKit device sends telemetry from its sensors data over Wi-Fi to your solution accelerator. To see the telemetry:

  1. Go to your solution dashboard, and click Device Explorer.

  2. Click on the device name of your DevKit device. on the right-hand tab, you can see the telemetry from the DevKit in real time:

    Sensor data in Azure IoT Suite

Control the DevKit device

The Remote Monitoring solution accelerator lets you control your device remotely. The sample code implements three methods that you can see in the Method section when you select the device on the Device Explorer page:

IoT DevKit Methods

To change the color of one of the DevKit LEDs, use the LedColor method:

  1. Select the device name from device list and click on the Jobs:

    Create a Job

  2. Configure the Jobs using the following values and click Apply:

    • Select Job: Run method

    • Method name: LedColor

    • Job Name: ChangeLedColor

      Job settings

  3. After a couple of seconds, the color of the RGB LED (below the button A) on your DevKit changes:

    IoT DevKit red led

Clean up resources

If you plan to move on to the tutorials, leave the Remote Monitoring solution accelerator deployed.

If you no longer need the solution accelerator, delete it from the Provisioned solutions page, by selecting it, and then clicking Delete Solution:

Delete solution

Problems and feedback

If you run into any problems, refer to the IoT DevKit FAQs or reach out to us using the following channels:

Next steps

Now that you've learned how to connect a DevKit device to your Remote Monitoring solution accelerator, here are some suggested next steps: