Skip to content

Commit 63a1dae

Browse files
committed
Add IoT Edge tutorial
1 parent 6c75d8e commit 63a1dae

File tree

9 files changed

+225
-7
lines changed

9 files changed

+225
-7
lines changed

articles/iot-central/TOC.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
items:
2626
- name: Create and connect a device
2727
href: core/tutorial-connect-device.md
28-
- name: Create a gateway device template
29-
href: core/tutorial-define-gateway-device-type.md
30-
- name: Connect an IoT Edge device
31-
href: /training/modules/connect-iot-edge-device-to-iot-central
3228
- name: Create a device group
3329
href: core/tutorial-use-device-groups.md
30+
- name: Connect an IoT Edge device
31+
href: core/tutorial-connect-iot-edge-device.md
32+
- name: Create a gateway device template
33+
href: core/tutorial-define-gateway-device-type.md
3434
- name: Extend your application
3535
items:
3636
- name: Create a rule
32.3 KB
Loading
51.1 KB
Loading
37.8 KB
Loading
64.8 KB
Loading

articles/iot-central/core/tutorial-connect-device.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ On this view, you can select the columns to display and set a time range to view
9090
If you'd prefer to continue through the set of IoT Central tutorials and learn more about building an IoT Central solution, see:
9191

9292
> [!div class="nextstepaction"]
93-
> [Create a gateway device template](./tutorial-define-gateway-device-type.md)
93+
> [Tutorial: Use device groups to analyze device telemetry](tutorial-use-device-groups.md)
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
---
2+
title: Tutorial - Connect an IoT Edge device to Azure IoT Central | Microsoft Docs
3+
description: This tutorial shows you how to connect an IoT Edge device to your IoT Central application. You first create an unassigned device, and then add a device template to enable views and forms for an operator to be able to interact with the device.
4+
author: dominicbetts
5+
ms.author: dobett
6+
ms.date: 10/18/2022
7+
ms.topic: tutorial
8+
ms.service: iot-central
9+
services: iot-central
10+
ms.custom: [device-developer]
11+
12+
# Customer intent: As a solution developer, I want to learn how to connect an IoT Edge device to IoT Central and then configure views and forms so that I can interact with the device.
13+
---
14+
15+
# Tutorial: Connect an IoT Edge device to your Azure IoT Central application
16+
17+
This tutorial shows you how to connect an IoT Edge device to your Azure IoT Central application. The IoT Edge device runs a module that sends temperature, pressure, and humidity telemetry to your application. You use a device template to enable views and forms that let you interact with the module on the IoT Edge device.
18+
19+
In this tutorial, you learn how to:
20+
21+
> [!div class="checklist"]
22+
> * Import an IoT Edge deployment manifest into your IoT Central application.
23+
> * Add an IoT Edge device that uses this deployment manifest to your application.
24+
> * Connect the IoT Edge device to your application.
25+
> * Monitor the IoT Edge runtime from your application.
26+
> * Add a device template with views and forms to your application.
27+
> * View the telemetry sent from the device in your application.
28+
29+
## Prerequisites
30+
31+
To complete the steps in this tutorial, you need:
32+
33+
[!INCLUDE [iot-central-prerequisites-basic](../../includes/iot-central-prerequisites-basic.md)]
34+
35+
You also need to be able to upload configuration files to your IoT Central application from your local machine.
36+
37+
## Import a deployment manifest
38+
39+
A deployment manifest specifies the configuration of an IoT Edge device including the details of any custom modules the device should download and run. IoT Edge devices that connect to an IoT Central application download their deployment manifests from the application.
40+
41+
To add a deployment manifest to IoT Central to use in this tutorial:
42+
43+
1. Download and save the [EnvironmentalSensorManifest-1-4.json](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/iotedge/EnvironmentalSensorManifest-1-4.json) deployment manifest to your local machine.
44+
45+
1. In your IoT Central application, navigate to the **Edge manifests** page.
46+
47+
1. Select **+ New**.
48+
49+
1. On the **Customize** page, enter *Environmental Sensor* as the name and then upload the *EnvironmentalSensorManifest-1-4.json* file.
50+
51+
1. After the manifest file is validated, select **Next**.
52+
53+
1. The **Review and finish** page shows the modules defined in the manifest, including the **SimulatedTemperatureSensor** custom module. Select **Create**.
54+
55+
The **Edge manifests** list now includes the **Environmental sensor** manifest:
56+
57+
:::image type="content" source="media/tutorial-connect-iot-edge-device/deployment-manifests.png" alt-text="Screenshot that shows the Edge Manifests list in the application.":::
58+
59+
## Add an IoT Edge device
60+
61+
Before the IoT Edge device can connect to your IoT Central application, you need to add it to the list of devices and get its credentials:
62+
63+
1. In your IoT Central application, navigate to the **Devices** page.
64+
65+
1. On the **Devices** page, make sure that **All devices** is selected. Then select **+ New**.
66+
67+
1. On the **Create a new device** page:
68+
* Enter *Environmental sensor - 001* as the device name.
69+
* Enter *env-sens-001* as the device ID.
70+
* Make sure that the device template is **unassigned**.
71+
* Make sure that the device isn't simulated.
72+
* Set **Azure IoT Edge device** to **Yes**.
73+
* Select the **Environmental sensor** IoT Edge deployment manifest.
74+
75+
1. Select **Create**.
76+
77+
The list of devices on the **Devices** page now includes the **Environmental sensor - 001** device. The device status is **Registered**:
78+
79+
:::image type="content" source="media/tutorial-connect-iot-edge-device/registered-sensor-device.png" alt-text="Screenshot that shows the registered and unassigned IoT Edge device.":::
80+
81+
Before you deploy the IoT Edge device, you need the:
82+
83+
* **ID Scope** of your IoT Central application.
84+
* **Device ID** values for the gateway and downstream devices.
85+
* **Primary key** values for the gateway and downstream devices.
86+
87+
To find these values, navigate to the **Environmental sensor - 001** device from the **Devices** page and select **Connect**. Make a note of these values before you continue.
88+
89+
## Deploy the IoT Edge device
90+
91+
In this tutorial, you deploy the IoT Edge runtime to a Linux virtual machine in Azure. To deploy and configure the virtual machine, select the following button:
92+
93+
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmaster%2Fedge-vm-deploy-1-4%2FedgeDeploy.json)
94+
95+
On the **Custom deployment** page, use the following values to complete the form:
96+
97+
| Setting | Value |
98+
| ------- | ----- |
99+
| `Resource group` | Create a new resource group with a name such as *MyIoTEdgeDevice_rg*. |
100+
| `Region` | Select a region close to you. |
101+
| `Dns Label Prefix` | A unique DNS prefix for your virtual machine. |
102+
| `Admin Username` | *AzureUser* |
103+
| `Admin Password` | A password of your choice to access the virtual machine. |
104+
| `Scope Id` | The ID scope you made a note of previously. |
105+
| `Device Id` | The device ID you made a note of previously. |
106+
| `Device Key` | The device key you made a note of previously. |
107+
108+
Select **Review + create** and then **Create**. Wait for the deployment to finish before you continue.
109+
110+
## Manage the IoT Edge device
111+
112+
To verify the deployment of the IoT Edge device was successful:
113+
114+
1. In your IoT Central application, navigate to the **Devices** page. Check the status of the **Environmental sensor - 001** device is **Provisioned**. You may need to wait for a few minutes while the device connects.
115+
116+
1. Navigate to the **Environmental sensor - 001** device.
117+
118+
1. On the **Modules** page, check the status of the three modules is **Running**.
119+
120+
On the **Modules** page, you can view status information about the modules and perform actions such as viewing their logs and restarting them.
121+
122+
## View raw data
123+
124+
On the **Raw data** page for the **Environmental sensor - 001** device, you can see the telemetry it's sending and the property values it's reporting.
125+
126+
At the moment, the IoT Edge device doesn't have a device template assigned, so all the data from the device is **Unmodeled**. Without a device template, there are no views or dashboards to display custom device information in the IoT Central application. However, you can use data export to forward the data to other services for analysis or storage.
127+
128+
## Add a device template
129+
130+
A deployment manifest may include definitions of properties exposed by a module. For example, the configuration in the deployment manifest for the **SimulatedTemperatureSensor** module includes the following:
131+
132+
```json
133+
"SimulatedTemperatureSensor": {
134+
"properties.desired": {
135+
"SendData": true,
136+
"SendInterval": 10
137+
}
138+
}
139+
```
140+
141+
The following steps show you how to add a device template for an IoT Edge device and the module property definitions from the deployment manifest:
142+
143+
1. In your IoT Central application, navigate to the **Device templates** page and select **+ New**.
144+
145+
1. On the **Select type** page, select **Azure IoT Edge**, and then **Next: Customize**.
146+
147+
1. On the **Customize** page, enter **Environmental sensor** as the device template name.
148+
149+
1. On the **Review** page, select **Create**.
150+
151+
1. On the **Create a model** page, select **Custom model**.
152+
153+
1. On the **Environmental sensor** page, select **Modules**, then **Import modules from manifest**.
154+
155+
1. In the **Import modules** dialog, select the **Environmental sensor** deployment manifest, then **Import**.
156+
157+
The device template now includes a module called **SimulatedTemperatureSensor**, with an interface called **management**. This interface includes definitions of the **SendData** and **SendInterval** properties from the deployment manifest.
158+
159+
A deployment manifest can only define module properties, not commands or telemetry. To add the telemetry definitions to the device template:
160+
161+
1. Download and save the [EnvironmentalSensorTelemetry.json](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/iotedge/EnvironmentalSensorTelemetry.json) interface definition to your local machine.
162+
163+
1. Navigate to the **SimulatedTemperatureSensor** module in the **Environmental sensor** device template.
164+
165+
1. Select **Add inherited interface** (you may need to select **...** to see this option). Select **Import interface**. Then import the *EnvironmentalSensorTelemetry.json* file you previously downloaded.
166+
167+
The module now includes a **telemetry** interface that defines **machine**, **ambient**, and **timeCreated** telemetry types:
168+
169+
:::image type="content" source="media/tutorial-connect-iot-edge-device/telemetry-interface.png" alt-text="Screenshot that shows the device template with the telemetry interface.":::
170+
171+
To add some forms and views to enable you to manage the device and view the telemetry:
172+
173+
1. In the **Environmental sensor** device template, select **Views**.
174+
175+
1. On the **Select to add a new view** page, select **Visualizing the device**.
176+
177+
1. Enter *Environmental telemetry* as the view name.
178+
179+
1. Select **Start with devices**. Then add the following telemetry types:
180+
* **ambient/temperature**
181+
* **humidity**
182+
* **machine/temperature**
183+
* **pressure**
184+
185+
1. Select **Add tile**, then **Save**.
186+
187+
1. To publish the template, select **Publish**.
188+
189+
## View telemetry
190+
191+
To view the telemetry from your device, you need to attach the device to the device template:
192+
193+
1. Navigate to the **Devices** page and select the **Environmental sensor - 001** device.
194+
195+
1. Select **Migrate**.
196+
197+
1. In the **Migrate** dialog, select the **Environmental sensor** device template, and select **Migrate**.
198+
199+
1. Navigate to the **Environmental sensor - 001** device and select the **Environmental telemetry** view.
200+
201+
1. The line chart plots the four telemetry values you selected for the view:
202+
203+
:::image type="content" source="media/tutorial-connect-iot-edge-device/environmental-telemetry-view.png" alt-text="Screenshot that shows the telemetry line charts.":::
204+
205+
1. The **Raw data** page now includes columns for the:
206+
* **ambient**, **machine**, and **timeCreated** telemetry values.
207+
* **SendData** and **SendInterval** properties.
208+
209+
## Clean up resources
210+
211+
[!INCLUDE [iot-central-clean-up-resources](../../../includes/iot-central-clean-up-resources.md)]
212+
213+
## Next steps
214+
215+
If you'd prefer to continue through the set of IoT Central tutorials and learn more about building an IoT Central solution, see:
216+
217+
> [!div class="nextstepaction"]
218+
> [Create a gateway device template](./tutorial-define-gateway-device-type.md)

articles/iot-central/core/tutorial-define-gateway-device-type.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,4 @@ In this tutorial, you learned how to:
329329
Next you can learn how to:
330330

331331
> [!div class="nextstepaction"]
332-
> [Add an Azure IoT Edge device to your Azure IoT Central application](/training/modules/connect-iot-edge-device-to-iot-central/)
332+
> [Create a rule and set up notifications in your Azure IoT Central application](tutorial-create-telemetry-rules.md)

articles/iot-central/core/tutorial-use-device-groups.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ To learn more about analytics, see [How to use data explorer to analyze device d
126126
Now that you've learned how to use device groups in your Azure IoT Central application, here is the suggested next step:
127127

128128
> [!div class="nextstepaction"]
129-
> [How to create telemetry rules](tutorial-create-telemetry-rules.md)
129+
> [Connect an IoT Edge device to your Azure IoT Central application](tutorial-connect-iot-edge-device.md)

0 commit comments

Comments
 (0)