Lab: Wi-Fi, MQTT Connect, Publish, and Subscribe
Course 1 · Module 6 Type: Hands-on lab (network + broker + device) Suggested time: 2.5–3.5 hours
Read first: Lesson · Cheatsheet · ← Table of Contents · ← M05 · M07 BLE →
Note: the snippets in this lab use the API of the TESAIoT Bitstream firmware, which is not yet open source. See detail and equivalent examples in the public SDK in the note at the top of the lesson MQTT and MQTTs on an Edge Device
Useful references during the lab
Section titled “Useful references during the lab”| Document | Use when |
|---|---|
| Lesson | cm55_trigger_mqtt_*, CONFIG, topics |
| Hackathon MQTT pages | web-app/ex09–ex15 |
| Bitstream Studio | Starting the broker / MQTT tools |
| HiveMQ MQTT Essentials | Reviewing QoS / retain |
Lab Goals
Section titled “Lab Goals”- Join Wi‑Fi until the status is CONNECTED
- Connect MQTT to the broker you choose
- Publish a message or telemetry at least once
- Subscribe (from the host or the device) and see the message
- Explain the difference between MQTT vs MQTTs, and record the config values used
- (Recommended) watch JSON telemetry from a sensor (continuing from M05)
Prerequisites
Section titled “Prerequisites”- Have passed M05, at least able to read a sensor (for telemetry)
- The room’s Wi‑Fi SSID / password (do not record it in Git)
- The broker host/port you will use
- A subscribe tool on the PC (MQTTX, mosquitto_sub, or the Hackathon web-app)
Do not publish a real password or certificate into a public report
Lab A — Wi‑Fi link (required)
Section titled “Lab A — Wi‑Fi link (required)”- Call
cm55_trigger_connectorexample_wifi_ui_connect, per the project - Read
cm55_get_wifi_statusuntilIPC_WIFI_LINK_CONNECTED - Record the SSID (no need to record the password)
Pass when: the Wi‑Fi link is ready before touching MQTT
Lab B — MQTT connect + status (required)
Section titled “Lab B — MQTT connect + status (required)”- Set the policy so MQTT can be used (such as the factory default)
cm55_trigger_mqtt_connect- Read
cm55_get_mqtt_statusuntilstate == CONNECTED (2) - Note the
broker_host,port,tls, andeffective_client_id
(void)cm55_trigger_mqtt_connect();/* poll cm55_get_mqtt_status until connected or timeout */Pass when: the status is CONNECTED and you have a client id to note
Lab C — Publish and observe (required)
Section titled “Lab C — Publish and observe (required)”Choose at least one path:
C1 Telemetry path
Section titled “C1 Telemetry path”- Turn on the sensor + the
TELEMETRY_PUBLISHpolicy - Subscribe on the host to the topic
bitstream/<MAC12>/sensors(or whatever topic you set) - Confirm JSON is coming in
C2 Explicit publish
Section titled “C2 Explicit publish”- Use either path (
cm33_mqtt_stack_publish, or the Studio panel) to send{"hello":1} - See the message on a subscriber
Pass when: you see a payload on a host tool at least once
Lab D — Subscribe / command path (required)
Section titled “Lab D — Subscribe / command path (required)”- Subscribe on the device side to the actuators topic (or use the existing topic-table config)
- From the host, publish a test command to that topic
- Record how the device received it (a log / an LED / an event, per what the firmware supports)
Pass when: there is evidence a message from the cloud/host reached the device (or reached the stack’s log)
Lab E — Choose one (recommended)
Section titled “Lab E — Choose one (recommended)”E1 MQTT vs MQTTs table
Section titled “E1 MQTT vs MQTTs table”Fill in a comparison table from your experiment, or from the documentation of the kit used: port, tls, CA
E2 Hackathon web MQTT
Section titled “E2 Hackathon web MQTT”Run ex09–ex14 per the Hackathon README (a broker in the Studio if needed)
E3 Payload design
Section titled “E3 Payload design”Design a JSON for an event from M05 (a temperature threshold/feature), then try publishing it once
Pass when: you submit a table/screenshot/short design file
Short report (10–15 lines)
Section titled “Short report (10–15 lines)”- The Wi‑Fi SSID (no password)
- The broker host:port and tls 0/1
- The client id / MAC topic used
- Evidence of publish + subscribe
- Limitations you observed (such as telemetry’s QoS, needing Wi‑Fi first)
Troubleshooting
Section titled “Troubleshooting”| Symptom | Approach |
|---|---|
| An MQTT error / it won’t connect | Wi‑Fi isn’t up yet · MQTT_ENABLED is off · the wrong host/port |
| Connects but no telemetry | The sensor isn’t publishing · TELEMETRY_PUBLISH is off · the wrong topic |
| TLS fails | The port isn’t 8883 · the CA doesn’t match the broker · the device’s clock is wrong (if certificate checking depends on it) |
| Subscribe sees nothing | A different MAC / a different topic prefix · a different broker |
| Auth fails | The username/password is empty or wrong |
Submit checklist
Section titled “Submit checklist”- Labs A–D passed
- At least 1 item from Lab E
- mqtt-cloud.md filled in
- The short report has no secrets
Lesson · Cheatsheet · Table of Contents · M07 BLE →
Cite this lesson
If you teach from this lesson or reuse it in slides or documents, credit it with the text below. If you changed it, add (adapted) after the title.
"Lab: Wi-Fi, MQTT Connect, Publish, and Subscribe" from TESA Open Knowledge by the Thai Embedded Systems Association (TESA), https://github.com/tesaiot/tesa-qualification-program, licensed under CC BY-NC 4.0
Thai attribution: "แล็บ: Wi-Fi, MQTT connect, publish และ subscribe" จาก TESA Open Knowledge โดยสมาคมสมองกลฝังตัวไทย (Thai Embedded Systems Association: TESA) https://github.com/tesaiot/tesa-qualification-program สัญญาอนุญาต CC BY-NC 4.0
Lesson link: https://tesaiot.github.io/tesa-qualification-program/en/courses/firmware-sdk-edge-ai/m06-mqtt/l02-lab/
This lesson adapts the source below; keep its credit too.
https://github.com/drsanti/TESAIoT-Courses/blob/287c21814ba8c75f693136616dcd270349a15966/C1/M06/lab.md · Original content by Asst. Prof. Dr. Santi Nuratch (ผศ.ดร.สันติ นุราช), KMUTT. Course 1 (C1/) of drsanti/TESAIoT-Courses. TESA funded the work and holds the rights; published here under CC BY-NC 4.0. The upstream repository carries no licence file. Text kept faithful; structure, front matter, quizzes and notes added by TESA Open Knowledge.
TESA Open Knowledge · © 2026 สมาคมสมองกลฝังตัวไทย (TESA) · CC BY-NC 4.0
Content is licensed CC BY-NC 4.0. Reuse it non-commercially and credit the Thai Embedded Systems Association (TESA) every time. · How to cite TESA