tb_gateway.yaml简单介绍
- Thingsboard–连接到ThingsBoard平台的配置。
- security–加密和授权类型的配置。
storage–存储方式配置(内存或文件)。
-
tb_gateway.yaml配置
在
tb_gateway.yaml
中打开Modbus Connectorthingsboard:
host: demo.thingsboard.io
port: 1883
security:
accessToken: PUT_YOUR_ACCESS_TOKEN_HERE
storage:
type: memory
read_records_count: 100
max_records_count: 100000
connectors:
-
name: Modbus Connector
type: modbus
configuration: modbus.json
modbus.json介绍和配置
官网介绍
注释中modbus相关的解释 thignsboard支持的modbus功能码(1/2/3/4可作为属性/遥测的functionCode且2/4是只读,5/6/15/16作为rpc的functionCode)
- 读数据
- 1 读
线圈
读写 - 2 读
离散输入
只读 - 3 读多个保存寄存器 读写
- 4 读保持寄存器 只读
- 1 读
- 写数据
- 5 写单个线圈
- 6 写单个寄存器
- 15 写多个线圈
- 16 写多个寄存器
{
"server": {
"name": "Modbus Test Server",
"type": "tcp", # 协议类型
"host": "10.211.55.3",
"port": 502,
"timeout": 35,
"method": "socket",
"devices": [
{
"unitId": 1, # 设备ID
"deviceName": "th_sensor",
"attributesPollPeriod": 5000, #属性轮询拉取时间间隔
"timeseriesPollPeriod": 5000, #遥测轮询拉取时间间隔
"sendDataOnlyOnChange": false, # 是否只有当数据变化时上传
"attributes": [ # 这里定义的modbus对应地址位的数据作为属性上传到tb
{
"byteOrder": "BIG", # 大小端
"tag": "batteryLevel", # 属性名称
"type": "long", # 数据类型
"functionCode": 4, # modbus功能码
"registerCount": 1, # 寄存器数量
"address": 2 # 地址位
},
{
"byteOrder": "LITTLE",
"tag": "switchStatus",
"type": "bits",
"functionCode": 1,
"registerCount": 1,
"address": 3
}
],
"timeseries": [ # 这里定义的modbus对应地址位的数据作为遥测数据上传到tb
{
"byteOrder": "BIG",
"tag": "humidity",
"type": "long",
"functionCode": 4,
"registerCount": 1,
"address": 1
},
{
"byteOrder": "BIG",
"tag": "temperature",
"type": "long",
"functionCode": 3,
"registerCount": 1,
"address": 0
}
],
"rpc": [
{
"tag": "writeSingleRegister",
"type": "16int",
"functionCode": 6,
"objectsCount": 1,
"address": 0
},
]
}
]
}
}
- 读数据