The following example configures a Modbus connector to output data to a Modbus device. When MQTT, SQL, JSON DB, or an input connector inserts a record into the "modbus1" integration table, the FairCom server delivers the record to the Modbus connector. This example configures the Modbus connector to extract the value of the temperature property from the record’s source_payload field and write it to a device using the Modbus protocol:
- Select Hub API from the Select API dropdown menu.
- Select
createOutputfrom the JSON Actions dropdown menu. - Replace the JSON in the API Request editor with the following JSON:
{
"api": "hub",
"action": "createOutput",
"params": {
"outputName": "writeTemperatureToModbus",
"serviceName": "modbus",
"databaseName": "faircom",
"ownerName": "admin",
"tableName": "modbusTableTCP",
"sourceFields": ["source_payload"],
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"propertyMapList": [
{
"propertyPath": "source_payload.temperature",
"modbusDataAddress": 1399,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
}
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}- Click Apply defaults to JSON request (
) to replace the
"authToken"value with the valid one from your session. - Click Send request (
) to issue the JSON-based request. - Observe the response and ensure the action is completed successfully.
Note
"errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.