一起學Azure Sphere(4)- 將Azure Sphere 通過DPS註冊到Azure Io

本文包含如下內容:

一.  使用Azure Sphere SDK 獲取CA證書並配置到Azure IoT Hub DPS服務;

      創建IoT Hub;

      創建DPS;

      通過Azure Sphere SDK獲取證書並上傳到DPS進行驗證。

二. 使用示例高級應用程序部署到Azure Sphere開發板並上報數據到IoT Hub;

     Visual studio 進行環境準備:(需卸載上節內容中的Azure Sphere SDK,然後重新安裝Azure Sphere SDK For Visual studio)

     在Visual studio 中編譯項目並進行調試;

     在DPS註冊組和IoT Hub中進行檢查;

     在Azure IoT Hub explorer中觀察設備到雲的數據。

 

視頻講解:

您可以在B站觀看本節視頻講解:https://www.bilibili.com/video/av98475432/

或在本站觀看:

 

圖文講解:

一.  使用Azure Sphere SDK 獲取CA證書並配置到Azure IoT Hub DPS服務;

      創建IoT Hub;

      創建DPS;

      通過Azure Sphere SDK獲取證書並上傳到DPS進行驗證。

關鍵步驟:

下載Azure Sphere 租戶證書:

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

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

獲取驗證證書:

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

 

img-94aea564-c88a-4718-8b32-fcd07c73a9b3.png

 

img-9280d951-17af-4369-ba1f-42979c69947f.png

 

img-8d07f312-cae5-4d49-9e63-972e2e24fc87.png

 

img-e9f73e0c-3d3a-4efb-a1c4-c08d59292182.png

 

 

img-29ed752f-3df2-458e-98cf-ba4bbc09442d.png

 

img-efe4c6a5-8b31-4bd4-8d5e-1765f79ab6bc.png

如下圖驗證通過。

img-a098329c-7bb5-45f8-9c66-b785979f909c.png

 

創建組註冊:

img-45199cee-6719-4cf8-9219-5abedac21e6c.png

 

創建組註冊:

img-845f95c3-abf3-40a4-a1fb-1fb9cd692d9d.png

 

二. 使用示例高級應用程序部署到Azure Sphere開發板並上報數據到IoT Hub;

     Visual studio 進行環境準備:(需卸載上節內容中的Azure Sphere SDK,然後重新安裝Azure Sphere SDK For Visual studio)

     在Visual studio 中編譯項目並進行調試;

     在DPS註冊組和IoT Hub中進行檢查;

     在Azure IoT Hub explorer中觀察設備到雲的數據。

 

注意,本步驟需要卸載上一講當中的Azure Sphere SDK for windows, 然後安裝Azure Sphere SDK for Visual studio 

示例代碼中如下位置需要修改:

img-531b16b7-faca-4ad7-bc51-ef583b5ae9d2.png

 

編譯項目:

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

編譯CMakelist.txt(鼠標右鍵)

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

選擇GDB Debugeger(HL Core) 並開始調試

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

 

編譯之後,可以看到已經開始向IoT Hub 發送遙測消息了:

img-8b35180c-4f0e-4c78-9171-5397ce2e36d6.png

 

在Iot Hub DPS 檢查組註冊記錄:

img-2ffbf31a-05bf-41f9-99f1-5755744427d5.png

 

在IoT Hub Device中檢查Device記錄:

img-3e5a3a0f-4dd4-43e9-9ee3-673c8ae3d5be.png

 

使用Azure IoT Hub Explorer 中查閱D2C 消息

img-33d9f8cb-f87c-4668-9853-6dcee9405c19.png

 

 

 

本節中,關於Azure IoT Hub DPS的內容,請參見:

Azure 智能雲 之 Azure IoT DPS 十分鐘中級系列文章目錄


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章