# Modbus TCP runtime ip

**URL:** <https://discourse.nodered.org/t/modbus-tcp-runtime-ip/58876>\
**Category:** General\
**Tags:** modbus\
**Created:** [23 February 2022 11:24 UTC](https://discourse.nodered.org/t/modbus-tcp-runtime-ip/58876 "2022-02-23T11:24:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MauroS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mauros/32/57230_2.png) [@MauroS](https://discourse.nodered.org/u/MauroS)\
**Post date:** [23 February 2022 11:24 UTC](https://discourse.nodered.org/t/modbus-tcp-runtime-ip/58876/1 "2022-02-23T11:24:43Z")

</div>

Hey everybody,  
I'm using node-red-contrib-modbus and made successfully a modbus tcp connection, even read and write mode.

I trying to find out a way to set dynamically, I mean in runtime as I do with a function node right before a flex-getter node, the client ip address, in my case is 10.0.0.10:502.  
IP is different on every installation and I don't want to hard code it every time.  
I'd prefer to do it via a dashboard

I tried to use flex-server or flex-connector but really cannot understand how to set flow or nodes to get my goal.

Any help would be welcome, or any basic example of flow which I could look into

Thanks  
M

---

<div class="post-metadata">

**Author:** ![MauroS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mauros/32/57230_2.png) [@MauroS](https://discourse.nodered.org/u/MauroS)\
**Post date:** [23 February 2022 13:59 UTC](https://discourse.nodered.org/t/modbus-tcp-runtime-ip/58876/2 "2022-02-23T13:59:04Z")

</div>

found this that could be related...

> [@IP Address as a variable](https://discourse.nodered.org/t/ip-address-as-a-variable/53225):
>
> I guess I'm reopening up my question from before: I am collecting data using Modbus TCP. I'd like the remain flexible and let the user enter their own IP address. it was brought up to use environmental variables. But maybe I'm not using the variable properly: I have a text entry and it's payload is set to $IP [image] Then under host I have this [image] calling the IP. [{"id":"dbf7fbb9.bab5b8","type":"tab","label":"Configuration","disabled":false,"info":""},{"id":"f5547811.4bbe48","typ…

---

<div class="post-metadata">

**Author:** ![MauroS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mauros/32/57230_2.png) [@MauroS](https://discourse.nodered.org/u/MauroS)\
**Post date:** [28 February 2022 10:21 UTC](https://discourse.nodered.org/t/modbus-tcp-runtime-ip/58876/4 "2022-02-28T10:21:23Z")

</div>

It seems clienttype TCP cannot override a clienttype SERIAL:  
If I try to set as TCP a modbus-client preconfigured as "serial client", this operation seem s to have no effect, and erros in debug are all about the serial client not the tcp one

I use this flow for testing

```auto
[
    {
        "id": "602c2fb9189b3c62",
        "type": "modbus-flex-getter",
        "z": "5b0dada6.2ecd9c",
        "name": "",
        "showStatusActivities": true,
        "showErrors": true,
        "logIOActivities": false,
        "server": "ebeab3422d31a778",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "x": 630,
        "y": 640,
        "wires": [
            [
                "167f353c05c28461"
            ],
            []
        ]
    },
    {
        "id": "9eb2b47107b96ed8",
        "type": "inject",
        "z": "5b0dada6.2ecd9c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 315,
        "y": 640,
        "wires": [
            [
                "2996681554f2e749"
            ]
        ],
        "l": false
    },
    {
        "id": "2996681554f2e749",
        "type": "function",
        "z": "5b0dada6.2ecd9c",
        "name": "FC 3 120.10 ",
        "func": "msg.payload = {\n fc: 3,\n address: 120,\n quantity: 10,\n}\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 640,
        "wires": [
            [
                "602c2fb9189b3c62"
            ]
        ]
    },
    {
        "id": "167f353c05c28461",
        "type": "debug",
        "z": "5b0dada6.2ecd9c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 775,
        "y": 640,
        "wires": [],
        "l": false
    },
    {
        "id": "5e8844296c95858c",
        "type": "modbus-flex-connector",
        "z": "5b0dada6.2ecd9c",
        "name": "",
        "maxReconnectsPerMinute": 4,
        "emptyQueue": false,
        "showStatusActivities": false,
        "showErrors": false,
        "server": "ebeab3422d31a778",
        "x": 730,
        "y": 580,
        "wires": [
            []
        ]
    },
    {
        "id": "b8f8914c9d5d69ae",
        "type": "function",
        "z": "5b0dada6.2ecd9c",
        "name": "TCP | 10.0.2.56:502 | 1",
        "func": "msg.payload = {\n 'connectorType': 'TCP',\n 'tcpHost': '10.0.2.56',\n 'tcpPort': '502',\n 'unitId': 1\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 470,
        "y": 580,
        "wires": [
            [
                "5e8844296c95858c"
            ]
        ]
    },
    {
        "id": "9ab09aca.ae3f08",
        "type": "inject",
        "z": "5b0dada6.2ecd9c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 315,
        "y": 580,
        "wires": [
            [
                "b8f8914c9d5d69ae"
            ]
        ],
        "l": false
    },
    {
        "id": "ebeab3422d31a778",
        "type": "modbus-client",
        "name": "",
        "clienttype": "serial",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "tcpHost": "0.0.0.0",
        "tcpPort": "0",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "unit_id": "0",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": false,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    }
]

```
