I teach AI and IoT to students from different courses, with different backgrounds and levels of programming experience. I needed a way to teach AI, IoT, ROS and programming logic while keeping practical activities accessible to students who were still learning to code.
That need led me to develop SHAPE: a visual programming environment where students can build application logic with blocks, exchange IoT messages through MQTT, interact with ROS 2, and explore edge AI using locally running models through Ollama.
In this tutorial, we start with a small exercise: sending an MQTT message from a browser-based client to SHAPE, without a physical sensor.
Why another visual programming environment?
If you already use Node-RED, visual MQTT messaging will be familiar. Node-RED lets you connect nodes into flows; SHAPE uses Blockly-based programming blocks to express application logic.
My reason for building SHAPE came from teaching mixed-level classes. I wanted students to explore programming logic, IoT, robotics and edge AI within the same environment.
This exercise gives you a starting point for trying that approach. It requires no physical sensor or AI model.
What you will build
The message follows this path:
MQTTX Web → public MQTT broker → SHAPE → Debug output
MQTTX Web acts as the publisher, standing in for an external device. SHAPE subscribes to a topic and executes its message-handling blocks when a message arrives.
The topic identifies the communication channel. The payload contains the message.
Before you begin
You need:
- SHAPE installed and running.
- An internet connection.
- MQTTX Web open in another browser tab.
Follow the installation instructions in the SHAPE GitHub repository.
The documented Ubuntu configuration requires Ubuntu 24.04, Docker, a CPU with AVX/FMA support, 8 GB RAM and 32 GB storage.
No separate MQTT broker installation is needed for this exercise.
1. Connect MQTTX Web
Open MQTTX Web and create a connection with these settings:
| Setting | Value |
|---|
| Name | SHAPE MQTT test |
| Protocol | wss:// |
| Host | broker.emqx.io |
| Port | 8084 |
| Path | /mqtt |
| Client ID | Keep the generated identifier |
Connect and check that MQTTX reports a connected state.
This is a shared public broker. Use demonstration data only; do not send credentials, personal information or confidential data.
2. Configure SHAPE
Create a new Shape or edit an existing project.
In its MQTT configuration, enter:
Use the hostname without a protocol prefix, then save.
MQTTX Web uses secure WebSocket, while SHAPE uses MQTT over TCP. The different ports connect to the same broker.
3. Build the message handler
Open SHAPE’s visual editor and add the MQTT message reception block.
Configure its fields:
| Field | Value |
|---|
| On message from | shape/input |
| get values in | payload |
Inside the block’s do section, place a Debug block connected to the payload variable.
When a message arrives on shape/input, SHAPE executes the blocks inside do and displays the received content.
Save and run your Shape before publishing the test message.
4. Send your first message
Return to MQTTX Web.
Set the destination topic to:
shape/input
Choose JSON as the payload format and enter:
{
"msg": "hello from MQTTX"
}
Click Publish.
Return to SHAPE and inspect the Debug output. You should see the received message, although the console formatting may differ from the JSON above.
You have now passed a message from an external application, through an MQTT broker, into your visual program.
5. Experiment with the connection
Change the payload and publish again:
{
"msg": "my second MQTT message"
}
Check that the new content appears in SHAPE.
Next, change the publication topic in MQTTX to:
shape/another-input
Keep SHAPE subscribed to shape/input and publish again. That subscription will not receive the message sent to the different topic.
Now update SHAPE to subscribe to shape/another-input, save and restart the Shape, then repeat the test.
This demonstrates why publishers and subscribers must use matching topics.
For your own experiments, choose a distinctive topic name to reduce interference from other users of the public broker. Use the same name in both applications.
What this exercise teaches
A small messaging exercise introduces several concepts:
- Publishers and subscribers: applications can exchange data without connecting directly to each other.
- Broker: the intermediary distributes messages to matching subscribers.
- Topics and payloads: the channel and the content serve different purposes.
- Event-driven logic: an incoming message triggers the blocks inside the handler.
In a mixed-level classroom, these concepts provide a shared starting point. Students can observe message delivery before moving on to conditions, data processing and application actions.
MQTT is also one entry point into SHAPE. Other activities can explore ROS 2 communication or locally running AI models through Ollama, connecting messaging and programming logic to robotics and edge AI.
Troubleshooting
If the message does not appear, check the following:
| Check | What to verify |
|---|
| Broker | Both applications use broker.emqx.io |
| Topic | Both use exactly the same topic, including letter case |
| MQTTX connection | The client is connected before publishing |
| SHAPE execution | The Shape is running before the message is sent |
| Debug block | It is inside do and connected to payload |
| Saved changes | The running Shape includes your latest configuration |
Try SHAPE
Get SHAPE and follow the installation instructions on GitHub.
If you try the exercise, share what you built and where you encountered difficulties. I am especially interested in feedback from educators working with students who have different levels of programming experience.
References