Node-red-contrib-buffer-parser with BIHL WIEDEMANN

Respected Steve Sir,

I have a doubt regarding the data output from the Node red Config buffer parser.

  1. I am using SMC pressure Sensor IO link and I configure it on the PORT 1 (There are 04 ports on IO Link Master starting from PORT 01 and goes to PORT 04) and I gave 2 bytes of process data as described by SMC vendor.


  1. When I configure it to the PORT 01 I get the desired results.
    Now I shift the sensor from PORT 01 to PORT 03 and try to read values and I read nothing.

When I was reading correctly at PORT 1 i kept the offset = 0 and when I configured it to PORT 3 I keep the offset= 10 as I am reading data from BYTE 10.

May be I am doing something wrong with the "offset" can anyone please guide me in this matter

?

Please check the flow as mentioned below :slight_smile:

[
    {
        "id": "166bcf76d196177e",
        "type": "buffer-parser",
        "z": "d46daf54501e291d",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16le",
                "name": "pressureSensorValue",
                "offset": 10,
                "length": 1,
                "offsetbit": 0,
                "scale": ">>3",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "return",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": false,
        "outputs": 1,
        "x": 856.2222671508789,
        "y": 253.0000705718994,
        "wires": [
            [
                "a2e5ad7a2c35696c",
                "7458146d6ba70545"
            ]
        ]
    },
    {
        "id": "4e77caafce2b081f",
        "type": "global-config",
        "env": [],
        "modules": {
            "node-red-contrib-buffer-parser": "3.2.2"
        }
    }
]

Firstly, some actual data and the value you expect it to represent would be helpful.

Use the Copy Value button that appears when you hover over an item in the debug panel. And when pasting the data to your reply, wrap it in triple ``` backticks to preserve formatting.

  1. Please provide the data coming out of OPC
    2. Include what you expect this to actually be (e.g. pressure 1740, out1 ON, out2 OFF, diag Normal)
  2. Please provide the code from the function node "Convert to array for parser"

Respected Steve Sir,

Are you able to import my flow ?
I think I forgot backticks in previous response:

I am expecting the pressure value to be "0.58 Mpas".
(Out1-On) (Out2-On) (diag- Normal)

Function code in the "Convert array to Parser" I converted the output of OPC in the array format as I was getting output in Object form from OPC client.
Code is as mentioned below:

var array = Object.values(msg.payload); // Converting the object data type to array
msg.payload = array;
node.status({ fill: "red", shape: "ring", text:msg.payload });
return msg;
{"_msgid":"efd5d465beb20ba3","payload":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":103,"11":235,"12":0,"13":0,"14":0,"15":0},"topic":"ns=2;s=type=0&circ=0&slavenr=1.ProcessData.InputData","datatype":"Byte","browseName":"","statusCode":{"value":0},"serverTimestamp":"2025-09-29T07:17:53.900Z","sourceTimestamp":"2025-09-29T07:17:53.900Z"}

I am attaching the whole flow again as I did not use backticks.
Please see the whole flow:

[
    {
        "id": "cdfc96937a19ffb6",
        "type": "function",
        "z": "d46daf54501e291d",
        "name": "Convert to array for \"PARSER\"",
        "func": "var array = Object.values(msg.payload); // Converting the object data type to array\nmsg.payload = array;\nnode.status({ fill: \"red\", shape: \"ring\", text:msg.payload });\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610.8664093017578,
        "y": 251.00010108947754,
        "wires": [
            [
                "166bcf76d196177e"
            ]
        ]
    }
]

Like last time, you have only exported 1 node.
To export a flow, you need to select all nodes you want in the export.

PS, dont bother exporting your FULL flow as I dont have your OPC data source (or OPC nodes installed) - instead, you could simulate the OPC data by capturing it (Debug->copy value) and adding to your flow using an inject + function node.

It is very unlikely the data in those 13 bits are formatted for the the unit MPa - io-link data is often binary and requires conversion. Do you have this information?

Ok Steve Sir noted.

Did you get the data that is required to understand my problem or where I am making mistake ?

I am giving offset = 10 as the data is on byte 10, using Int16(le) as the data from SMC vendor is coming in Little endian.

10.0 Out1
10.1 Out2
10.2 Diag
10.3 to 11.7 Process data for pressure sensor

Yes sir I was talking to you about the end result in unit of "Mpa" IO link is digital so i will get digital or binary values.

Did you also see in parser in "Scaling" I used ">>>3" to shift to right just by three bits to remove the unwanted data.
Then I multiplied the output of parser with 0.000250
Then offset of -0.25 to get desired results.

Which i am getting the correct response.

It is just that when I changed the port1 to port 3 Its not working so there is something that I am missing in offset or fundamentals wrong.

Sir please see attachment that I was getting desired response in yellow when I configured at port1.

So when you change to another port on IOLink, the data is in a different position. You had an offset of 10. Which means you were reading from byte 10 (WORD 5 or in your case, since you converted to an array, this is index5 in the array)

As per Buffer Parser built in help:

A node that converts an array of integer (Int16) or a buffer in to an object of values based on the specification provided

The problem.

Your debug node shows data output by OPCUA is a Uint8Array (i.e. an array of bytes) - that means after your function "Convert to Array" you are sending an array of 8 bit values to the buffer parser. It should be an array of 16 bit values OR a Buffer of bytes.

The correct way.

  1. Convert the payload to a buffer

[{"id":"cf73580e64c54f94","type":"inject","z":"494851d036808354","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":195,"y":860,"wires":[["e2297343b184f20a"]],"l":false},{"id":"e2297343b184f20a","type":"function","z":"494851d036808354","name":"Fake Port1 data (Uint8Array)","func":"msg.payload = new Uint8Array([94,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0])\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":860,"wires":[["787c7220c0098364","e8ac9b93237b3259"]]},{"id":"e8ac9b93237b3259","type":"debug","z":"494851d036808354","name":"OPC UA Data","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":420,"y":920,"wires":[]},{"id":"787c7220c0098364","type":"function","z":"494851d036808354","name":"Convert to Buffer","func":"msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":860,"wires":[["40737f6a3a88656f","2609f20636755837"]]},{"id":"2609f20636755837","type":"debug","z":"494851d036808354","name":"Converted for parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":700,"y":920,"wires":[]}]

Also, the doc states "Unsigned 13 bit" you had selected int16le

Respected Steve Sir,

I don't understand it.
Ok I got the point that when I convert it to array each element is of 16 bit rather then 8 bit but then how do i get correct response. ?

After converting it to buffer as you said for the same pressure reading I am getting different values.

What data type should I keep ?
I kept int16(le) as the data is coming in little endian from SMC.
I want to read byte 10 and byte 11 so int16.

Now I am getting more and more confused.

how do i remove Byte10.0, byte 10.1 and byte 10.2 which is not relevant to me ?
I use >>>3 in scaling. is it correct ?

[
    {
        "id": "d46daf54501e291d",
        "type": "tab",
        "label": "Bihl Wiedemann OPC Server",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "5a6ae3bbd703e75f",
        "type": "mqtt in",
        "z": "d46daf54501e291d",
        "name": "",
        "topic": "RaspberryPi",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "6c8927a5ed0034ab",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 134.8666648864746,
        "y": 76.00000858306885,
        "wires": [
            [
                "216ea618f6df5f13"
            ]
        ]
    },
    {
        "id": "89299e81421bcf02",
        "type": "mqtt out",
        "z": "d46daf54501e291d",
        "name": "",
        "topic": "SiemensLaptop",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "6c8927a5ed0034ab",
        "x": 299.8666687011719,
        "y": 155.13333892822266,
        "wires": []
    },
    {
        "id": "b442ac8370bb0764",
        "type": "inject",
        "z": "d46daf54501e291d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "HI Raspberry Pi, I am Siemens Laptop and communicating with you from IP 192.168.1.119",
        "payloadType": "str",
        "x": 112.8666763305664,
        "y": 154.00003051757812,
        "wires": [
            [
                "89299e81421bcf02"
            ]
        ]
    },
    {
        "id": "216ea618f6df5f13",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 317.9333267211914,
        "y": 78.9333267211914,
        "wires": []
    },
    {
        "id": "b7e1066612ea64b5",
        "type": "inject",
        "z": "d46daf54501e291d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 108.93331909179688,
        "y": 444.93335819244385,
        "wires": [
            [
                "062398eb8c4d4b6d",
                "866d89542c3718d7"
            ]
        ]
    },
    {
        "id": "20d51df8772ac674",
        "type": "OpcUa-Client",
        "z": "d46daf54501e291d",
        "endpoint": "d5876577da118764",
        "action": "read",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "useTransport": false,
        "maxChunkCount": 1,
        "maxMessageSize": 8192,
        "receiveBufferSize": 8192,
        "sendBufferSize": 8192,
        "setstatusandtime": false,
        "keepsessionalive": false,
        "name": "",
        "x": 460.93326568603516,
        "y": 339.93335914611816,
        "wires": [
            [
                "05cad23cc3152ad8",
                "7f1a8165644967b8"
            ],
            [],
            []
        ]
    },
    {
        "id": "062398eb8c4d4b6d",
        "type": "OpcUa-Item",
        "z": "d46daf54501e291d",
        "item": "ns=2;s=type=0&circ=0&slavenr=1.ProcessData.InputData",
        "datatype": "Byte",
        "value": "",
        "name": "",
        "x": 280.7333755493164,
        "y": 339.6667585372925,
        "wires": [
            [
                "20d51df8772ac674"
            ]
        ]
    },
    {
        "id": "05cad23cc3152ad8",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "Output of OPC client",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 689.9333877563477,
        "y": 326.9333906173706,
        "wires": []
    },
    {
        "id": "166bcf76d196177e",
        "type": "buffer-parser",
        "z": "d46daf54501e291d",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16le",
                "name": "pressureSensorValue",
                "offset": 10,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "return",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": false,
        "outputs": 1,
        "x": 872.2222709655762,
        "y": 264.00007152557373,
        "wires": [
            [
                "a2e5ad7a2c35696c",
                "7458146d6ba70545"
            ]
        ]
    },
    {
        "id": "a2e5ad7a2c35696c",
        "type": "function",
        "z": "d46daf54501e291d",
        "name": "Scaling with 0.00025",
        "func": "var valueFromObject = Object.values(msg.payload);\nvar finalPressureValue = Number(valueFromObject);\nmsg.payload = Number(((finalPressureValue * 0.00025)- 0.25).toFixed(3));\nnode.status({ fill: \"red\", shape: \"ring\", text: msg.payload });\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1085.333236694336,
        "y": 246.22223663330078,
        "wires": [
            [
                "96e5732431e7159a"
            ]
        ]
    },
    {
        "id": "7458146d6ba70545",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "Output of Parser",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1069.111125946045,
        "y": 297.11112213134766,
        "wires": []
    },
    {
        "id": "96e5732431e7159a",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "Final pressure Value",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1141.111068725586,
        "y": 162.11110591888428,
        "wires": []
    },
    {
        "id": "866d89542c3718d7",
        "type": "OpcUa-Item",
        "z": "d46daf54501e291d",
        "item": "ns=2;s=type=0&circ=0&slavenr=2.ProcessData.InputData",
        "datatype": "Byte Array",
        "value": "",
        "name": "",
        "x": 297.11112213134766,
        "y": 540.111123085022,
        "wires": [
            [
                "936db14a473ab75b"
            ]
        ]
    },
    {
        "id": "936db14a473ab75b",
        "type": "OpcUa-Client",
        "z": "d46daf54501e291d",
        "endpoint": "d5876577da118764",
        "action": "read",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "useTransport": false,
        "maxChunkCount": 1,
        "maxMessageSize": 8192,
        "receiveBufferSize": 8192,
        "sendBufferSize": 8192,
        "setstatusandtime": false,
        "keepsessionalive": false,
        "name": "",
        "x": 485.11112213134766,
        "y": 540.1111240386963,
        "wires": [
            [
                "a607bbea08af8f97",
                "13b6ec4236cb4585"
            ],
            [],
            []
        ]
    },
    {
        "id": "a607bbea08af8f97",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "Output of OPC client",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 708.1111221313477,
        "y": 528.111123085022,
        "wires": []
    },
    {
        "id": "d5b6cef6647867bf",
        "type": "buffer-parser",
        "z": "d46daf54501e291d",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16le",
                "name": "TiltingTableAngle",
                "offset": 2,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.01",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "return",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": false,
        "outputs": 1,
        "x": 900.1111259460449,
        "y": 587.1111545562744,
        "wires": [
            [
                "89189a0edce3a835"
            ]
        ]
    },
    {
        "id": "89189a0edce3a835",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "debug 9",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1061.1110649108887,
        "y": 586.1111555099487,
        "wires": []
    },
    {
        "id": "cf73580e64c54f94",
        "type": "inject",
        "z": "d46daf54501e291d",
        "name": "",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 123.11112213134766,
        "y": 695.222240447998,
        "wires": [
            [
                "e2297343b184f20a"
            ]
        ],
        "l": false
    },
    {
        "id": "e2297343b184f20a",
        "type": "function",
        "z": "d46daf54501e291d",
        "name": "Fake Port1 data (Uint8Array)",
        "func": "msg.payload = new Uint8Array([94,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0])\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 288.11112213134766,
        "y": 695.222240447998,
        "wires": [
            [
                "787c7220c0098364",
                "e8ac9b93237b3259"
            ]
        ]
    },
    {
        "id": "e8ac9b93237b3259",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "OPC UA Data",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 348.11112213134766,
        "y": 755.222240447998,
        "wires": []
    },
    {
        "id": "787c7220c0098364",
        "type": "function",
        "z": "d46daf54501e291d",
        "name": "Convert to Buffer",
        "func": "msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 558.1111221313477,
        "y": 695.222240447998,
        "wires": [
            [
                "2609f20636755837"
            ]
        ]
    },
    {
        "id": "2609f20636755837",
        "type": "debug",
        "z": "d46daf54501e291d",
        "name": "Converted for parser",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 628.1111221313477,
        "y": 755.222240447998,
        "wires": []
    },
    {
        "id": "7f1a8165644967b8",
        "type": "function",
        "z": "d46daf54501e291d",
        "name": "Convert to Buffer",
        "func": "msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 682.1111297607422,
        "y": 264.2222366333008,
        "wires": [
            [
                "166bcf76d196177e"
            ]
        ]
    },
    {
        "id": "13b6ec4236cb4585",
        "type": "function",
        "z": "d46daf54501e291d",
        "name": "Convert to Buffer",
        "func": "msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 702.1111221313477,
        "y": 588.2222394943237,
        "wires": [
            [
                "d5b6cef6647867bf"
            ]
        ]
    },
    {
        "id": "6c8927a5ed0034ab",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.1.200",
        "port": 1883,
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": 4,
        "keepalive": 60,
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "d5876577da118764",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://192.168.10.40:4840",
        "secpol": "Basic256",
        "secmode": "Sign",
        "none": false,
        "login": true,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    },
    {
        "id": "d95953a57a8ab1a5",
        "type": "global-config",
        "env": [],
        "modules": {
            "node-red-contrib-opcua": "0.2.340",
            "node-red-contrib-buffer-parser": "3.2.2"
        }
    }
]

Your flow:

When you provide sample data PLEASE provide what value you expect these to be.

Does this look right?

[{"id":"cf58c22509393b43","type":"function","z":"307abce67fc6d2da","name":"OPC Data Uint8Array \\n 0,0,0,0,0,0,0,0,0,0,103,91,0,0,0,0","func":"msg.payload = new Uint8Array([0,0,0,0,0,0,0,0,0,0,103,91,0,0,0,0])\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":320,"wires":[["e7879cd9668d6c12","2d9aea3bf657076d"]]},{"id":"8238f2a20d99d533","type":"inject","z":"307abce67fc6d2da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":175,"y":320,"wires":[["cf58c22509393b43"]],"l":false},{"id":"e7879cd9668d6c12","type":"debug","z":"307abce67fc6d2da","name":"Output of OPC client","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":640,"y":360,"wires":[]},{"id":"2d9aea3bf657076d","type":"function","z":"307abce67fc6d2da","name":"Convert to Buffer","func":"msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":280,"wires":[["e946850af2adadcb"]]},{"id":"e946850af2adadcb","type":"buffer-parser","z":"307abce67fc6d2da","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"pressure","offset":10,"length":1,"offsetbit":0,"scale":">> 3","mask":""},{"type":"bool","name":"out1","offset":10,"length":1,"offsetbit":0,"scale":">> 3","mask":""},{"type":"bool","name":"out2","offset":10,"length":1,"offsetbit":1,"scale":">> 3","mask":""},{"type":"bool","name":"diagnostics","offset":10,"length":1,"offsetbit":2,"scale":">> 3","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":false,"outputs":1,"x":850,"y":280,"wires":[["1d4c22374437109c","3459fb8e3c35b3d2"]]},{"id":"1d4c22374437109c","type":"function","z":"307abce67fc6d2da","name":"Scaling with 0.00025","func":"const original = { ...msg.payload}\nmsg.payload.pressure = ((msg.payload.pressure * 0.00025) - 0.25)\nmsg.payload.pressureUnit = 'Mpa'\nmsg.payload.pressureFormula = '(v * 0.00025) - 0.25'\nmsg.payload.out1 = msg.payload.out1 ? 1 : 0\nmsg.payload.out2 = msg.payload.out1 ? 1 : 0\nmsg.payload.diagnostics = msg.payload.diagnostics ? \"Abnormal\" : \"Normal\"\nmsg.payload._raw = original\nnode.status({ fill: \"red\", shape: \"ring\", text: msg.payload.pressure.toFixed(3) });\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":280,"wires":[["19f96a99c9927d6c"]]},{"id":"3459fb8e3c35b3d2","type":"debug","z":"307abce67fc6d2da","name":"Output of Parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1060,"y":340,"wires":[]},{"id":"19f96a99c9927d6c","type":"debug","z":"307abce67fc6d2da","name":"Final pressure Value","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1320,"y":280,"wires":[]}]

The important bits:

  • byte swap the data and use UINT BE
  • Shift the value to bit 0

Sir I have no idea what this values should be from sensor as this is converted by OPC Server.

See how i do in siemens PLC where I know what my RAW count is .

No Steve Sir,
I copied your code and tried but it is incorrect.
I see pressure of 0.5 Mpa and with your code it is 1.0512 Mpa

As far as I can see it is correct.

[{"id":"8238f2a20d99d533","type":"inject","z":"307abce67fc6d2da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":175,"y":320,"wires":[["cf58c22509393b43"]],"l":false},{"id":"e7879cd9668d6c12","type":"debug","z":"307abce67fc6d2da","name":"Output of OPC client","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":640,"y":360,"wires":[]},{"id":"e946850af2adadcb","type":"buffer-parser","z":"307abce67fc6d2da","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"pressure","offset":10,"length":1,"offsetbit":0,"scale":">> 3","mask":""},{"type":"bool","name":"out1","offset":10,"length":1,"offsetbit":0,"scale":">> 3","mask":""},{"type":"bool","name":"out2","offset":10,"length":1,"offsetbit":1,"scale":">> 3","mask":""},{"type":"bool","name":"diagnostics","offset":10,"length":1,"offsetbit":2,"scale":">> 3","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":false,"outputs":1,"x":850,"y":280,"wires":[["1d4c22374437109c","3459fb8e3c35b3d2"]]},{"id":"1d4c22374437109c","type":"function","z":"307abce67fc6d2da","name":"Scaling with 0.00025","func":"const original = { ...msg.payload}\nmsg.payload.pressure = ((msg.payload.pressure * 0.00025) - 0.25)\nmsg.payload.pressureUnit = 'Mpa'\nmsg.payload.pressureFormula = '(v * 0.00025) - 0.25'\nmsg.payload.out1 = msg.payload.out1 ? 1 : 0\nmsg.payload.out2 = msg.payload.out1 ? 1 : 0\nmsg.payload.diagnostics = msg.payload.diagnostics ? \"Abnormal\" : \"Normal\"\nmsg.payload._raw = original\nnode.status({ fill: \"red\", shape: \"ring\", text: msg.payload.pressure.toFixed(3) });\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":280,"wires":[["19f96a99c9927d6c"]]},{"id":"3459fb8e3c35b3d2","type":"debug","z":"307abce67fc6d2da","name":"Output of Parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1060,"y":340,"wires":[]},{"id":"19f96a99c9927d6c","type":"debug","z":"307abce67fc6d2da","name":"Final pressure Value","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1320,"y":280,"wires":[]},{"id":"2d9aea3bf657076d","type":"function","z":"307abce67fc6d2da","name":"Convert to Buffer","func":"msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":280,"wires":[["e946850af2adadcb"]]},{"id":"cf58c22509393b43","type":"function","z":"307abce67fc6d2da","name":"OPC Data Uint8Array \\n 0,0,0,0,0,0,0,0,0,0,103,91,0,0,0,0","func":"msg.payload = new Uint8Array([0,0,0,0,0,0,0,0,0,0,103,91,0,0,0,0])\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":320,"wires":[["9558d92e59f5a64f"]]},{"id":"dc24d34e57670ec9","type":"inject","z":"307abce67fc6d2da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":175,"y":240,"wires":[["23da6c6f4ad10283"]],"l":false},{"id":"23da6c6f4ad10283","type":"buffer-maker","z":"307abce67fc6d2da","name":"faking Siemens PLC","specification":"spec","specificationType":"ui","items":[{"name":"item0","type":"uint16be","length":1,"dataType":"num","data":"0"},{"name":"item1","type":"int16be","length":1,"dataType":"num","data":"0"},{"name":"item2","type":"int16be","length":1,"dataType":"num","data":"0"},{"name":"item3","type":"int16be","length":1,"dataType":"num","data":"0"},{"name":"item4","type":"int16be","length":1,"dataType":"num","data":"0"},{"name":"item5","type":"uint32le","length":1,"dataType":"num","data":"26451"},{"name":"item7","type":"uint16be","length":1,"dataType":"num","data":"0"},{"name":"item8","type":"uint16be","length":1,"dataType":"num","data":"0"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":320,"y":240,"wires":[["9558d92e59f5a64f"]]},{"id":"9558d92e59f5a64f","type":"junction","z":"307abce67fc6d2da","x":520,"y":320,"wires":[["2d9aea3bf657076d","e7879cd9668d6c12"]]}]

Steve Sir,

This is 100 percent correct but how did you do this ? I am trying the same and not getting answer.
The raw count is same as SIEMENS and the value of pressure is also perfectly matching.

Steve Sir,

Thank you very much for your support.
I wasted lot of your time yesterday.
Sorry for that.
I appreciate that you took time out from your busy schedule to help me and all other node red members. Highly appreciated.

I started fresh in the morning today and used your concept of buffer and is very helpful and got all desired results.

But for today I still have doubt that yesterday why did you use UINT32(le) in "UI" configuration and not "UINT16(be)" ?

I also understood that you placed that value at item 5 because my data was on byte 10,
Each item is of 2 bytes so my data should be on item 5 or Index 5 of an array.
But confused why did you take datatype as "Uint32" and "little endian".

Thank you so much for your support.

1 Like

Final results of my project.

Thanks a lot.

I have also sent you a request on "LinkedIn" to connect.
Hoping for a positive response.

1 Like