MQTT · Study deck

MQTT Publish-Subscribe Basics

Picture a cold-store sensor sending one numbered temperature record.

Broker Bex is your guide for this deck.

fundpubsub
Broker Bex, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: If boiler 7 loses its MQTT session without a clean close, the broker can publish the stored will to a status topic.
  • Explain: The alarm screen and the archive may listen to the same topic, yet one can update while the other stays stale.
  • Explain: A client subscribed to plant/boiler7/pressure does not match, even if it can decode the same text payload.
  • Explain: The sensor does not know whether a phone app, alarm panel, logger, or automation rule is listening.
iotclass.org

Major section

Start With One Publication

The alarm screen and the archive may listen to the same topic, yet one can update while the other stays stale.

  • The send is only the start of the evidence path.
  • Telemetry means measurements and status sent from a remote device for review.
  • MQTT means Message Queuing Telemetry Transport.

Why it matters

MQTT publish-subscribe works because the broker receives one publication, matches it to subscriptions, and leaves evidence about who should receive it next.

iotclass.org

Major section

Start With One Publication (continued)

A broker is the service that routes messages by topic.

  • A payload is the useful content carried inside one message.
  • This runway does not choose a delivery setting or prove an external action.
  • The sensor does not know whether a phone app, alarm panel, logger, or automation rule is listening.
iotclass.org

Major section

Route a Boiler Reading Through Topic Filters

A boiler publishes plant/boiler7/temperature with payload 83.4 C.

  • A client subscribed to plant/boiler7/pressure does not match, even if it can decode the same text payload.
  • A will message adds another broker action.
  • Subscribers should read that will as session-loss evidence, not as a direct temperature measurement.
MQTT publisher, broker, and subscriber message flow
MQTT publisher, broker, and subscriber message flow
iotclass.org

Major section

Route a Boiler Reading Through Topic Filters (continued)

If boiler 7 loses its MQTT session without a clean close, the broker can publish the stored will to a status topic.

  • A reconnect can later publish a fresh online state.
  • Topic permissions must also stop boiler 7 from writing as boiler 8.
  • The same plant/+/temperature subscription receives both boiler streams.
iotclass.org

Deck summary

Key takeaways

The alarm screen and the archive may listen to the same topic, yet one can update while the other stays stale.

  • A broker is the service that routes messages by topic.
  • A boiler publishes plant/boiler7/temperature with payload 83.4 C.
  • If boiler 7 loses its MQTT session without a clean close, the broker can publish the stored will to a status topic.
iotclass.org

Retrieval practice

Recall check 1 of 3

Broker Bex says: answer from memory, then check your reasoning.

Q1What is the main design value of MQTT publish-subscribe in an IoT deployment?

APublishers and subscribers are decoupled through broker-routed topics.
BEvery device sends messages directly to every dashboard, rule engine, and database.
CThe broker removes the need for authentication, topic design, or delivery evidence.
DSubscribers choose sensor firmware behavior by changing the publisher code at runtime.
Show answer

Answer: A MQTT's broker and topic model lets producers and consumers evolve independently, as long as the topic contract remains stable.

iotclass.org

Retrieval practice

Recall check 2 of 3

Broker Bex says: answer from memory, then check your reasoning.

Q2A dashboard needs all temperature readings from greenhouse 2, but not other sites or other signal types. Which subscription is the best fit?

Asite/greenhouse-2/+/air/temperature
Bsite/#
Csite/greenhouse-2/sensor-17/air/temperature
Dgreenhouse-2-temperature
Show answer

Answer: A The single-level wildcard covers multiple devices while keeping the site and signal type constrained.

iotclass.org

Retrieval practice

Recall check 3 of 3

Broker Bex says: answer from memory, then check your reasoning.

Q3A new dashboard receives every topic under site/#, including maintenance commands and device credentials events it should not see. Which broker-boundary fix is strongest?

AKeep site/# because subscribers can ignore unwanted messages after receiving them.
BMove all topic meaning into the payload so every subscriber uses one flat topic.
CDisable broker logs because the dashboard currently displays the expected data.
DUse a narrower topic filter and enforce subscriber authorization in the broker ACL.
Show answer

Answer: D Topic design and broker authorization should constrain what the dashboard can receive.

iotclass.org

Print reference

Answers

Answer key.

  1. A · MQTT's broker and topic model lets producers and consumers evolve independently, as long as the topic contract remains stable.
  2. A · The single-level wildcard covers multiple devices while keeping the site and signal type constrained.
  3. D · Topic design and broker authorization should constrain what the dashboard can receive.
iotclass.org