Hi,
First of all this is a great forum, if we think that 10 days ago i had no idea of node red and now i can control many things on node red that is because of this community. As always i tried many things and searched google and couldn't find any information. First i should explain my intension.
I want to control my displays from node red UI. I have installed Mosquitto MQTT and Node Red on my raspi.
I have a projector and a pc screen. With a fast research i find two cmd commands "%windir%\System32\DisplaySwitch.exe /external" and "%windir%\System32\DisplaySwitch.exe /internal" that can change the displays. So i think about send a MQTT message (or what it called i don't know sorry) to my pc and execute these lines.
Next i installed Mosquitto MQTT on my win10 pc and i can get the message from node red to " mosquitto_sub.exe -h ******* -p ****** -u ****** -P ****** -t ****** ". I send the displayswitch.exe lines and nothing happened. (i know it was a bit optimistic to think that will run in first try:) ) Btw i get the messages on cmd screen but nothing happens. There is no problem on my MQTT connection.
After this point i have no clue I just want to know am i on the right path to accomplish my task or is there any other way, simple or harder doesn't matter. Can anyone direct me to the right place to look.
My native language is not English. Sorry for any grammer and other word mistakes.
Thanks.
MQTT is a broker i.e. some program on a device - for example, your Pi running Node-RED - publishes
a message to the broker with a topic
.
The broker is also running on some device - in this case it's also on your Pi. The broker now looks to see if some other program has subscribed
to the topic
of the msg that just arrived. It will then send that msg to ALL the programs that have subscribed
to that topic
.
For another device (like your PC) to receive that msg, some program (it could be another copy of node-red running on your PC) has to be using the same broker
that the msg was published to, and has to be subscribed to the topic
. You could now possibly use an exec
node on the PC to run the commands.
But first make sure you can send and receive the messages.
In Node-red you define the IP address of the broker in the `MQTT' nodes configuration.
Let us say that your Pi has an IP address of 192.168.1.10 and your PC has an IP address of 1192.168.1.99. In both the node-red running on the Pi and the version running on the PC you would configure the MQTT node to use 192.168.1.10 as the server:
at this point, as long as the topics are the same, when node-red on the Pi publishes a message (MQTT-out
), node-red on the PC should receive that message from a MQTT-in
node.
Thanks Paul, I did as you said and it worked at first try When someone knows whats he is doing than there is no need for optimizm Thanks again. I hope this topic helps others too.
Glad to help. You may find this blog series helpfull in understanding more about MQTT
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.