当前位置:网站首页>詳細些介紹如何通過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}}]}
边栏推荐
- Network security - password cracking
- [error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
- [data mining] task 1: distance calculation
- Anna: Beibei, can you draw?
- 深度(穿透)选择器 ::v-deep/deep/及 > > >
- 力扣(LeetCode)183. 从不订购的客户(2022.07.02)
- Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance o
- 小程序開發的部分功能
- Groovy, "try with resources" construction alternative
- Vant implements a simple login registration module and a personal user center
猜你喜欢

Everything file search tool

Visual yolov5 format data set (labelme JSON file)

stm32F407-------IIC通讯协议

How can retail enterprises open the second growth curve under the full link digital transformation

MySQL学习03

自定义组件、使用npm包、全局数据共享、分包

Everything文件搜索工具

微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
![[camera topic] turn a drive to light up the camera](/img/d3/7aabaa5c75813abc4a43820b4c3706.png)
[camera topic] turn a drive to light up the camera

Niuniu's ball guessing game (dynamic planning + prefix influence)
随机推荐
查询商品案例-页面渲染数据
In the face of difficult SQL requirements, HQL is not afraid
微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
缺少库while loading shared libraries: libisl.so.15: cannot open shared object file: No such file
Ni visa fails after LabVIEW installs the third-party visa software
DQL basic operation
Network security OpenVAS
Storage basic operation
[Yu Yue education] Jiujiang University material analysis and testing technology reference
网络安全-DNS欺骗与钓鱼网站
Performance test | script template sorting, tool sorting and result analysis
Where is the future of test engineers? Confused to see
How to find summer technical internship in junior year? Are you looking for a large company or a small company for technical internship?
Wechat applet development tool post net:: err_ PROXY_ CONNECTION_ Failed agent problem
Network security - vulnerabilities and Trojans
Hard core observation 547 large neural network may be beginning to become aware?
Button button adaptive size of wechat applet
Niuniu's ball guessing game (dynamic planning + prefix influence)
Internal connection query and external connection
Everything file search tool