Hi folks, I'm very green to this whole thing (downloaded Mosquitto exactly a week ago, Node-RED a day or two later, working on this project at work while doing my other duties) so please excuse me if I'm missing a fundamental(s) here...
I'm running Node-RED v2.2.2, node-red-dashboard v3.1.6, Mosquitto 2.0.14, and a ClickPlus PLC on V3.21.
My goal is to create a relatively simple proof of concept dashboard I can host on a webpage only accessible within our LAN, so I can show higher ups we've got a foundation we can build off of to take our IIoT offerings to the next level. This is going surprisingly well, but I have a hiccup. The PLC can send information to me just fine, but now I want to send commands to it (just tell it to turn an LED on or off). I've configured a node-red-dashboard ui_switch to attempt the first step of this but when I click it, my Node-RED gives me a series of errors, and I have to close and restart to reestablish connection.
I've created a dashboard, and the gauges are working successfully, I can have my coworker move transducers and they respond immediately. The switch is giving me trouble though...
Here's how I have the switch and its accessories formatted-
This is driving me crazy since I think I've gotten relatively good with this given the limited amount of time I've used this tool but I can't wrap my head around the issue here. Please help!
You have spaces in the Topic field
global.LED Control. You can't (easily) have spaces in a global context name. Are you sure that is what you want anyway? What are you trying to achieve with that?
Also be very careful with what you have. Since you have specified message passthrough you may find yourself in an infinite loop via MQTT. It is generally best not to specify pass through.
I'm not sure how that field should be configured yet- I thought it would work similarly to the other MQTT Topics I've been working with but now that you mention it, I have had issues with spaces in there. Thank you! Should I format as a msg or as global?
I removed the space and it seems to be working correctly... now- I need to get the ClickPlus to accept the command and turn on an LED with it!
I'm not quite following the second post about infinite loops.. should I remove one of the MQTT in or MQTT out fields(EDIT: nodes, not fields)?
I don't know exactly what you are doing, so it may not be a problem in this case. The potential problem is that when an MQTT message arrives it sets the switch position, but because you have pass through enabled the message will be passed on to the next node. If that then goes on to the MQTT Out node and publishes to the same topic then that will trigger another message from the MQTT In node which does the same thing, so the message goes round and round as fast as it can. Usually you only want an output from the switch when the user clicks it, if that is the case then de-select the pass through option.
Ahh- I think I know what you mean now. What I want this switch to do is turn an LED on the PLC on or off, and display the current status of the LED. I figure it'd be the simplest way to prove we can control the PLC from another device.
I've modified it now so that the nodes are all still arranged the way they were before, but I've disabled the Pass through option and chosen the "Switch icon shows state of the input" option for the Indicator. Would this be a step in the right direction for this goal? I want the switch to display whether the LED is actually on or not, rather than whatever the switch was last set to.
Yes that is exactly right (at least it is the way I would do it). So when you press the switch it sends the On or Off message and when the confirmation comes back then the switch display changes. Also if something else changes the led then the switch will follow.
Thank you Colin! I've got it set up that way. Still having issues communicating between Click and Node but I suppose I ought to make a separate topic for that.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.