# OPCUA-client Write to int32ARRAY PLC Value

**URL:** <https://discourse.nodered.org/t/opcua-client-write-to-int32array-plc-value/75344>\
**Category:** General\
**Tags:** opcua\
**Created:** [17 February 2023 12:11 UTC](https://discourse.nodered.org/t/opcua-client-write-to-int32array-plc-value/75344 "2023-02-17T12:11:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andzana](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@andzana](https://discourse.nodered.org/u/andzana)\
**Post date:** [17 February 2023 12:11 UTC](https://discourse.nodered.org/t/opcua-client-write-to-int32array-plc-value/75344/1 "2023-02-17T12:11:24Z")

</div>

Hi guys,

i've problem with OpcUa write, in the PLC the data is int32Array[201],

with the OpcUa-Cliet READ i've add a payload.range and the result is OK, read only 3° value of the PLC int32Array

```auto
[
    {
        "id": "51ab919daee71d28",
        "type": "OpcUa-Item",
        "z": "441eefb194c6bb17",
        "item": "ns=4;s=OPC_UA.diVAR",
        "datatype": "Int32 Array",
        "value": "",
        "name": "",
        "x": 360,
        "y": 60,
        "wires": [
            [
                "1c5f199d0907cf65"
            ]
        ]
    },
    {
        "id": "1c5f199d0907cf65",
        "type": "OpcUa-Client",
        "z": "441eefb194c6bb17",
        "endpoint": "0480335b7ee5b194",
        "action": "read",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "folderName4PKI": "",
        "name": "READ",
        "x": 550,
        "y": 60,
        "wires": [
            [
                "eb6dba8e85f20a76"
            ]
        ]
    },
    {
        "id": "eb6dba8e85f20a76",
        "type": "debug",
        "z": "441eefb194c6bb17",
        "name": "READxx",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 730,
        "y": 60,
        "wires": []
    },
    {
        "id": "7ba5d4a44f4f31ef",
        "type": "inject",
        "z": "441eefb194c6bb17",
        "name": "READ RANGE 3",
        "props": [
            {
                "p": "payload.range",
                "v": "3",
                "vt": "num"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 120,
        "y": 60,
        "wires": [
            [
                "51ab919daee71d28"
            ]
        ]
    },
    {
        "id": "0480335b7ee5b194",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://192.168.3.98:4840",
        "secpol": "Basic256Sha256",
        "secmode": "Sign",
        "none": true,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

```

but i've need to write only this Value (not all array)

i've try this solution but not send to PLC anything

```auto
[
    {
        "id": "1d36543af421357f",
        "type": "OpcUa-Item",
        "z": "441eefb194c6bb17",
        "item": "ns=4;s=OPC_UA.diVAR",
        "datatype": "Int32 Array",
        "value": "201",
        "name": "",
        "x": 360,
        "y": 120,
        "wires": [
            [
                "abd3c695794ccf40"
            ]
        ]
    },
    {
        "id": "abd3c695794ccf40",
        "type": "OpcUa-Client",
        "z": "441eefb194c6bb17",
        "endpoint": "0480335b7ee5b194",
        "action": "write",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "folderName4PKI": "",
        "name": "WRITE",
        "x": 550,
        "y": 120,
        "wires": [
            [
                "8b7c9778a4109563"
            ]
        ]
    },
    {
        "id": "8b7c9778a4109563",
        "type": "debug",
        "z": "441eefb194c6bb17",
        "name": "WRITExx",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 720,
        "y": 120,
        "wires": []
    },
    {
        "id": "a6fba8e66b34e16b",
        "type": "inject",
        "z": "441eefb194c6bb17",
        "name": "WRITE",
        "props": [
            {
                "p": "payload.range",
                "v": "3",
                "vt": "num"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 90,
        "y": 120,
        "wires": [
            [
                "1d36543af421357f"
            ]
        ]
    },
    {
        "id": "0480335b7ee5b194",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://192.168.3.98:4840",
        "secpol": "Basic256Sha256",
        "secmode": "Sign",
        "none": true,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

```

The PLC have enable to write, (with UaExpert i write correctly only single array value)

if i send a value msg.payload=200 without payload.range Write the value to plc but wrong and confusing about all array values

 ![Schermata 2023-02-17 alle 13.28.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/7679890b7921146500a6c79c9784c55f35dd472e.png)

I've been using Node-red for a while now, I probably don't really understand how the payload works

Thanks in advance for any help...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 April 2023 12:12 UTC](https://discourse.nodered.org/t/opcua-client-write-to-int32array-plc-value/75344/2 "2023-04-18T12:12:10Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
