I have a raspberry pi 3 A+ and pi zero w both with node red. I am trying to setup a button on the Pi Zero Z W and an LED on the Pi 3 A+ so that when the button on the zero is pressed, it will trigger the LED to turn on.
I have looked into the MQTT to facilitate this but have not been able to work it out. Am I looking in the right place? Or is there a better way?
There are a number of ways to achieve this, MQTT is certainly a tried and tested method. One observation though, you would not need NR server installed on both Pis to achieve this.
Going down the MQTT route, have you installed an MQTT broker yet? One that works very well on the Pi is Mosquitto https://mosquitto.org/.
Mosquitto and NR running on the one Pi is a good combination.
As @Bobo says, to use MQTT one of the two pi needs to be set up as a MQTT broker ao you need to install MQTT on one of them. Lets say you install MQTT on the Pi 3 A+ you would have
But watch out for the fact that the node doesn't support Retained topics out of the box. In fact mosquitto is so easy to setup that I would go for that. sudo apt install mosquitto mosquitto-clients
is all you have to do if I remember correctly. I think the default configuration file (/etc/mosquitto/mosquitto.conf) is ok for normal use.
I think @zenofmud should get 10 out of 10 marks for excellent artwork.
If all you want to do is press a button, then maybe a Pi-Zero-W would be a bit of an overkill.
I would use a Wemos D1 Mini as it's much cheaper (and safer in case you destroy an input pin).
Hmm, I do agree on the simple installation, in fact I use mosquitto all over the places, I was thinking what could be easiest for beginners. For the sample simple button solution drafted, retained topics seems not really needed
Anyway, besides installation of the mosquitto broker, I think I remember it is needed to arrange so that it starts automatically at boot. Simple for sure, but some additional beginner steps
install mosquitto on the Pi3A+ (as its the more powerful Pi)
Connect to Node-RED on the Pi3A (preferably from a browser on a 3rd machine)
Add yourself a Pi input node configured to use whatever pin you have your button connected to
And a MQTT out node configured with topic button and address of localhost (or you can use 127.0.0.1 or the actual Ip of the machine - up to you)
So you'll end up with this
Connect to Node-RED on the PiZero using another tab on your browser
Add yourself an MQTT input node and a Pi output node
configure your MQTT to use same topic (button) but make sure its set for the actual ip address of your Pi3A (e.g replace 192.168.0.218 with ip address of your pi3A)
try to aim for similar task Problem / Solution /Discussion style.
Of course feel free to reference other ones as necessary as this builds on the basics nicely.
thank you everybody, I'm right on this and I will notify everybody of my progress. The pi zero w is overkill because we needed a few levels of redundancy for my project.