Skip to content

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

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

  • 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)

  • 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


  1. Call cm55_trigger_connect or example_wifi_ui_connect, per the project
  2. Read cm55_get_wifi_status until IPC_WIFI_LINK_CONNECTED
  3. 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)”
  1. Set the policy so MQTT can be used (such as the factory default)
  2. cm55_trigger_mqtt_connect
  3. Read cm55_get_mqtt_status until state == CONNECTED (2)
  4. Note the broker_host, port, tls, and effective_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


Choose at least one path:

  • Turn on the sensor + the TELEMETRY_PUBLISH policy
  • Subscribe on the host to the topic bitstream/<MAC12>/sensors (or whatever topic you set)
  • Confirm JSON is coming in
  • 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)”
  1. Subscribe on the device side to the actuators topic (or use the existing topic-table config)
  2. From the host, publish a test command to that topic
  3. 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)


Fill in a comparison table from your experiment, or from the documentation of the kit used: port, tls, CA

Run ex09–ex14 per the Hackathon README (a broker in the Studio if needed)

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


  1. The Wi‑Fi SSID (no password)
  2. The broker host:port and tls 0/1
  3. The client id / MAC topic used
  4. Evidence of publish + subscribe
  5. Limitations you observed (such as telemetry’s QoS, needing Wi‑Fi first)

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

  • 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.

Full guide: how to cite TESA

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