Week 11
Assignment - Networking and Communications
-
Group assignment:
- Send a message between two projects
- Document your work to the group work page and reflect on your individual page what you learned
-
Individual assignment:
- Design, build and connect wired or wireless node(s) with network or bus addresses and a local input and/or output device(s)
From Assignment Details

Group Assignment
The assignment this week was to send a message between two projects. I used the MQTT protocol and the broker set up by Julian. And to send between two projects I prepared two boards, two input boards (as designed in week 8); one as input, one output.
Code

I wrote some code for the board I made in week 8. I connected it to an MQTT server, and wrote out to the Serial Monitor.
I did this by installing the ArduinoMQTTClient library in the Arduino IDE, and then opened the example from the File>Examples menu.
I updated the file called secrets.h, using the credentials Julian shared, so I could use the shared Fab Academy MQTT Broker.
#define SECRET_SSID ""
#define SECRET_PASS ""
#define SECRET_BROKER "mqtt.fabcloud.org"
#define SECRET_PORT 1883
#define SECRET_TOPIC "fabacademy/etc"
#define SECRET_USER "fabacademy"
#define SECRET_PSK "fabacademy"
I uploaded it to the Xiao ESP32 module, with the OLED screen that I made in week 8. It listens to MQTT on the topic: fabacademy/creative-spark.
Then I had it write messages to the screen.
At first, I had an issue issue with the University’s Network

Tried my phone’s hotspot, it worked. But, I went back to the University Network… and then it worked too.

Then, I published a message with mosquitto_pub from the terminal on my computer. And I receive it on my device.

“Hello Ger” :)

Reflection
[From group and individual assignments]: MQTT nodes are the devices, and the “-pub” and “-sub” libraries allow each to subscribe to a channel of messages from the broker/host. In this case I sent the messages via a channel called fabacademy/creative-spark. The subscribing node receives the message and can write it to an output or do something with that information. More complexity can be built into the message, so even though it is a string of characters, it can be pars-able with some structure (like JSON). This structure can then be interpreted as richer data, like with two variables, eg., Temp and Humidity, or affect other logic. eg an LED to turn on or off.
Some old sources on MQTT:
I’ve used MQTT in home automation projects. I never really got the chance to get in deeper into QoS, retained messages, topic structure, wildcards, but it was really interestign to read. I have used MQTT nodes in Node-RED which expose these features.
There is password authentication, though it can be used on a local network or behind a VPN. Which feels secure for most cases.
A sophisticated protocol that does basic message brokering well, and has advanced features that are there for more complicated uses.
Files
- fabacademy_combined.ino
- secrets.h (SSID and password have to be filled in)