I'm not understanding what I'm doing wrong. I have one Raspberry Pi as my broker. My other Raspberry Pi isn't receiving anything on its side.
What I did first was test the connection on the localhost on one Pi and that is working well.
But what I did was change both the MQTT In and MQTT out nodes to the IP address of my second Raspberry Pi that is connected away from my first one. I'm getting nothing. I also matched the Topic name on each, the broker is running on the second pi, and NodeRed is running on both, but I'm using the node only on the first Pi and not the second. What am I doing wrong?
Did you set the broker configuration to allow remote connections ? They are blocked by default for security.
I made sure to change the config file to allow anonymous true, listener 1883 and I think another listener for the second Pi's IP address as well. I thought that might've been the cause of my problems, but the config file looked right to me.
You only need one mqtt broker. For example, let’s a]say you choos pi-a. In the mqtt configuration on pi-a specify the IP address of
On pi-b, in the mqtt node configuration also specify the IP address of
I have the latest version of node-red (v3.0.2) running on RPI 3’s with no problem.
Just as an observation: 142.x.x.x is a public IP address. Are these on the open internet?
Okay just to make sure. So after updating or retrying with the possible version problem, on Pi-A, I run the MQTT broker only on that. Then for each node on the different Raspberry Pi, I use the IP address of Pi-A that is running the broker on each MQTT node on both Pi.
I was honestly shown to use "hostname -I" to find the IP address. I'm on my public university wi-fi
Did you verify that the two devices can "see" each other? Can you ping from one to the other and back?
Yes, use the same IP on both pi’s. But as @gerry mentioned the IP addresses for a local network should begin with 10…, 192… or 172….
From the cli on pi-a make sure you can ping pi-b. Use:
ping-c 3 ip-address-goes-here
to jump in here. Yes, the Pi that has the broker setup is the IP for the other Pi. On the Pi that has the broker you did set up the MQTT node by assigning an id to it. I usually use 127.0.0.1 but you can also use the device IP as well. The other Pi the MQTT node setup uses the brokers IP of 142.x.x.x
 it's possible there might be some type of port blocking as well, I think everything is on the table at this point
I might've got my numbers mixed up, sorry. I'll verify just to make sure in an hour when I go back to the college. I'm betting it is 172.#.#.#
So to just to go through each step so I can understand, if I'm trying to send a variable from Pi-A to Pi-B with Pi-B running MQTT broker that is receiving information, I complete this node below on Pi-B with the IP Address on the node assigning to the IP address of Pi-B.
I then implement the node below on Pi-A, which wants to send information to Pi-B, and I assign that node's IP address to the IP address of Pi-B
And this is with matching the topics together, ensuring that everything is updated, and if I can ping an IP address.
@gerry @zenofmud Also thank you for your help, I'll try all of this within the hour. I was trying extremely hard and I think I was confusing myself with something simple.
just as a note: if you put an # (pound sign) in the receive topic it will show all the messages regardless of topic, this will let you check to see if there is a topic issue.
If you want to learn more about MQTT then see this tutorial MQTT Essentials - All Core Concepts explained
@zenofmud @dceejay @gerry hello again, I'm still trying to get my MQTT to work, but on my second screen, I still can't get a response or connection on my second Pi. I have my first Pi sending a message to itself, but my second pi is still connecting.
My server for the first Pi with Node Red and MQTT broker running on it is 172.25.#.#(port number) which is what I put into my other Pi. I checked the Ping via the command line and it looks to be working.
Can you post a screen shot of the node configs?
Open a cli on pi-a and run:
Sudo cat /etc/mosquitto/mosquitto.conf
And copy the results and paste them to a response. Please do not show us a photo.
They on each pi, export your flow and paste it into a response