For this week’s assignment, we had to configure the Raspberry Pi as an MQTT message broker and the NodeMCU as an MQTT Client. For this I followed the following two tutorials, which are very straightforward and complete:
As a result of this, I installed and configured Mosquitto on the Raspberry Pi (following the first tutorial), re-flashed the NodeMCU’s firmware including the MQTT libraries and programmed it to send ping messages to the Raspberry pi. Also, by using a program MQTT-Spy I was able to send messages to the NodeMCU.
NOTE: Don’t forget to start the mosquitto daemon before trying to connect to it using MQTT-spy.
Raspberry Pi as AP
Relying on a specific wireless network or carrying your own wireless router in order to bridge communications between the Raspberry Pi and the NodeMCU is not very practical. Specially because SSIDs and their passwords have to be hardcoded into the NodeMCU and you can’t always (or want) hook up your Raspberry Pi to a wireless network so easily. So fortunately, in order to get things going on a portable self-sufficient fashion, you can turn your Raspberry Pi into a wireless access point (AP), and hook it put to the internet via its Ethernet port.
To do this, you can follow THIS Adafruit tutorial. If you are using the Edimax WiFi adapter that came with the Vilros kit, you don’t have to change any of the driver configurations (when you get to that step you’ll notice).
I got my Raspberry Pi working as an Access Point, and I modified my NodeMCU’s configuration file (SSID, Password and HOST) to connect directly to it.
As you might noticed, this post was not a tutorial on how to do the things I presented above. The reason for this is that the tutorials I presented above are very clear, self-contained and well written. This week’s post will only serve as evidence for my progress regarding course assignments, so please access the links to the other tutorials to recreate my MQTT setup.
Until next time!
Leave a Reply