One node-red device to ctl another node-red device

is there a way to get one node red to send commands to another node-red device

Cross posted - https://node-red.slack.com/archives/C03M2TAQ8/p1527514230000511

I’d imagine MQTT would be the simplest if the flows are running on different machines

hi
I am sure it would if only I could get my head around it
did try to load mqtt my server 2012 but it failed
I only want to read a sensor from one drive and do something on another & I just don’t find this node-red stuff very easy to understand (not looking at doing anything cloud based either)

Well MQTT is, as far as I know, the easiest way to get data between parts of a node-red system. Start here https://www.hivemq.com/mqtt-essentials/

Once you have read that and understood the basics then if you can’t get it running you can ask here.

Some of it isn't and it is quite different to other methods (such as traditional programming languages)

But if you think about it, how easy would it be to get get a program on one computer to send a message to another computer using a traditional programming language?

Quite hard.
MQTT is considered a really good way of passing messages between computers

Here are example flows of sending and receiving a message via a public MQTT broker

[{"id":"89481906.6eedf8","type":"inject","z":"e03a15ac.7a2328","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":140,"wires":[["eaecf0ac.de2eb"]]},{"id":"eaecf0ac.de2eb","type":"mqtt out","z":"e03a15ac.7a2328","name":"","topic":"cymplecy/timestamp","qos":"","retain":"true","broker":"b045d3bf.c4b8a","x":600,"y":140,"wires":[]},{"id":"93c8e193.5b8a9","type":"mqtt in","z":"e03a15ac.7a2328","name":"","topic":"cymplecy/timestamp","qos":"2","broker":"b045d3bf.c4b8a","x":300,"y":260,"wires":[["b7dbe4fe.aaf0c8"]]},{"id":"b7dbe4fe.aaf0c8","type":"debug","z":"e03a15ac.7a2328","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":580,"y":260,"wires":[]},{"id":"b045d3bf.c4b8a","type":"mqtt-broker","z":"","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

RabbitMQ is a good cross-platform, open-source, ‘local’ broker (supports many protocols as well as MQTT).

Well, it all depends on what you want to do exactly but if MQTT is too hard, why not use simple HTTP requests ?
This method is “node-red-ready” as it does not require any additional software like a MQTT broker …
Create a flow on NodeRed #1 including a “HTTP IN” node
Create another flow NodeRed #2 sending an HTTP request to the http path defined on NodeRed #1

Maybe it would help if you explained in a little more detail. What setup do you have? It looks like you are using Windows Server? Are the 2 Node-RED instances actually on different devices?

Answers to these questions would help us focus in on some possible solutions.

There are loads of tutorials on installing the Mosquitto MQTT broker for example, but mainly on Linux. Windows isn't really any harder but is a slightly different when you want to productionize it.

ok
want to keep it simple and in house
I have a pi zero on ip address 192.168.7.80:1880 which reads a sensor etc (infred diodie)
using node red
I then have another pi zero also running node-red on ip-address 192.168.7.81:1880 which has a motor on it which again I can control

I want a reliable way to get the sensor from the 1st one turning the motor etc on the second one which I am sure is fairly straight forward.
but im not very good with linx (far to used to Microsoft & networking at ip level)

I have pc servers that could host things if need be but eclipse MQTT did not seem to like server 2012 etc.

hope this is a bit clearer

To install the broker on either of the PIs:
sudo apt-get update && sudo apt-get install -y mosquitto

You can install the clients on both with:
sudo apt-get update && sudo apt-get install -y mosquitto-clients

Assuming you installed the broker on 192.168.7.80…

On 192.168.7.80, open a terminal and type:
mosquitto_sub -d -t hello/world

On 192.168.7.81, open a terminal and type:
mosquitto_pub -d -h 192.168.7.80 -t hello/world -m “Hello from 192.168.7.81”

This should result in something like below in the terminal on 192.168.7.80

Hello from 192.168.7.81

Once you’ve got that working, using MQTT is just as easy in NR.

ok thanks I will have a play

It is in fact very easy once you get more "warmed up". There is a learning curve as usual. As with everything in life. Training for a driver license, training & experience to make your girlfriend/wife happier, etc etc

But sometimes the forest is hidden by all the trees (A saying in my country)

But I can tell you, it works very well. Exactly what you wanna do I do but with other messages and other devices to control. Rock solid.

Right, I can see that there are lots of external dependencies for running Mosquitto on Windows. You would probably be better off with RabbitMQ or EMQ (emqtt.io). Mosquitto is favoured by Pi users due to its low resource requirements.

But one of your Pi Zero's should be fine - just don't try to create too big a set of Node-RED flows. If you find the Pi0 getting slow or cranky due to low resources or high CPU, simply add another Pi0 just to run Mosquitto. It should go without saying that you should adjust the startup of the Pi to exclude the Linux GUI as this takes up loads of resources you don't need to use. I don't use a zero but I've had a reasonably complex set of Node-RED flows along with Mosquitto and a database running on an original Pi without any issues.

@asandford has given you the basics for installation. There are plenty of other tutorials around as well.

A really good source for learning about MQTT is the HiveMQ Essentials documentation (MQTT Essentials - All Core Concepts Explained).

At first all you really need to remember is that MQTT is a publish and subscribe message handler (think email for machines). In Node-RED, you use the msg.topic to control the MQTT topic that you publish or subscribe to.

You might also want to grab a copy of MQTT Spy (Home · eclipse/paho.mqtt-spy Wiki · GitHub) which is a Java based (we try not to hold that against it!) cross-platform GUI tool that will let you easily explore your MQTT broker.

A pi zero will easily handle node-red and mosquitto provided you do not have hundreds of nodes or hundreds of messages/second.

Thank you
very helpful I will look into this

hi
have just tried this
is this secure & can you just send what ever you like across it (apart from needing internet access to use it ) whats the advantage in set a local broker up?

Its not secure (as its a public broker - people just use it for convenience and testing )

You can send what you like ( within normal MQTT restraints)

The advantage is that it doesn’t need setting up :slight_smile:

Another alternative, is to install the node-red-contrib-mqtt-broker and just run that on one of the Pi

Examples attached

Sending Pi

[{"id":"94e9199b.e746a8","type":"inject","z":"768dfbdd.ae43a4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":140,"wires":[["45565d46.f8a2b4"]]},{"id":"45565d46.f8a2b4","type":"mqtt out","z":"768dfbdd.ae43a4","name":"","topic":"cymplecy/timestamp","qos":"","retain":"true","broker":"6711f1f2.75f57","x":580,"y":140,"wires":[]},{"id":"ca85b417.4a96d8","type":"mosca in","z":"768dfbdd.ae43a4","mqtt_port":"1883","mqtt_ws_port":8080,"name":"","username":"","password":"","dburl":"","x":270,"y":80,"wires":[[]]},{"id":"6711f1f2.75f57","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

receiving Pi
(change IP to be the address of the sending Pi)

[{"id":"6e223577.bc14bc","type":"mqtt in","z":"768dfbdd.ae43a4","name":"","topic":"cymplecy/timestamp","qos":"2","broker":"4fb8043.49c20fc","x":280,"y":260,"wires":[["8d67a7b4.987368"]]},{"id":"8d67a7b4.987368","type":"debug","z":"768dfbdd.ae43a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":560,"y":260,"wires":[]},{"id":"4fb8043.49c20fc","type":"mqtt-broker","z":"","name":"","broker":"aaa.bbb.ccc.ddd","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Thanks for the heads-up on that, here's a video by Peter Scargill demonstrating it.

Thank you so much. it became so much clearer with the example code that you have supplied

I have managed to get the two board to communicate (using the cloud base one so far)

most helpfull