> 文档中心 > edgex接入modbus设备

edgex接入modbus设备

本文介绍edgex利用modbus-tcp协议接入模拟设备,利用kuiper根据设备名称进行筛选,然后发布到mqtt server的过程

1.下载 ModbusPal并配置

ModbusPal 下载连接https://sourceforge.net/p/modbuspal/discussion/899955/thread/72cf35ee/cd1f/attachment/ModbusPal.jarz

 寄存器地址及传感器值字段

添加模拟设备

添加寄存器地址及字段

 

 添加ModbusPal支持的值自动生成器,它可以绑定到寄存器:

 

运行模拟器

 

 2.添加Device Profile及设备

 内容如下,源文件为yml格式,此处只能用bash

startingAddress该属性定义Modbus设备从0开始的startingAddress。例如,GET命令从Modbus地址4004请求数据以获取温度数据,因此起始寄存器地址应该是4003。

RAW_TYPE:这个属性定义了从Modbus设备读取的二进制数据,然后我们可以使用值类型来指示用户想要接收的数据类型。

dbtimestamp:  created: 1649747852301  modified: 1649747852301id: e37ae456-dd0b-40ba-bff8-f17be919cc2bname: Hbfec-Temperature-Sensormanufacturer: Audon Electronicsdescription: The NANO_TEMP is a Ethernet Thermometer measuring from -55°C to 125°C  with a web interface and Modbus TCP communications.model: Temperaturelabels: [Web, Modbus TCP, SNMP]deviceResources:- description: Lower alarm threshold of the temperature  name: ThermostatL  isHidden: true  tag: ""  properties:    valueType: Float32    readWrite: RW    units: ""    minimum: ""    maximum: ""    defaultValue: ""    mask: ""    shift: ""    scale: "0.1"    offset: ""    base: ""    assertion: ""    mediaType: ""  attributes:    primaryTable: HOLDING_REGISTERS    rawType: Int16    startingAddress: 3999- description: Upper alarm threshold of the temperature  name: ThermostatH  isHidden: true  tag: ""  properties:    valueType: Float32    readWrite: RW    units: ""    minimum: ""    maximum: ""    defaultValue: ""    mask: ""    shift: ""    scale: "0.1"    offset: ""    base: ""    assertion: ""    mediaType: ""  attributes:    primaryTable: HOLDING_REGISTERS    rawType: Int16    startingAddress: 4000- description: 1 - OFF (disabled), 2 - Lower, 3 - Higher, 4 - Lower or Higher  name: AlarmMode  isHidden: true  tag: ""  properties:    valueType: Int16    readWrite: RW    units: ""    minimum: ""    maximum: ""    defaultValue: ""    mask: ""    shift: ""    scale: ""    offset: ""    base: ""    assertion: ""    mediaType: ""  attributes:    primaryTable: HOLDING_REGISTERS    startingAddress: 4001- description: Temperature x 10 (np. 10,5 st.C to 105)  name: Temperature  isHidden: false  tag: ""  properties:    valueType: Float32    readWrite: R    units: ""    minimum: ""    maximum: ""    defaultValue: ""    mask: ""    shift: ""    scale: "0.1"    offset: ""    base: ""    assertion: ""    mediaType: ""  attributes:    primaryTable: HOLDING_REGISTERS    rawType: Int16    startingAddress: 4003deviceCommands:- name: AlarmThreshold  isHidden: false  readWrite: RW  resourceOperations:  - deviceResource: ThermostatL    defaultValue: ""    mappings: {}  - deviceResource: ThermostatH    defaultValue: ""    mappings: {}- name: AlarmMode  isHidden: false  readWrite: RW  resourceOperations:  - deviceResource: AlarmMode    defaultValue: ""    mappings:      "1": "OFF"      "2": Lower      "3": Higher      "4": Lower or Higher

添加设备

选择device-modbus服务

 

选择刚才添加的device profile

 

添加设备,给设备取一个名字

 

添加自动采集的数据属性及时间间隔

 

添加设备地址信息

楼主是在win10的宿主机上跑的虚拟机,在虚拟机里利用docker-compose安装的edgex套件,我的宿主机ip是192.168.100.100,虚拟机网络模式为NAT,虚拟机的IP是192.168.32.16,这里address的地址应该填写宿主机ip192.168.100.100而不是192.168.32.2.

 3.根据kuiper-manager设置kuiper

创建kerper服务 ,这里的ip地址为docker为kuiper服务分配的ip地址

 创建流,流类型选择edgex总线

创建规则,筛选设备名为modbus的数据

 slink设置为mqtt server

 获取数据

利用MQTT.fx连接上mqtt server

查看订阅主题的消息

 

妊娠纹产品大全