We are using the 1-wire node to read temperature from a 1-wire sensor. The node output msg.payload is as follows:
{"payload":15.25,"topic":"","_msgid":"dac51164c5a5ec03"}
We need to write this temperature data (in this example 15.25) to a Modbus TCP client with the "Modbus write" node, and the error we currently get is:
Error: Data length error, expected 8 got 4
So I guess some sort of data parsing/conversion needs to take place (with a function node or parse node?) to format the payload to a clean 16 bit signed integer so that the Modbus TCP client register can be written with function code 6.
What is the simplest most effective way to achieve this?
Thank you!
Flow and used nodes follow:
[
{
"id": "873e6f46fb3cd974",
"type": "1-Wire",
"z": "f41a1647b9ab4cab",
"identifier": "28-00000cfa46e8",
"name": "Sensor",
"format": "1",
"x": 380,
"y": 840,
"wires": [
[
"b71bc2e80e367d13",
"6d814f4da6947f0b"
]
]
},
{
"id": "b71bc2e80e367d13",
"type": "debug",
"z": "f41a1647b9ab4cab",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 660,
"y": 840,
"wires": []
},
{
"id": "5849884c7f8b304d",
"type": "inject",
"z": "f41a1647b9ab4cab",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 840,
"wires": [
[
"873e6f46fb3cd974"
]
]
},
{
"id": "6d814f4da6947f0b",
"type": "modbus-write",
"z": "f41a1647b9ab4cab",
"name": "MTCP",
"showStatusActivities": true,
"showErrors": true,
"unitid": "1",
"dataType": "HoldingRegister",
"adr": "40002",
"quantity": "1",
"server": "df54d9acd8346d83",
"emptyMsgOnFail": true,
"keepMsgProperties": true,
"x": 650,
"y": 920,
"wires": [
[],
[]
]
},
{
"id": "df54d9acd8346d83",
"type": "modbus-client",
"name": "MDBUS CLIENT",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": true,
"tcpHost": "192.168.1.167",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": true
}
]