Assignments, ESP8266, ESPlorer IDE, Firmware, LUA, MQTT, NodeMCU, Protocols, Raspberry Pi

Assignment #4: MQTT Setup – Pi as Access Point

MQTT

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.

Screen Shot 2016-02-15 at 1.06.53 PM

Screen Shot 2016-02-15 at 2.20.35 PM

Flashing the firmware on the NodeMCU in OS X using esptool

Screen Shot 2016-02-15 at 3.15.26 PM

Running the LUA scripts on the NodeMCU, and connecting it to the same wireless network as the MQTT broker (Raspberry Pi). Using the ESPlorer IDE.

Screen Shot 2016-02-15 at 3.25.03 PM

Successfully connecting the NodeMCU to the Raspberry Pi vía WiFi. Also, using MQTT-spy to send messages to the NodeMCU.

Screen Shot 2016-02-15 at 3.25.52 PM

Showing the ‘ping’ messages sent from the NodeMCU to the Raspberry Pi in the MQTT-spy client window

 

Screen Shot 2016-02-15 at 3.29.20 PM

The NodeMCU’s log showing it’s firmware version, network connection and messages received from the MQTT broker (Raspberry Pi).

NOTE: Don’t forget to start the mosquitto daemon before trying to connect to it using MQTT-spy.

Screen Shot 2016-02-15 at 3.51.46 PM

Start it by running ‘mosquitto’ from the command line

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.

Screen Shot 2016-02-15 at 10.23.42 PMScreen Shot 2016-02-15 at 10.23.54 PMScreen Shot 2016-02-15 at 10.24.12 PMScreen Shot 2016-02-15 at 10.24.23 PM

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