当前位置:网站首页>详细些介绍如何通过MQTT协议和华为云物联网进行通信
详细些介绍如何通过MQTT协议和华为云物联网进行通信
2022-07-03 01:33: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}}]}
边栏推荐
- Internal connection query and external connection
- 网络安全-DNS欺骗与钓鱼网站
- 深度学习笔记(持续更新中。。。)
- 小程序開發的部分功能
- Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance o
- Redis: simple use of redis
- STM32 - introduction of external interrupts exti and NVIC
- mysql
- 【Camera专题】HAL层-addChannel和startChannel简析
- Network security - scanning and password explosion 2
猜你喜欢

Ni visa fails after LabVIEW installs the third-party visa software

Certaines fonctionnalités du développement d'applets

微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
![[data mining] task 3: decision tree classification](/img/9a/1cb2a8a90f16e7bfa9b48e516a966c.png)
[data mining] task 3: decision tree classification
![[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)](/img/68/65b8c0530cfdc92ba4f583b0162544.gif)
[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)

STM32 - introduction of external interrupts exti and NVIC

Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux

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

Visual yolov5 format data set (labelme JSON file)
![[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](/img/2a/98400b0d0b5eda1e52abae30746f2b.jpg)
[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
随机推荐
ByteDance data Lake integration practice based on Hudi
Network security - scanning and password explosion 2
网络安全-病毒
How can retail enterprises open the second growth curve under the full link digital transformation
STM32 - GPIO input / output mode
Prohibited package name
网络安全-信息收集
去除网页滚动条方法以及内外边距
File class (check)
Everything file search tool
[camera topic] complete analysis of camera dtsi
Network security - the simplest virus
Asian Games countdown! AI target detection helps host the Asian Games!
Network security - dynamic routing protocol rip
小程序开发的部分功能
One of the C language practical projects is greedy snake
Problems encountered in small program development of dark horse shopping mall
网络安全-钓鱼
Query product cases - page rendering data
网络安全-动态路由协议RIP