Understanding settings
The settings are always processed by the system in JSON format, before they are sent to the gateway, and are divided into 2 parts:
slaveDefinitions
In slaveDefinitions, you decide what you will read. There are a number of settings for each slave:
Field | Value (as in example) | Description |
---|---|---|
"address" | "192.168.2.11" | The IP address of the modbus slave. |
"port" | 502 | The port number of the modbus slave. |
"slaveId" | 1 | The slave id of the modbus slave. |
"type" | "generic-tcp" | To choose which register you want to read, specify generic-tcp. |
Example of a slaveDefinitions block
"slaveDefinitions": [
{
"name": "modbus.tcp",
"slaves": [
{
"address": "192.168.2.11",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
},
{
"address": "192.168.2.12",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
}
]
}
]
SlaveSettings
For each slave that you have defined in slaveDefinitions, you can determine in slaveSettings which registers you actually want to read. First of all, you start by determining the name, always in the following format:
modbus.tcp.{ip_address}__{port}.{slave_id}
ip_address: the IP address of the slave. Use an underscore ("_") instead of a period (".").
port: this is standard 502 for modbus.
slave_id: the slave ID that you have specified in slaveDefinitions.
For example: modbus.tcp.192_168_2_11__502.1 → IP address = 192.168.2.11, Port = 502, Slave ID = 1.
Furthermore, in measurementPaths you determine which modbus registers you want to read.
Field | Value (as in example) | Description |
---|---|---|
"measurementPath" | "voltage.uv" | The name of the path on which the data is put. |
"functionCode" | 4 | Type of register to be read:
|
"startAddress" | 0 | The modbus address you want to read. |
"dataType" | 1 | Type of data to be read:
|
"factor" | 1 | This determines the factorization of the read value.
|
"minValue" (Optional) | 0 | If a minimum value has been entered, it will not be forwarded if the measurement is below this value. |
"maxValue" (Optional) | 500 | If a maximum value has been entered, it will not be forwarded if the measurement is above this value. |
"firstBit" (optional) | 7 | If you want to read one or more bits from a register, enter the first bit here. Choose Int16 as the data type (type 1 in the gateway settings).
|
"lastBit" (optional) | 7 | If you want to read one or more bits from a register, enter the first bit here. Choose Int16 as the data type (type 1 in the gateway settings).
|
Example of a slaveSettings block
"slaveSettings": [
{
"name": "modbus.tcp.192_168_2_11__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "voltage.uv",
"functionCode": 4,
"startAddress": 0,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 500
}
]
}
},
{
"name": "modbus.tcp.192_168_2_12__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "alarm_1",
"functionCode": 3,
"startAddress": 1,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 1,
"firstBit": 7,
"lastBit": 7
}
]
}
}
]
Example of a complete settings definition
{
"slaveDefinitions": [
{
"name": "modbus.tcp",
"slaves": [
{
"address": "192.168.2.11",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
},
{
"address": "192.168.2.12",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
}
]
}
],
"slaveSettings": [
{
"name": "modbus.tcp.192_168_2_11__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "voltage.uv",
"functionCode": 4,
"startAddress": 0,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 500
}
]
}
},
{
"name": "modbus.tcp.192_168_2_12__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "alarm_1",
"functionCode": 3,
"startAddress": 1,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 1,
"firstBit": 7,
"lastBit": 7
}
]
}
}
]
}