# Node-red connect PLC to dashboard

**URL:** <https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473>\
**Category:** General\
**Created:** [10 July 2018 03:31 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473 "2018-07-10T03:31:23Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 03:31 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/1 "2018-07-10T03:31:23Z")

</div>

Hi,

i have project using Node-red to connect with PLC. i want take data from some address in PLC and show it to dashboard.  
i have problem, how to solve %MW100:X1 / %MW100:X2 of PLC with some variable?

![node1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9133b8a93d1b36e2917dd4d6a3deababe66a8c14.PNG)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [10 July 2018 06:24 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/2 "2018-07-10T06:24:07Z")

</div>

so what have you tried? Where are you stuck?

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 06:37 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/3 "2018-07-10T06:37:38Z")

</div>

i mean, how to make 1 address plc can contains all the variable?

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 06:39 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/4 "2018-07-10T06:39:13Z")

</div>

usually i make 1 address for 1 variable value. not for 1 module plc.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [10 July 2018 08:15 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/5 "2018-07-10T08:15:52Z")

</div>

You've not said what node you are using or given any example of your flow.

But if you would normally obtain one variable you could do that twice to pick up both variables and then use the join node to get them into one message in Node-RED

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 08:39 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/6 "2018-07-10T08:39:57Z")

</div>

sorry, i want use a simple node red like this.

![contoh%20node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/33611e4a4a4a662c821ae74ef7eb2c13bc88e445.PNG)

how the formula to using 1 address from PLC with the many variable like list picture before.  
because usually, i make 1 address for 1 variable value from PLC.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [10 July 2018 08:52 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/7 "2018-07-10T08:52:24Z")

</div>

As you want to do something that is more complex your flow will get more complex too.  
Try something like below:

```
[modbus tcp]-|
             |---[join]---[function]-
[modbus tcp]-|
```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 July 2018 08:58 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/8 "2018-07-10T08:58:22Z")

</div>

I assume you are using node-red-modbus-tcp (though you have not told us that, you could name any node modubustcp on the flow) then the readme says you can pass in a payload telling it what to read and what topic to set for the answer. I think that rather than trying to get them all in one go (which may be possible, I don't know) then send in a sequence of messages and get them one after another with different topics. Then you can use the topic to know what is in each reply (in a switch node or function node for example) and do whatever is required with each one.

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 10:15 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/9 "2018-07-10T10:15:01Z")

</div>

if i join 2 modbus, so i need 2 address for plc, right? and i just call the other address with extend the quantity in modbustcp.

but thanks for your idea.

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 10:16 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/10 "2018-07-10T10:16:16Z")

</div>

yeah i want all of them go. but in 1 address.🙂

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [10 July 2018 10:23 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/11 "2018-07-10T10:23:14Z")

</div>

I want all of the data get out, one by one.  
Depend of the situation 😀

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 July 2018 10:46 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/12 "2018-07-10T10:46:00Z")

</div>

> [@anggarabaihramsyah](#):
>
> yeah i want all of them go. but in 1 address.

Why?  
What is wrong with getting them one at time as a sequence of messages?

[Edit] If you want to show them on the dashboard you would have to split them up anyway, with them coming as a sequence you can use a Switch node to send them each to the appropriate dashboard nodes.

---

<div class="post-metadata">

**Author:** ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://discourse.nodered.org/u/Cristiano)\
**Post date:** [11 July 2018 00:36 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/13 "2018-07-11T00:36:17Z")

</div>

Hello

Do u want read or write ? or both ?

Usually what is usual to do is to read the word of the plc, in decimal for example and then break the word by the weight of the bits and so you know which active bit .... in modbus there are several functions to read or write, for example the function 1 can read only one bit.  
More info, about modbus function: [https://en.wikipedia.org/wiki/Modbus](https://en.wikipedia.org/wiki/Modbus)

I also advise using the modbus node in the image

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1beabf366f5ee96be80103ec44c7d4080be008f9.png)

---

<div class="post-metadata">

**Author:** ![anggarabaihramsyah](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@anggarabaihramsyah](https://discourse.nodered.org/u/anggarabaihramsyah)\
**Post date:** [11 July 2018 02:21 UTC](https://discourse.nodered.org/t/node-red-connect-plc-to-dashboard/1473/14 "2018-07-11T02:21:28Z")

</div>

all right, thanks for the idea.  
i will try something with it.

 ![testing](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e43bb040456843fa237d6714d944dcb82e3f15af.png)
