title | description | author | manager | ms.service | services | ms.topic | ms.tgt_pltfrm | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|
Use Azure device twins to control MXChip IoT DevKit user LED | Microsoft Docs |
In this tutorial, learn how to monitor DevKit states and control the user LED with Azure IoT Hub device twins. |
liydu |
jeffya |
iot-hub |
iot-hub |
conceptual |
arduino |
04/04/2018 |
liydu |
You can use this example to monitor the MXChip IoT DevKit WiFi information and sensor states and to control the color of the user LED using Azure IoT Hub device twins.
-
How to monitor the MXChip IoT DevKit sensor states.
-
How to use Azure device twins to control the color of the DevKit's RGB LED.
-
Set up your development environment by following the Getting Started Guide.
-
From your GitBash terminal window (or other Git command-line interface), type the following commands:
git clone https://github.com/DevKitExamples/DevKitState.git cd DevKitState code .
-
Click the Tasks drop-down menu in Visual Studio Code and select Run Task... - cloud-provision.
-
Your progress is displayed under the TERMINAL tab of the Welcome panel.
-
When prompted with the message What subscription would you like to choose, select a subscription.
-
Select or choose a resource group.
[!NOTE] If you already have a free IoT Hub, you can skip this step.
-
When prompted with the message What IoT hub would you like to choose, select or create an IoT Hub.
-
Something similar to function app: function app name: xxx, is displayed. Write down the function app name; it will be used in a later step.
-
Wait for the Azure Resource Manager template deployment to finish, which is indicated when the message Resource Manager template deployment: Done is displayed.
-
Click the Tasks drop-down menu in Visual Studio Code and select Run Task... - cloud-deploy.
-
Wait for function app code uploading process to finish; the message function app deploys: Done is displayed.
-
Connect your MXChip IoT DevKit to your computer.
-
Click the Tasks drop-down menu in Visual Studio Code and select Run Task... - config-device-connection
-
On the MXChip IoT DevKit, press and hold button A, press the Reset button, and then release button A to make the DekKit enter configuration mode.
-
Wait for connection string configuration process to be completed.
With your MXChip IoT DevKit connected to your computer:
-
Click the Tasks drop-down menu in Visual Studio Code and select Run Build Task... The Arduino sketch is compiled and uploaded to the DevKit.
-
When the sketch has been uploaded successfully, a Build & Upload Sketch: success message is displayed.
-
In a Web browser, open the
DevKitState\web\index.html
file--which was created during the What you need step. -
Input the function app name you wrote down earlier.
-
Click the Connect button
-
Within a few seconds, the page refreshes and displays the DevKit's WiFi connection status and the state of each of the onboard sensors.
-
Click the user LED graphic on the Web page illustration.
-
Within a few seconds, the screen refreshes and shows the current color status of the user LED.
-
Try changing the color value of the RGB LED by clicking in various locations on the RGB slider controls.
Note
You can see raw data of device twin in Azure portal: IoT Hub -> IoT devices -> <your device> -> Device Twin.
You have learned how to:
- Connect an MXChip IoT DevKit device to your Azure IoT Remote Monitoring solution accelerator.
- Use the Azure IoT device twins function to sense and control the color of the DevKit's RGB LED.
Here are the suggested next steps: