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
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.
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:
2. Configure the Azure Sphere tenant certificate into Azure IoT Central
Azure Sphere tenant certificate acquisition command:
Download the Azure Sphere tenant certificate:
azsphere tenant download-CA-certificate --output C:\CAcertificate.cer
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
3. Create a device template in Azure IoT Central
Choose IoT device, next step
Click the next step directly as shown below:
Click the next step directly as shown below:
After entering the name, click Custom
Click Add Interface:
Click on the custom interface:
Click to add function:
Enter the relevant information of "Temperature" and click Save;
Click on the upper right corner to post:
After adding, you can see the Azure Sphere grouping in the device:
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!
Update the prompted configuration file to the code:
Compile the project:
Compile CMakelist.txt (right mouse button)
Select GDB Debugeger (HL Core) and start debugging
After running, you can see the following OK results, indicating successful connection to IoT Central:
You can see the devices automatically registered in IoT Central:
Click Migrate to migrate it to the Azure shpere template, that is, bind the physical device to the device template.
Edit the dashboard, set as follows:
After saving, refresh the home page to see the effect:
5. Create alarm rules in IoT Central;
When the conditions are met, you can receive the alarm email:
Other content in this series:
(Video) Learn Azure Sphere together (1)-What is Azure Sphere
(Video) Learn Azure Sphere (3)-Advanced program for local development and debugging
(Video) Learn Azure Sphere together (5)-Provision Azure Sphere to Azure China IoT Hub