CloudSketch AI Logo
FeaturesTemplatesPricingEnterpriseAboutContactLog in
🌙☀️
Log inStart free
Home/Templates/IoT

📡 IoT · Sequence

MQTT Publish/Subscribe Messaging

How MQTT messaging works between devices, a broker and applications: connect, subscribe, publish with QoS, retained messages and last will.

More IoT templates

Drawing diagram…

What this diagram shows

  • Devices and apps only talk to the broker, never to each other
  • QoS 1 messages are acknowledged and resent if lost
  • Last will tells subscribers when a device drops off

Prompt used

MQTT sequence: a sensor connects to the broker with a last-will message 'offline', a dashboard app subscribes to building/+/temperature, the sensor publishes a temperature reading with QoS 1 and the retained flag, the broker acknowledges (PUBACK) and forwards it to subscribers, a new subscriber immediately receives the retained last value, and when the sensor's connection drops the broker publishes its last will.

Mermaid code
sequenceDiagram
  participant S as Sensor
  participant B as MQTT Broker
  participant D as Dashboard App
  participant N as New Subscriber
  S->>B: CONNECT (last will: offline)
  B-->>S: CONNACK
  D->>B: SUBSCRIBE building/+/temperature
  B-->>D: SUBACK
  S->>B: PUBLISH building/a/temperature 26.4 (QoS 1, retained)
  B-->>S: PUBACK
  B->>D: 26.4
  N->>B: SUBSCRIBE building/a/temperature
  B->>N: Retained value 26.4
  Note over S,B: Connection lost
  B->>D: Last will: sensor offline

Related templates

Data FlowIoT

IoT Telemetry Data Pipeline

How sensor readings travel from devices to dashboards and alerts: MQTT ingestion, stream processing, time-series storage and anomaly detection.

SequenceIoT

IoT Device Provisioning Sequence

How a new device joins the platform securely: claiming by the owner, certificate issue and its first connection to the MQTT broker.

C4 ArchitectureProIoT

IoT Platform Reference Architecture

A general-purpose IoT platform: device connectivity, device management, data processing, rules and the apps built on top.

DeploymentProIoT

IoT Edge Computing Deployment

Where processing happens in an edge IoT setup: devices, an on-site edge server running containers, and the cloud for fleet management and long-term storage.

FlowchartIoT

Smart Home Automation Flow

How a smart home reacts to events: motion, door and temperature triggers run rules for lights, locks, AC and alerts.

State MachineIoT

IoT Device Lifecycle

Every state an IoT device goes through, from manufacture to decommissioning, including updates, faults and replacement.