[小 迪 导读]:
本教程在掌握基础modbusRTU标准协议概念和业务流程之后,通过真实的支持ModbusRTU标准协议的设备和DTU来进行实战演练。
系统需要使用两个设备以及若干导线:
- 红外传感器:吸顶式红外探测器 (485型)
- DTU:采用的是有人的口红CAT-1 DTU DR154
系统架构逻辑图如下,包括设备模拟,通道通信,模型设置,应用显示部分
操作步骤:
1.设备接线
设备信息
模块 | 吸顶式红外探测器 (485型) |
---|---|
型号 | PR-3000-HW-N01 |
类型 | Modbus 红外探测器 |
- 红外探测器

DTU信息
品牌 | 有人 |
---|---|
型号 | DR154(RS485) |
密码(Pwd) | usr_cn |
- dtu图片

接线连接
红外探测器连接电源
红外探测器根据端口图正负连接电源正负,电源可以选用电源适配器。
DTU连接电源
根据DTU上的端口图,红色线(电源线)连接DC+,黑色线(地线)连接DC-
连接DTU和红外探测器
根据端口图,红外探测器的A端口连接DTU端口的RX(A),红外探测器的B端口连接DTU端口的TX(B)
说明 RX为接收,TX为发送

连接详情请可点击参考真实Mobuds接入
2.dtu配置
1.DTU正面二维码下方标识正负极连接电源,A,B端连接电表,到开手机微信扫码,扫描DTU二维码进入小程序,打开蓝牙连接与DTU背部IMEI相同编号的蓝牙,进入连接,密码为usr_cn。

2.打开参数设置,设置工作模式:地址设为部署的平台地址;端口号设为20651。
说明 地址为服务器地址,端口号为服务器端口号,若无自己的物联网服务器,可选择地址:prod.dgiotcloud.cn,端口号设为20651
警告 设置dtu时,工作模式设置完后需保存再设置串口,不能一次性设置,一次性设置会导致设置不完全

勾选注册包功能,注册包数据类型选择IMEI码,将会自动生成一个IMEI码。

3.打开参数设置,设置串口设置:波特率设为4800,校验位选择NONE。
说明 支持ModbusRTU的设备:参数可以询问商家或者商品介绍获取设备的参数

3.创建采集通道
1.创建ModbusRTU采集通道。位置在通道管理-创建通道
2.选择Modbus采集通道并配置

3.产品添加通道后需对通道进行重启
4.通道日志查看


5.创建产品
1.要连接红外探测器,创建一种产品即可
2.创建产品
红外探测器

3.产品物模型配置
将以下物模型代码直接复制即可
红外探测器
{
"events": [],
"properties": [
{
"accessMode": "r",
"dataForm": {
"address": "0X10",
"afn": "",
"byteType": "",
"bytelen": "",
"collection": "%s",
"control": "%d",
"countcollection": "%s",
"countround": "all",
"countstrategy": 20,
"da": "",
"data": "null",
"dt": "",
"iscount": "0",
"offset": 0,
"operatetype": "readCoils",
"order": 0,
"originaltype": "short16_AB",
"protocol": "MODBUSRTU",
"rate": 1,
"round": "all",
"slaveid": "0X10",
"strategy": "3"
},
"dataSource": {
"": [],
"_dlinkindex": "",
"address": "0X0003",
"operatetype": "readHregs",
"originaltype": "short16_AB",
"registersnumber": "1",
"slaveid": "0X01"
},
"dataType": {
"das": [],
"specs": {
"0": "正常",
"1": "报警"
},
"type": "enum"
},
"devicetype": "感烟火灾探测器",
"identifier": "yan",
"isaccumulate": false,
"isshow": true,
"isstorage": true,
"moduleType": "properties",
"name": "烟感",
"required": true,
"updateAt": "1663731590802",
"index": 0
}
],
"services": [],
"tags": []
}
4.如何复制物模型
在产品管理-配置-物模型-查看物模型处

将物模型代码复制粘贴即可

更多配置细节参考真实Mobuds接入
6.红外探测器设备连接的DTU注册成功
1.红外探测器设备连接的DTU注册成功

2.红外探测器设备连接的DTU上线成功

7.红外探测器数据采集成功
1.红外探测器实时数据

[小 迪 提醒]
没有多个数据的modbusRTU设备的用户可以使用虚拟modbus软件自行模拟。
虚拟modbus连接点击了解详情。
[小 迪 点评]
- dgiot支持ModbusRTU协议的设备接入,有真实设备的用户尝试进行设备接入演练。
- 红外探测器也是modbus设备,为大家提供多一些的熟悉对象。