# Use modebus node -- modbus/tcp --

**URL:** <https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856>\
**Category:** Dashboard\
**Created:** [28 April 2021 10:12 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856 "2021-04-28T10:12:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyred](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lyred](https://discourse.nodered.org/u/lyred)\
**Post date:** [28 April 2021 10:12 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856/1 "2021-04-28T10:12:27Z")

</div>

hello team,

on node red I want to use the **tcp modbus** to have the data of at least **10 sensors** , for this I want to use a Flex Getter modbus and configure it in TCP by giving it the sensor address and the port.

**is that the right noed ??!**

to use this node I must configure **msg.payload** in a function " **msg.payload = { value: msg.payload, 'fc': 1, 'unitid': 1, 'address': 0 , 'quantity': 1 } return msg "**

is that for each sensor I have to make him **a special node** modbus Flex Getter for him ! since they have different addresses.  
also what it means ' **unitid'** in **msg.payload.**

The attached figures explains a little bit what I want.

thanks for your answers..

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/ccffd17b6f0273815a710bbf6a34802c64636840.png) ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7e08b6a8d54e22b94a38cafcff53cc6c6523a118.png)

---

<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:** [28 April 2021 10:23 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856/2 "2021-04-28T10:23:43Z")

</div>

> [@lyred](#):
>
> is that for each sensor I have to make him **a special node** modbus Flex Getter for him ! since they have different addresses.

what addresses are you wanting to read?

If all addresses are near each other (e.g. Address 0, 1, 10 and 25) then I would strongly recomend reading 26 items in one go and pick out the values you need.

It is ...

- far more efficient
  - 1 communication requesting 26 items is MUCH better and much faster than requesting 4 separate times a single item

- and less troublesome
  - you get consistent data - i.e. all items are read at the same time
  - you have all values in one place (making it easy to do calcs etc)

---

<div class="post-metadata">

**Author:** ![lyred](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lyred](https://discourse.nodered.org/u/lyred)\
**Post date:** [28 April 2021 10:33 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856/3 "2021-04-28T10:33:03Z")

</div>

thanks for your reply.

he addresses are near for example : 192.168.10.1 .... 192.168.10.2 ... 192.168.10.3 .... 4 .... 5 ....

how can i read everyone at once ?

also what it means ' **unitid'** in **msg.payload.** it is the ID ?

---

<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:** [28 April 2021 10:40 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856/4 "2021-04-28T10:40:35Z")

</div>

> [@lyred](#):
>
> he addresses are near for example : 192.168.10.1 .... 192.168.10.2 ... 192.168.10.3 .... 4 .... 5 ....

when i said "If all addresses are near each other (e.g. Address 0, 1, 10 and 25) then I would strongly recomend reading 26 items in one go" I was referring to the "modbus register address" (not the ip address)

For reading values from more than one modbus tcp device, you will need to setup a config for each device & a separate flex-getter to request from each devices.

> [@lyred](#):
>
> also what it means ' **unitid'**

The unit id comes into play when several devices are connected to one IP address. This is not a common scenario. Normally the unit id is set to 1. Most modbus tcp devices ignore this.

---

<div class="post-metadata">

**Author:** ![lyred](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lyred](https://discourse.nodered.org/u/lyred)\
**Post date:** [28 April 2021 12:12 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856/5 "2021-04-28T12:12:12Z")

</div>

thanks a lot

---

<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:** [12 May 2021 12:13 UTC](https://discourse.nodered.org/t/use-modebus-node-modbus-tcp/44856/6 "2021-05-12T12:13:05Z")

</div>

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