I'm a beginner with Node Red and MQTT, but I've made some good strides. I have two raspberry pis that I downloaded MQTT and Node Red on.
I have simple Nodes that are currently sending the recurring outputs from my only Python code from my first Raspberry Pi to the debug tab. That's how far I've gotten so far because I didn't want to mess up anything else after so many attempts.
What I want to do is wirelessly send that data to my other Raspberry Pi via MQTT for it to receive the values. There's a final step of using that information for serial communication, but I can attempt this later.
Can I ask for some steps that I should do to accomplish this or a link to reference? I've researched and I can't find anything for two Raspberry Pis.
If your router allows this, reserve the IP address for this Pi so it never changes.
Use this IP address in the configuration of Node-red's MQTT nodes.
For testing, use topic "test" in MQTT-out on one Pi and MQTT-in on the other.
Inject some data to MQTT-out ("publish" it) and it will arrive at any MQTT-in ("subscribed" to the topic) node on the other Pi.
The only complication is if the Pies are connected to different networks. In that case you probably need to use a cloud based MQTT broker such as Hivemq.
Probably because MQTT doesn't care what devices are using it. It makes no difference if you are exchanging data between PCs, Linux, microcontrollers or mainframes.
There are a couple of deficiencies in that tutorial.
First, in item 2 it should be sudo apt update && sudo apt full-upgrade
Secondly in the section on allowing remote access (which @Ceowens will need to do) note that at the top of the file /etc/mosquitto/mosquitto.conf it states # Place your local configuration in /etc/mosquitto/conf.d/
One should not modify mosquitto.conf itself otherwise a future update may overwrite it. One should instead create a file in the conf.d directory. I make a file /etc/mosquitto/conf.d/mossy.conf and in that put
listener 1883
allow_anonymous true
as suggested in the tutorial. In addition I put there
Thank you both for the help, but I am still having a bit of trouble. This may be because I'm on my college wifi, but I wanted to see if I'm doing this right. So on my first Raspberry Pi, I have:
moquitto_sub -h localhost - v -t test_channel
And on my second one, I did hostname -I, got the IP address of my pi, and did:
moquitto_pub -h 172.#.#.# -t test_channel - m "Hello From Other Pi"
I don't see an output on my first Pi. Did I do something wrong in the terminal?
I don't use mosquitto_pub and mosquitto_sub but I don't like the space between "-" & "v" and "-" & "m", and you have consistently misspelled mosquitto. Linux commands do not have autocorrect built in.
So your first Pi is your mosquitto broker...
But that suggests you are trying to use the IP address of your second Pi as the broker. You need to use the IP address of your broker.