Azure Sphere (6)-Connect to Azure IoT Central within 30 minutes

This article introduces:

Connect Azure Sphere to Azure IoT Central and display basic charts within 30 minutes

This section mainly focuses on practical operations and does not explain too much about Azure IoT Central. Azure IoT Central will be introduced separately in subsequent chapters.

 

Steps in this article:

1. Create Azure IoT Central;

2. Configure the Azure Sphere tenant certificate into Azure IoT Central;

3. Create a device template in Azure IoT Central;

4. Debug Azure Sphere advanced program in Visual Studio and configure DPS to connect to Azure IoT Central;

5. Create alarm rules in IoT Central;

 

Video explanation:

You can watch the video explanation of this article at Station B: https://www.bilibili.com/video/BV1D54y1R7Z3/

 

Graphic explanation (video explanation is more detailed):

Note: The configuration steps of the case in this article, especially the device template part, only apply to Azure Sphere's default Azure IoT central demo. If you are designing other products, such as temperature and humidity meters, etc., you need to design according to your actual product!

The sample code for this example is the same as the previous section, please see: https://github.com/Azure/azure-sphere-samples

1. Create Azure IoT Central

img-f3b392d7-450f-4809-a11a-75f84cd7b09d.png

 

 

Fill in the name, select the pricing tier, select the location, in this example select the Asia Pacific region closest to us.

There are some preset templates for specific scenes in the template for you to choose. In this example, we choose a custom application.

img-9e83d7c0-9e94-4615-8a4a-2e0d9ac3ab03.png

The pricing reference is as follows:

New customers have a 7-day free trial layer, in addition to:

Pricing layer Standard layer 1 Standard layer 2
example Suitable for devices that send a small amount of messages every hour Suitable for devices that send messages every few minutes
Price per device $ 0.4 per month  $ 0.7 per month 
Monthly device message distribution * 5,000 messages 30,000 messages
Free number included in each IoT Central app 2 free devices (including 10,000 messages) 2 free devices (including 60,000 messages)
Exceed the monthly distribution of messages over the use of the price of 1 $ 0.015 per 1K messages  $ 0.015 per 1K messages 

*  Total number of message distributions shared across all devices in the IoT Central application

1 The  standard message size is 4 KB. For example, if the device sends a 4.5 KB message, it is billed as 2 messages.

After the creation is complete, click on the connection below to enter the main interface:

img-87183b56-a45a-4233-9103-91479f419641.png

 

2. Configure the Azure Sphere tenant certificate into Azure IoT Central

 

img-8a9049f3-49c2-478a-be01-f089100ad79f.png

Azure Sphere tenant certificate acquisition command:

Download the Azure Sphere tenant certificate:

azsphere tenant download-CA-certificate --output C:\CAcertificate.cer

img-dfdaced8-0bea-4889-a734-a9e6fefa8e5e.png

 

img-f7689c56-061c-4bb9-bd99-7b1aaf181e6a.png

Use the following command to generate a verification certificate with a verification code, and then click the verification button in the figure above to upload the verification certificate.

Obtain a verification certificate:

azsphere tenant download-validation-certificate --output C:\ValidationCertification.cer --verificationcode codeXXXXX

 

img-ed6dd5b5-63d2-4589-9867-70d3fdf09612.png

 

3. Create a device template in Azure IoT Central

Choose IoT device, next step

img-94138f8f-9029-45c7-8218-8b42a30ee753.png

Click the next step directly as shown below:

img-766765cf-4f36-4432-8c4a-42bd4c3b25aa.png

 

Click the next step directly as shown below:

img-a0d3d5ef-cf96-4d73-9b7b-b65078c119d3.png

 

 

 

 

After entering the name, click  Custom

img-6b14d7ac-1672-4bd9-a0ca-9515d3973f48.png

 

Click Add Interface:

img-b6ff6f6a-14c7-4683-8c26-575be52cd542.png

Click on the custom interface:

img-8c2f40b3-f45d-469b-868e-2c7c1f0a4c20.png

Click to add function:

img-2b010bb6-232c-4530-92d9-3acd255f33f1.png

 

Enter the relevant information of "Temperature" and click Save;

Click on the upper right corner to post:

img-3d764669-d01c-455d-89bf-e14aa19ceec8.png

After adding, you can see the Azure Sphere grouping in the device:

img-adc19e3e-daa7-4998-8346-6dd1f437e0e0.png

4. Debug Azure Sphere advanced program in Visual Studio and configure DPS to connect to Azure IoT Central

Focus on the key, in the Tools path in the sample code , execute the ShowIoTContralConfig command, and follow the prompts to obtain the required values ​​in the json configuration file.

One API Token can be created!

img-03d9f7d1-2580-49fa-b4bd-f1b97a8b89a9.png

Update the prompted configuration file to the code:

img-6b2b31f7-aac0-439a-b381-99b46a1c2c11.png

Compile the project:

img-1a5786d2-c659-44e0-a5ab-0a1a92e94045.png

Compile CMakelist.txt (right mouse button)

img-43b47d82-d9b1-4e13-b3df-795a9830e76b.png

Select GDB Debugeger (HL Core) and start debugging

img-aee14986-45ab-4795-94d4-f586bf206432.png

After running, you can see the following OK results, indicating successful connection to IoT Central:

img-5ed21b2a-2ebf-4b7e-ac87-77ec578f6cc4.png

You can see the devices automatically registered in IoT Central:

img-126e9e50-a399-432c-88e8-a3f6050a6c16.png

 

Click Migrate to migrate it to the Azure shpere template, that is, bind the physical device to the device template.

img-664faf65-dbb4-4292-94ff-dd1eee4c0744.png

 

Edit the dashboard, set as follows:

img-5920dd7c-e6ad-4ab4-aada-77436c2bc98e.png

After saving, refresh the home page to see the effect:

img-31e652b9-2b32-474d-964d-826cd85b7189.png

5. Create alarm rules in IoT Central;

img-8698a7a7-e3ce-483f-8574-c0f548e116af.png

When the conditions are met, you can receive the alarm email:

img-d3c485b0-7586-4a07-a51a-84ca8f53bee3.png

 

 

Other content in this series:

  1. (Video) Learn Azure Sphere together (1)-What is Azure Sphere

  2. (Video) Learn Azure Sphere together (2)-Prepare Azure Sphere development environment and declare equipment

  3. (Video) Learn Azure Sphere (3)-Advanced program for local development and debugging

  4. (Video) Learn Azure Sphere together (4)-Register Azure Sphere to Azure IoT Hub through DPS and send telemetry messages

  5. (Video) Learn Azure Sphere together (5)-Provision Azure Sphere to Azure China IoT Hub

  6. (Video) Learn Azure Sphere together (6)-Connect Azure Sphere to Azure IoT Central and display basic diagrams in 30 minutes

 


Guess you like

Origin blog.51cto.com/10117438/2486631