Iteration 4 - Hasan Berk
Big Heart SETU
Iteration 4 ⛅
MQTT Architecture
![]() |
MQTT Architecture |
This iteration was largely involved in the setting up of our MQTT architecture, which is shown above. After lots of troubleshooting, we managed to conclude our MQTT architecture to the following:
- DFRobot Cloud Board v1 - This is the board which the server Microbit is connected to. It is connected to the internet using an Android hotspot.
- Microbits (multiple) - These are used as clients for the server Microbit.
- BeeBotte - This is the MQTT broker service.
- IoT MQTT Panel (Dev: Rahul Kundu on iOS App Store) - This is the mobile application to feed back information to the end user's phone client from BeeBotte.
Final Startup Sequence:
We devised the following startup sequence, which after lots of testing and troubleshooting, found worked best.
- Turn on the Android Hotspot.
- Turn on the Cloud Board with the Server Microbit connected to it.
- Wait for the code to execute, and the LED on the Cloud Board turns Green.
- Wait for the Heart icon to appear on the Server Microbit LED Matrix.
- Connect the Client Microbits
- Verify connection between the server-client Microbits.
- Verify connection on the phone client application.
Important Things to Note:
Hotspot Compatibility
Through connection troubleshooting, it was discovered that iPhone hotspots are not compatible with our cloud board. This raised a lot of issues, as only one out of the seven people in our class had an Android phone. We later discovered that Windows hotspots work as well, but are a lot more intermittent than Android. Since our university uses eduroam, there was too much interference on the network for a stable connection fit for this purpose. We did not pinpoint the exact reason why Android worked and iOS hotspots did not, however we can estimate it was because of iOS's use of IPV6 addresses in the mobile hotspot, as well as different security protocols.
Therefore we could conclude that:
Android hotspot 🟢 - works fully
Windows hotspot 🟠 - works but intermittent
iPhone hotspot 🔴 - does not work
DFRobot Cloud Board V1
After reading the documentation for the cloud board, we noted the different LED colours on the Cloud Board itself.
🟢 The Cloud Board is connected to WiFi, and established a connection with the MQTT Broker.
🟣 The Cloud Board is connected to WiFi, but there is no connection to the MQTT Broker.
🔵 The CloudBoard is attempting to connect to the WiFi.
🔴 The Cloud Board is not connected to WiFi.
MQTT Message Limit
Since we are using the free plan with BeeBotte, we had to be wary of the daily message limit of 50k messages a day. Although this seems like a lot, when we have 6 client Microbits with a publish/subscribe message every 250ms, it can reach the limit quicker than assumed.
To combat this, as well as not overload the Microbit processing power, we set the delay between each message to 500ms.
Microbit MQTT Architecture Code
Server Microbit Code
After multiple iterations, we finalized the code with the following architecture in place.
There is a confirmation string called Server, which displays on the Microbit LED Matrix to indicate it's purpose.
It sets the delay variable, which in this case is 500ms to wait between each published message to the client Microbits.
Then we move on to the Micro:IoT extension block, which is used to configure the hotspot and BeeBotte credentials. It also defines the MQTT topics.
Once all this is complete, it sets the radio group for the client Microbits, and shows a heart icon before clearing the screen, to indicate successful start up configuration.
Send to Node Function
Input X - Radio input number to send to
Val - The value to send
Toggle X - The X coordinate to toggle
Toggle Y - The Y coordinate to toggle
Forever Loop
Radio -> MQTT Function
This function listens for any radio values received from the client Microbits, and once it receives one it sends an MQTT message back to BeeBotte. The message is a JSON string consisting of a key-value pair, as well ispublic set to true, which is required.
On successful message sent, the (4,4) LED toggles on the Server Microbit LED Matrix.
This function is used to serial print the MQTT messages received from our topic one subscription. These are messages returning from the MQTT broker.
parseJSONMessage Function
This function is to parse incoming JSON MQTT messages received from our topic one subscription. Once parsed, it sends the message to the intended ID.
MQTT Topic One Message Received
Client Microbit Code
Phone Client MQTT Panel Configuration
Demonstration
As you can see from the video above, it shows the full end to end successful use of the MQTT broker. When a value is sent from the slider on the phone, it appears on the Microbit LED matrix.
IFTTT (If This Then That)
The next major thing we looked at during this iteration was the use of the IFTTT application. This application integrates custom triggers with different applications and use cases. For example, one thing we got working in class was using the Microbit to send an email through my email address to Jason to come see our progress with IFTTT.
Applet Setup
This was triggered (If This) by pressing the button on the Microbit, which uses webhooks, and then sent an email (Then That) using my email address to Jason and the rest of the class.
We were absolutely fascinated by this and it truly unlocked a whole new world of possibilities of feeding back information to the user. Some possible ideas included potentially using HRV to control a light bulb in a room, perhaps pulsing in accordance with the HRV.
![]() |
Email from Microbit to Us 😁 |
Comments
Post a Comment