# Write data to plc using s7 comm

**URL:** <https://discourse.nodered.org/t/write-data-to-plc-using-s7-comm/88521>\
**Category:** Industrial\
**Created:** [5 June 2024 12:46 UTC](https://discourse.nodered.org/t/write-data-to-plc-using-s7-comm/88521 "2024-06-05T12:46:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_1711](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@Mohamed\_1711](https://discourse.nodered.org/u/Mohamed_1711)\
**Post date:** [5 June 2024 12:46 UTC](https://discourse.nodered.org/t/write-data-to-plc-using-s7-comm/88521/1 "2024-06-05T12:46:39Z")

</div>

Can I minimize this Flow to be in one flow:

```auto
[
    {
        "id": "854bd5d297c3580f",
        "type": "s7comm write",
        "z": "9d4d11fb464940c4",
        "connection": "9f73cf0bb98275cb",
        "payload": "{\"S7_Type\":\"DB\",\"S7_DBnum\":\"1010\",\"S7_Datatype\":\"DI\",\"S7_Offset\":\"106\",\"S7_BitOffset\":\"0\",\"S7_Quantity\":\"1\",\"S7_Name\":\"JOB\"}",
        "s7Name": "JOB",
        "topic": "",
        "name": "PROGRAM",
        "signalSetted": false,
        "x": 670,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "82f73117a7bfd407",
        "type": "s7comm write",
        "z": "9d4d11fb464940c4",
        "connection": "9f73cf0bb98275cb",
        "payload": "{\"S7_Type\":\"DB\",\"S7_DBnum\":\"1010\",\"S7_Datatype\":\"DI\",\"S7_Offset\":\"106\",\"S7_BitOffset\":\"0\",\"S7_Quantity\":\"1\",\"S7_Name\":\"JOB\"}",
        "s7Name": "JOB",
        "topic": "",
        "name": "JOB",
        "signalSetted": false,
        "x": 650,
        "y": 380,
        "wires": [
            []
        ]
    },
    {
        "id": "e0868309fa5adf09",
        "type": "s7comm write",
        "z": "9d4d11fb464940c4",
        "connection": "9f73cf0bb98275cb",
        "payload": "{\"S7_Type\":\"DB\",\"S7_DBnum\":\"1010\",\"S7_Datatype\":\"CHAR\",\"S7_Offset\":\"130\",\"S7_BitOffset\":\"0\",\"S7_Quantity\":\"1\",\"S7_Name\":\"JOB_CODE\"}",
        "s7Name": "JOB_CODE",
        "topic": "",
        "name": "JOB_CODE",
        "signalSetted": false,
        "x": 670,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "2afbc11059ad53c7",
        "type": "function",
        "z": "9d4d11fb464940c4",
        "name": "PORGRAM",
        "func": "msg.payload = { \"value\":125 }\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 320,
        "wires": [
            [
                "854bd5d297c3580f"
            ]
        ]
    },
    {
        "id": "c3df54979d701f33",
        "type": "function",
        "z": "9d4d11fb464940c4",
        "name": "JOB",
        "func": "msg.payload = { \"value\": 343 }\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 380,
        "wires": [
            [
                "82f73117a7bfd407"
            ]
        ]
    },
    {
        "id": "75e401bb11f870c8",
        "type": "function",
        "z": "9d4d11fb464940c4",
        "name": "JOB CODE",
        "func": "msg.payload = {\n \"value\": 'F'\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 440,
        "wires": [
            [
                "e0868309fa5adf09"
            ]
        ]
    },
    {
        "id": "39d9b6516dd05e97",
        "type": "inject",
        "z": "9d4d11fb464940c4",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 240,
        "y": 420,
        "wires": [
            [
                "2afbc11059ad53c7",
                "c3df54979d701f33",
                "75e401bb11f870c8"
            ]
        ]
    },
    {
        "id": "9f73cf0bb98275cb",
        "type": "s7comm",
        "ip": "172.31.51.13",
        "port": "102",
        "rack": "0",
        "slot": "4",
        "payload": [
            {
                "S7_Type": "DB",
                "S7_DBnum": "1010",
                "S7_Datatype": "DI",
                "S7_Offset": "102",
                "S7_BitOffset": "0",
                "S7_Quantity": "1",
                "S7_Name": "PROGRAM"
            },
            {
                "S7_Type": "DB",
                "S7_DBnum": "1010",
                "S7_Datatype": "DI",
                "S7_Offset": "106",
                "S7_BitOffset": "0",
                "S7_Quantity": "1",
                "S7_Name": "JOB"
            },
            {
                "S7_Type": "DB",
                "S7_DBnum": "1010",
                "S7_Datatype": "CHAR",
                "S7_Offset": "130",
                "S7_BitOffset": "0",
                "S7_Quantity": "1",
                "S7_Name": "JOB_CODE"
            }
        ]
    }
]

```

 ![Flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9d4a8eae56fbdb39f52c63b55c03038c447014ec.png)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [5 June 2024 15:54 UTC](https://discourse.nodered.org/t/write-data-to-plc-using-s7-comm/88521/2 "2024-06-05T15:54:07Z")

</div>

Make a subflow?? Or what do you like todo?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 June 2024 17:00 UTC](https://discourse.nodered.org/t/write-data-to-plc-using-s7-comm/88521/3 "2024-06-05T17:00:21Z")

</div>

What do you really mean?

Are you wanting to write all values in one network transmission (for data consistency improvements)?

---

<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:** [4 August 2024 17:00 UTC](https://discourse.nodered.org/t/write-data-to-plc-using-s7-comm/88521/4 "2024-08-04T17:00:29Z")

</div>

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