Welcome to BRICKS.
This tutorial covers the first step of external data communication: integrating MQTT. By completing this chapter, you will easily master the fundamental use of external data communication in the BRICKS Cloud Intelligent Display.
Before You Begin
What is MQTT?
MQTT is a publish/subscribe-based messaging protocol widely used for IoT devices. For a detailed explanation, you may refer to the following video:Introduction to MQTT.
🕐 Estimated time to complete this tutorial: 5–8 minutes
Step 1: Create an MQTT Generator and Configure Its Properties
BRICKS Generators do more than just countdowns and audio playback—they can also communicate with external data and devices via protocols such as HTTP, WebSocket, GraphQL, MQTT, BLE, and Serial Port.
In this lesson, we will demonstrate how to use an MQTT Generator to communicate with external IoT devices.
Create an MQTT Generator, and in its properties:Set Init to [ Yes ] so it automatically connects on initialization.
In URI, enter [ mqtt://broker.hivemq.com:1883 ], which uses HiveMQ’s public service to simulate MQTT communication.
Under Subscribe, add a Topic [ bricks/hello ].
Set the Message Type to [ text ], so we can connect it to a string variable in the Property Bank.
Step 2: Configure a String Variable for the MQTT Generator to Receive Messages
Create a new string-type variable in the Property Bank. This variable will store the messages received from the MQTT publisher.
Next, return to the MQTT Generator created in Step 1. Under Outlets, locate Message Payload and assign the variable you just created. This links the variable to the MQTT message data.
Step 3: Create a Text Brick to Display the Variable Content
Add a Text Brick and set its width to 30 for displaying the message.
In the Brick properties, link the Text field to the variable by clicking the link icon and selecting the string variable created in Step 2. Make sure the text color contrasts with the background so the message is visible.
Step 4: Publish a Message via HiveMQ
Now we will simulate publishing an MQTT message using HiveMQ’s service. Open the HiveMQ test page here: http://www.hivemq.com/demos/websocket-client/.
In the Publish section, you will see fields for Topic, QoS, and Message. Recall that in Step 1, we configured the Topic, QoS, and Message Type in the MQTT Generator’s Subscribe section. Enter the same Topic [ bricks/hello ], ensure the QoS value matches, and then type any message you want to send in the Message field.
Step 5: Preview on Device
Save the application and play it on your device. Then, return to the HiveMQ page and click [ Publish ]. When the message is sent, check if the Text Brick on your device updates to display the message you entered.
Congratulations! You have now learned the basic concept of integrating external communication with MQTT.
The next lesson will introduce HTTP API communication.
For any assistance, please click the chat icon in the bottom-right corner. Our team will respond to your questions as quickly as possible.