DGIOT实战教程——风量传感器接入 - DGIOT

DGIOT实战教程——风量传感器接入

首页博客, 实战教程

[小 迪 导读]
本教程在掌握基础modbusRTU标准协议概念和业务流程之后,通过真实的支持ModbusRTU标准协议的设备和DTU来进行实战演练。

系统需要使用两个设备以及若干导线:

  • 风量传感器:采用的是管道式风速变送器 (485型)
  • DTU:采用的是有人的口红CAT-1 DTU DR154

系统架构逻辑图如下,包括设备模拟,通道通信,模型设置,应用显示部分

操作步骤:

1.设备接线

设备信息

模块 管道式风速变送器 (485型)
型号 PR-3009TH-FS-NO1
类型 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的设备:参数可以询问商家或者商品介绍获取设备的参数

file
file

3.创建采集通道

1.创建ModbusRTU采集通道。位置在通道管理-创建通道

2.选择Modbus采集通道并配置


3.产品添加通道后需对通道进行重启

4.通道日志查看


5.创建产品

1.要连接风速变送器,创建一种产品即可
2.创建产品

风速变送器

3.产品物模型配置
将以下物模型代码直接复制即可
风速变送器

{
    "properties": [
        {
            "accessMode": "r",
            "dataForm": {
                "address": "0X10",
                "collection": "%%wind_float",
                "control": "%d",
                "countcollection": "%s",
                "countround": "all",
                "countstrategy": 20,
                "data": "null",
                "iscount": "0",
                "offset": 0,
                "operatetype": "readCoils",
                "order": 0,
                "originaltype": "short16_AB",
                "protocol": "MODBUSRTU",
                "rate": 1,
                "round": "all",
                "slaveid": "0X10",
                "strategy": "计算值"
            },
            "dataSource": {
                "": [],
                "_dlinkindex": "",
                "address": "2",
                "operatetype": "readHregs",
                "originaltype": "short16_AB",
                "registersnumber": "1",
                "slaveid": "velocity"
            },
            "dataType": {
                "das": [],
                "specs": {
                    "max": 9999,
                    "min": 0,
                    "precision": 1,
                    "step": 0,
                    "unit": ""
                },
                "type": "float"
            },
            "devicetype": "风量传感器",
            "identifier": "wind_float",
            "isaccumulate": false,
            "isshow": true,
            "isstorage": true,
            "moduleType": "properties",
            "name": "风量值浮点型",
            "required": true,
            "updateAt": "1662689964496",
            "index": 0
        },
        {
            "accessMode": "r",
            "dataForm": {
                "address": "0X10",
                "collection": "%%wind_int",
                "control": "%d",
                "countcollection": "%s",
                "countround": "all",
                "countstrategy": 20,
                "data": "null",
                "iscount": "0",
                "offset": 0,
                "operatetype": "readCoils",
                "order": 0,
                "originaltype": "short16_AB",
                "protocol": "MODBUSRTU",
                "rate": 1,
                "round": "all",
                "slaveid": "0X10",
                "strategy": "计算值"
            },
            "dataSource": {
                "": [],
                "_dlinkindex": "",
                "address": "1",
                "operatetype": "readHregs",
                "originaltype": "short16_AB",
                "registersnumber": "1",
                "slaveid": "velocity"
            },
            "dataType": {
                "das": [],
                "specs": {
                    "max": 65535,
                    "min": 0,
                    "precision": 3,
                    "step": 0,
                    "unit": "m³/h"
                },
                "type": "int"
            },
            "devicetype": "风量传感器",
            "identifier": "wind_int",
            "isaccumulate": false,
            "isshow": true,
            "isstorage": true,
            "moduleType": "properties",
            "name": "风量整数型",
            "required": true,
            "updateAt": "1662689893515",
            "index": 1
        },
        {
            "accessMode": "r",
            "dataForm": {
                "address": "0X10",
                "collection": "%%wind_velocity/10",
                "control": "%d",
                "countcollection": "%s",
                "countround": "all",
                "countstrategy": 20,
                "data": "null",
                "iscount": "0",
                "offset": 0,
                "operatetype": "readCoils",
                "order": 0,
                "originaltype": "short16_AB",
                "protocol": "MODBUSRTU",
                "rate": 1,
                "round": "all",
                "slaveid": "0X10",
                "strategy": "计算值"
            },
            "dataSource": {
                "": [],
                "_dlinkindex": "",
                "address": "0",
                "operatetype": "readHregs",
                "originaltype": "short16_AB",
                "registersnumber": "1",
                "slaveid": "velocity"
            },
            "dataType": {
                "das": [],
                "specs": {
                    "max": 999,
                    "min": 0,
                    "precision": 3,
                    "step": 0,
                    "unit": "m/s"
                },
                "type": "float"
            },
            "devicetype": "风量传感器",
            "identifier": "wind_velocity",
            "index": 2,
            "isaccumulate": false,
            "isshow": true,
            "isstorage": true,
            "moduleType": "properties",
            "name": "风速值",
            "required": true,
            "updateAt": "1662689799736"
        },
        {
            "accessMode": "r",
            "dataForm": {
                "address": "0X10",
                "collection": "%s",
                "control": "%d",
                "countcollection": "%s",
                "countround": "all",
                "countstrategy": 20,
                "data": "null",
                "iscount": "0",
                "offset": 0,
                "operatetype": "readCoils",
                "order": 0,
                "originaltype": "short16_AB",
                "protocol": "MODBUSRTU",
                "rate": 1,
                "round": "all",
                "slaveid": "0X10",
                "strategy": "3"
            },
            "dataSource": {
                "": [],
                "_dlinkindex": "",
                "address": "0X00",
                "operatetype": "readHregs",
                "originaltype": "bit",
                "registersnumber": "3",
                "slaveid": "0X01"
            },
            "dataType": {
                "das": [],
                "size": 1000000000,
                "specs": {},
                "type": "text"
            },
            "devicetype": "风量传感器",
            "identifier": "velocity",
            "index": 3,
            "isaccumulate": false,
            "isshow": false,
            "isstorage": false,
            "moduleType": "properties",
            "name": "风量",
            "required": true,
            "updateAt": "1662689688077"
        }
    ]
}

4.如何复制物模型

在产品管理-配置-物模型-查看物模型处

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

更多配置细节参考真实Mobuds接入

6.风速变送器设备连接的DTU注册成功

1.风速变送器设备连接的DTU注册成功

2.风速变送器设备连接的DTU上线成功

7.风速变送器数据采集成功

1.风速变送器实时数据

[小 迪 提醒]
没有多个数据的modbusRTU设备的用户可以使用虚拟modbus软件自行模拟。
虚拟modbus连接点击了解详情

[小 迪 点评]

  • dgiot支持ModbusRTU协议的设备接入,有真实设备的用户尝试进行设备接入演练。
  • 风速变送器也是modbus设备,为大家提供多一点的熟悉对象。

想了解更多 dgiot 的具体细节,欢迎大家在GitHub上查看相关源代码。

上一篇:
上一篇:

加小迪为好友
即可加入交流群

点击填写表单
获得解决方案专家帮助
点击前往 GitHub
查看源代码