当前位置:网站首页>詳細些介紹如何通過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}}]}
边栏推荐
- [North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array
- Niuniu's ball guessing game (dynamic planning + prefix influence)
- Prohibited package name
- How is the mask effect achieved in the LPL ban/pick selection stage?
- 网络安全-破解系统密码
- A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?
- 微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
- 转载收录6.5大侠写的部分Qt开发经验
- Answers to ten questions about automated testing software testers must see
- stm32F407-------IIC通讯协议
猜你喜欢
【Camera专题】OTP数据如何保存在自定义节点中
技术大佬准备就绪,话题C位由你决定
深度(穿透)选择器 ::v-deep/deep/及 > > >
Redis:Redis的简单使用
How do it students find short-term internships? Which is better, short-term internship or long-term internship?
[camera topic] complete analysis of camera dtsi
Niuniu's ball guessing game (dynamic planning + prefix influence)
STM32 - vibration sensor control relay on
Processing of tree structure data
A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?
随机推荐
Redis:Redis的简单使用
Reprint some Qt development experience written by great Xia 6.5
网络安全-漏洞与木马
How can retail enterprises open the second growth curve under the full link digital transformation
leetcode961. Find the elements repeated N times in the array with length 2n
Types of map key and object key
Groovy, "try with resources" construction alternative
502 (bad gateway) causes and Solutions
Network security - DNS spoofing and phishing websites
自定义组件、使用npm包、全局数据共享、分包
Technology sharing | Frida's powerful ability to realize hook functions
Return the only different value (de duplication)
Niuniu's ball guessing game (dynamic planning + prefix influence)
Rockchip3399 start auto load driver
网络安全-木马
Network security - firewall
网络安全-钓鱼
[Yu Yue education] Jiujiang University material analysis and testing technology reference
[shutter] shutter debugging (debugging control related functions | breakpoint management | code operation control)
DQL basic operation