Hi All, we appreciated that you can share all information about how we can use the node-red application. And following this, we have created a simple test for communicating through MQTT with two equipment but have the following issue.
We can send the Sparkplug message but when we want to check if the message is ok not come the last part of the message "Value" data.
We are using a Raspberry PI 4 with Mosquitto MQTT Broker and applying the Sparkplug codification into the node -red. To verify this we are using the same node-red application.
Could you please help us verify what is the error?
Many Thanks
[
{
"id": "e9a0d0f28d260b54",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "fb5b1839cdcb6c22",
"type": "function",
"z": "e9a0d0f28d260b54",
"name": "Sparkplug B Message",
"func": "msg.payload = {\n \"metrics\":\n [{\n \"name\":'Temp',\n \"alias\": 23,\n \"datatype\": 9,\n \"value\": msg.payload[0]\n }],\n \"seq\": 0\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 680,
"y": 240,
"wires": [
[
"fb6e8fa3b2843b6c",
"5a00beec7dfc8d25"
]
]
},
{
"id": "5a00beec7dfc8d25",
"type": "debug",
"z": "e9a0d0f28d260b54",
"name": "debug 1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1020,
"y": 240,
"wires": []
},
{
"id": "9b6e18d04c6d4d90",
"type": "modbus-write",
"z": "e9a0d0f28d260b54",
"name": "TestWriteMDB",
"showStatusActivities": true,
"showErrors": false,
"unitid": "1",
"dataType": "MHoldingRegisters",
"adr": "0",
"quantity": "10",
"server": "2ea27f71b146d1b4",
"emptyMsgOnFail": false,
"keepMsgProperties": true,
"x": 820,
"y": 380,
"wires": [
[],
[]
]
},
{
"id": "46d1a911159a1260",
"type": "random",
"z": "e9a0d0f28d260b54",
"name": "Random_Value",
"low": "0",
"high": "1000",
"inte": "false",
"property": "payload",
"x": 320,
"y": 340,
"wires": [
[
"98ca7bcef0479bbc"
]
]
},
{
"id": "45e41c801da5733e",
"type": "inject",
"z": "e9a0d0f28d260b54",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 340,
"wires": [
[
"46d1a911159a1260"
]
]
},
{
"id": "98ca7bcef0479bbc",
"type": "function",
"z": "e9a0d0f28d260b54",
"name": "Holding_Register",
"func": "var HR = msg.payload\nvar HRArray = []\n\nHRArray[0] = HR + 50 ;\nHRArray[1] = HR + 25 ; \nHRArray[2] = HR + 15;\nHRArray[3] = HR + 22;\nHRArray[4] = HR + 23;\nHRArray[5] = HR + 78;\nHRArray[6] = HR - 48;\nHRArray[7] = HR * 2 ;\nHRArray[8] = HR * 3;\nHRArray[9] = HR + 56;\n\nmsg.payload = HRArray\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 340,
"wires": [
[
"9b6e18d04c6d4d90",
"e75feb684135e32f",
"fb5b1839cdcb6c22"
]
]
},
{
"id": "e75feb684135e32f",
"type": "debug",
"z": "e9a0d0f28d260b54",
"name": "debug 3",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 460,
"wires": []
},
{
"id": "6f2dc45a87d4ea68",
"type": "debug",
"z": "e9a0d0f28d260b54",
"name": "debug 4",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 960,
"y": 60,
"wires": []
},
{
"id": "faacc4911f97079f",
"type": "mqtt in",
"z": "e9a0d0f28d260b54",
"name": "Receive_Data",
"topic": "spBv1.0/Synertrex/DDATA/Test/#",
"qos": "2",
"datatype": "auto-detect",
"broker": "cadb3065520d7ac4",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 210,
"y": 580,
"wires": [
[
"3107093fb3fa47c3",
"351e433ca41eb930"
]
]
},
{
"id": "3107093fb3fa47c3",
"type": "debug",
"z": "e9a0d0f28d260b54",
"name": "debug 5",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 420,
"y": 660,
"wires": []
},
{
"id": "2b18dfa09b6afe0e",
"type": "debug",
"z": "e9a0d0f28d260b54",
"name": "debug 2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 580,
"wires": []
},
{
"id": "351e433ca41eb930",
"type": "decode",
"z": "e9a0d0f28d260b54",
"name": "sparkplug_b_decode",
"protofile": "7a32d763db061211",
"protoType": "Payload",
"x": 460,
"y": 580,
"wires": [
[
"2b18dfa09b6afe0e"
]
]
},
{
"id": "fb6e8fa3b2843b6c",
"type": "encode",
"z": "e9a0d0f28d260b54",
"name": "sparkplug_b",
"protofile": "a3eeaf7db6f73929",
"protoType": "Payload",
"x": 670,
"y": 120,
"wires": [
[
"6f2dc45a87d4ea68",
"e2b912bfabb9e544"
]
]
},
{
"id": "e2b912bfabb9e544",
"type": "mqtt out",
"z": "e9a0d0f28d260b54",
"name": "Send_Data",
"topic": "spBv1.0/Synertrex/DDATA/Test/4/",
"qos": "2",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "cadb3065520d7ac4",
"x": 1090,
"y": 120,
"wires": []
},
{
"id": "2ea27f71b146d1b4",
"type": "modbus-client",
"name": "",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": true,
"tcpHost": "192.168.28.101",
"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
},
{
"id": "cadb3065520d7ac4",
"type": "mqtt-broker",
"name": "MQTT_Server",
"broker": "192.168.28.102",
"port": "1883",
"clientid": "Synertrex",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "spBv1.0/Synertrex/NBIRTH/",
"birthQos": "1",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "spBv1.0/Synertrex/NDEATH/",
"closeQos": "1",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "7a32d763db061211",
"type": "protobuf-file",
"protopath": "/home/synuser/sparkplugb/sparkplug_b.proto",
"watchFile": true
},
{
"id": "a3eeaf7db6f73929",
"type": "protobuf-file",
"protopath": "/home/synuser/sparkplugb/sparkplug_b.proto",
"watchFile": true
}
]