当前位置:网站首页>詳細些介紹如何通過MQTT協議和華為雲物聯網進行通信
詳細些介紹如何通過MQTT協議和華為雲物聯網進行通信
2022-07-03 01:59:00 【Aaron-ywl】
一、創建產品
首先登進華為雲官網地址:華為雲官網
進入主頁面後,搜索物聯網
選擇lotDA進入
點擊立即使用
然後在總覽頁面點擊平臺接入地址
從這裏可以看到華為雲物聯網MQTT協議端口號也域名地址
然後在產品一欄點擊創建產品
根據提示填寫信息
二、設備注册
在產品的所有設備一欄點擊注册設備
根據提示填寫信息
設置完後會生成信息,下載好保存!
這是我的設備信息
設備信息:
所屬資源空間:DefaultApp_62afp4qr
設備標識(device_id):aaron_1
設備標識碼:sep8266_iot
設備密鑰(secret):1531149131263
{
“device_id”: “aaron_1
”,
“secret”: “1531149131263
”
}
三、產品模型定義
點擊查看產品中創建好的設備
選擇自定義模型
添加服務
接下來就是添加屬性嗎,屬性就是傳感器上傳的數據類型,需要展示的數據;根據自己的傳感器數量、類型自己定義即可。
四、生成MQTT登錄密匙
創建完產品和設備後,我們接下來要使用MQTT協議來登錄華為雲服務器,詳細官方地址:使用MQTT.fx調測
這是參數解析
MQTT設備登錄密匙生成地址:在線生成MQTT密匙
填好之前下載好的信息,包括device_id和secret.
到這裏我們就得到了MQTT協議設備登錄的參數。
五、使用MQTT客戶端軟件登錄
到目前為止,所有參數都已經得到了,接下來采用MQTT客戶端登錄華為雲進行通信。
打開MQTT客服端,具體下載轉接:MQTT客戶端v2.4(協議3.1.1).exe
華為雲物聯網平臺的域名是:a161a58a78.iot-mqtts.cn-north-4.myhuaweicloud.com
華為雲物聯網平臺的IP地址是: 121.36.42.100
MQTT客戶端、用戶名、登陸密碼在剛才已經獲得到了。
不懂的可以看看結尾,我已經總結好了。
連接後,返回雲平臺,可以看到設備處於在線狀態。說明設備已經成功連接了。
六、上報數據
連接成功後,我們接下來進行上報數據,官方教程地址:MQTT上報數據
裏面詳細介紹了上報數據的格式。
關於service_id和properties我們可以在雲平臺查看。
在所有設備一欄點擊查看
在設備影子一欄可以看到服務和屬性分別對應service_id和properties
我已經標注好了。
華為雲lot平臺的MQTT協議訂閱主題的格式: 格式:
$oc/devices/{device_id}/sys/messages/down
例如:$oc/devices/aaron_1/sys/messages/down
華為雲lot平臺MQTT協議發布主題的格式:
格式:$oc/devices/{device_id}/sys/properties/report
例如:$oc/devices/aaron_1/sys/properties/report
設備發布信息到華為雲平臺示例:
{"services": [{"service_id": "DHT11","properties":{"DHT11-T":50}}]}
在MQTT客戶端填好對應的參數,然後進行訂閱和發布主題,在右邊可以看到成功訂閱信息和發送數據。
回到雲平臺,可以看到我們上報的數據信息。
到此,設備數據已經上報成功了!
總結一下信息:
我的設備生成的數據:
ClientId/device_id:aaron_1
DeviceService/sercret:1531149131263
MQTT賬戶在線生成信息:
MQTT客戶端ID/Clientld:aaron_1_0_0_2022070108
MOTT用戶名/Username:aaron_1
MQTT登錄密碼/Password:66459ff563a64c15e817e1414e292c44c1e464ed91bdb450a4ef15f3ed84f6a0
華為雲iot平臺的MQTT服務器地址信息:
端口:1883
域名:219102c9fe.iot-mqtts.cn-north-4.myhuaweicloud.com
ip地址:121.36.42.100
華為雲lot平臺的MQTT協議訂閱主題的格式:
格式:$oc/devices/{
device_id}/sys/messages/down
例如:$oc/devices/aaron_1/sys/messages/down
華為雲lot平臺MQTT協議發布主題的格式:
格式:$oc/devices/{
device_id}/sys/properties/report
例如:$oc/devices/aaron_1/sys/properties/report
設備發布信息到華為雲平臺示例:{
"services": [{
"service_id": "DHT11","properties":{
"DHT11-T":50}}]}
边栏推荐
- MySQL学习03
- [shutter] top navigation bar implementation (scaffold | defaulttabcontroller | tabbar | tab | tabbarview)
- [Appendix 6 Application of reflection] Application of reflection: dynamic agent
- Introduction to kotlin collaboration
- The technology boss is ready, and the topic of position C is up to you
- Groovy, "try with resources" construction alternative
- [data mining] task 1: distance calculation
- 网络安全-木马
- Network security - Information Collection
- Performance test | script template sorting, tool sorting and result analysis
猜你喜欢
小程序开发的部分功能
In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
Ni visa fails after LabVIEW installs the third-party visa software
Hard core observation 547 large neural network may be beginning to become aware?
Learn BeanShell before you dare to say you know JMeter
How can retail enterprises open the second growth curve under the full link digital transformation
Query product cases - page rendering data
小程序開發的部分功能
One of the C language practical projects is greedy snake
Depth (penetration) selector:: v-deep/deep/ and > > >
随机推荐
Machine learning notes (constantly updating...)
MySQL learning 03
Network security NAT network address translation
Huakaiyun (Zhiyin) | virtual host: what is a virtual host
[AUTOSAR cantp] -2.11-uds diagnostic response frame data segment data padding data filling and data optimization data optimization (Theory + configuration)
In the face of difficult SQL requirements, HQL is not afraid
stm32F407-------ADC
How is the mask effect achieved in the LPL ban/pick selection stage?
What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it
Everything file search tool
网络安全-防火墙
【Camera专题】Camera dtsi 完全解析
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance o
[leetcode] 797 and 1189 (basis of graph theory)
File class (check)
When the epidemic comes, how to manage the team as a leader| Community essay solicitation
去除网页滚动条方法以及内外边距
Vant implements a simple login registration module and a personal user center
¢ growth path and experience sharing of getting an offer
浏览器是如何对页面进行渲染的呢?