# HMI and plc control

**URL:** <https://discourse.nodered.org/t/hmi-and-plc-control/86457>\
**Category:** General\
**Created:** [15 March 2024 13:06 UTC](https://discourse.nodered.org/t/hmi-and-plc-control/86457 "2024-03-15T13:06:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![younesDV](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/younesdv/32/88130_2.png) [@younesDV](https://discourse.nodered.org/u/younesDV)\
**Post date:** [15 March 2024 13:06 UTC](https://discourse.nodered.org/t/hmi-and-plc-control/86457/1 "2024-03-15T13:06:09Z")

</div>

Hello,  
I have a simple question, is it possible to add a button on my HMI ( siemens) and by a simple click on my button it activates or desactivates a node, my HMI is controlled by a plc s7-1500.  
Thanks.

---

<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:** [15 March 2024 14:15 UTC](https://discourse.nodered.org/t/hmi-and-plc-control/86457/2 "2024-03-15T14:15:16Z")

</div>

> [@younesDV](#):
>
> I have a simple question

doubtful 😉

> [@younesDV](#):
>
> is it possible to add a button on my HMI ( siemens)

Yes, if you know how.

> [@younesDV](#):
>
> and by a simple click on my button it activates or desactivates a node

what does "activates or desactivates a node" really mean?  
If you mean "inhibit messages reaching a node" then **Yes**  
If you mean "enables and enables a node" then that is much harder (and not recommended)

> [@younesDV](#):
>
> my HMI is controlled by a plc s7-1500

In which case, you can set a flag or byte or integer in the PLC and then have Node-RED read its value and do what is necessary.

---

<div class="post-metadata">

**Author:** ![younesDV](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/younesdv/32/88130_2.png) [@younesDV](https://discourse.nodered.org/u/younesDV)\
**Post date:** [15 March 2024 14:34 UTC](https://discourse.nodered.org/t/hmi-and-plc-control/86457/3 "2024-03-15T14:34:24Z")

</div>

I meant the second option that is harder, my project is to add a button on my HMI ( already done ), and once I click on it, I start sending Data From my PLC to MYSQL, actually I've already done this part I can read data from my plc and save it on a SQL server, I just wanna control my nodered from my HMI.  
and it seems impossible I guess.  
Thanks for your reply.

---

<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:** [15 March 2024 14:36 UTC](https://discourse.nodered.org/t/hmi-and-plc-control/86457/4 "2024-03-15T14:36:47Z")

</div>

> [@younesDV](#):
>
> it seems impossible I guess

It is perfectly possible to allow / disallow messages being sent to mysql.

1. When PLC value is `true` (or `1`), set a flow context variable `flow.enableDatabase`
2. Add a switch node JUST BEFORE the mysql node that checks if `flow.enableDatabase` is `true` - and allow the messages to pass through to the database.

That is just one possibility. There are numerous other ways of handling this.

---

<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:** [13 June 2024 14:37 UTC](https://discourse.nodered.org/t/hmi-and-plc-control/86457/5 "2024-06-13T14:37:42Z")

</div>

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