MQTT

Protocol

Lightweight publish-subscribe messaging protocol designed for constrained devices — the default choice for IIoT sensor-to-broker communication.

What is MQTT?

MQTT (Message Queuing Telemetry Transport) is a lightweight publish-subscribe messaging protocol originally developed by IBM in 1999 for connecting oil pipeline sensors over unreliable satellite links. It became an OASIS standard in 2014 (v3.1.1) and received a major update in 2019 (v5.0). With packet headers as small as 2 bytes, it's designed for constrained devices on networks with limited bandwidth and high latency.

The protocol uses a broker-based architecture: devices (clients) publish messages to topics, and the broker distributes them to all subscribers of that topic. There's no direct device-to-device connection — the broker handles all routing, which makes it simple to add or remove devices without reconfiguring the network.

Why It Matters for Manufacturing

MQTT is the de facto transport layer for IIoT data. When a temperature sensor on a packaging line needs to send readings to a dashboard, historian, or analytics engine, MQTT is almost always the protocol carrying those messages. It's the "M" in the MING stack (Mosquitto + InfluxDB + Node-RED + Grafana) — the most common open-source IIoT architecture.

Three reasons it dominates factory floors:

  1. Runs on anything — From a Raspberry Pi Zero to a 10,000-device factory. The same Mosquitto broker binary handles both.
  2. Fire-and-forget simplicity — Sensors publish; consumers subscribe. No handshakes, no connection management, no complex configuration.
  3. Works on bad networks — Designed for satellite links with 50%+ packet loss. Industrial WiFi and cellular backhaul are easy by comparison.

How It Works

Publish/Subscribe model:

Sensor → publishes to topic "factory/line1/temp" → Broker → delivers to all subscribers
  • Topics are hierarchical strings (e.g., factory/line1/machine3/vibration). Subscribers can use wildcards: factory/line1/+/vibration (single level) or factory/# (all subtopics).
  • QoS levels control delivery guarantees:
    • QoS 0: At most once (fire-and-forget, fastest)
    • QoS 1: At least once (acknowledged, may duplicate)
    • QoS 2: Exactly once (two-phase handshake, slowest)
  • Retained messages: The broker stores the last message on each topic. New subscribers immediately get the current value — critical for dashboard displays.
  • Last Will and Testament (LWT): Clients register a "will" message that the broker publishes if the client disconnects unexpectedly. Used for device health monitoring.

MQTT 3.1.1 vs 5.0

Most manufacturing deployments still run 3.1.1, but 5.0 adds features that matter at scale:

Feature3.1.15.0
Error reportingGeneric return codesDetailed reason codes per packet
Shared subscriptionsBroker-specific extensionsStandard — load-balance across consumers
Session expiryPersistent or clean onlyConfigurable TTL per session
Message propertiesNoneCustom key-value metadata headers
Flow controlNoneClient-specified receive maximum
Topic aliasesNoYes — reduces bandwidth for repeated topics

Recommendation: Use 5.0 for new deployments. Shared subscriptions and reason codes alone justify the upgrade. 3.1.1 clients can connect to 5.0 brokers — backward compatible.

Protocol Comparison

FeatureMQTTOPC-UAModbus TCP
ArchitecturePub/sub via brokerClient/serverClient/server (master/slave)
Overhead2-byte header minimumHeavy (XML/binary encoding)8-byte header
ScalabilityThousands of devices via single brokerPoint-to-point, complex at scale247 devices per network
Data modelNone (raw payload)Rich object model, typed dataRegister-based, no semantics
SecurityTLS + username/passwordBuilt-in certificates, encryptionNone built-in
Best forSensor telemetry, event streamingPLC-to-PLC, SCADA integrationLegacy device polling
Firewall friendlyYes (outbound TCP only)No (requires inbound port)Depends on deployment

MQTT + OPC-UA together: OPC-UA PubSub mode can transport messages over MQTT, combining OPC-UA's rich data model with MQTT's lightweight transport. Sparkplug B adds a standardized payload format to MQTT, solving the "no data model" problem without requiring OPC-UA.

Common Pairings

  • Sparkplug B — Payload specification that adds device/metric semantics on top of MQTT. Standardizes how devices report birth/death certificates and metric values. Used heavily in Unified Namespace architectures.
  • Mosquitto — The most common open-source MQTT broker. Lightweight, single binary, handles millions of messages/sec.
  • HiveMQ / EMQX — Enterprise MQTT brokers with clustering, persistence, and management UIs for large-scale deployments.
  • Node-RED — Flow-based tool with native MQTT nodes for wiring up data pipelines. The typical glue layer between MQTT and everything else.
  • InfluxDB / TimescaleDB — Time-series databases that ingest MQTT data via Telegraf or direct subscription.

Getting Started

  1. Install Mosquitto: docker run -p 1883:1883 eclipse-mosquitto — you have a broker running in seconds.
  2. Publish a test message: mosquitto_pub -t "test/hello" -m "world" from any machine on the network.
  3. Subscribe: mosquitto_sub -t "test/#" — see messages arrive in real time.
  4. Connect a sensor: Most IIoT gateways and PLCs with Ethernet support MQTT out of the box. Configure the broker address and topic structure.
  5. Add a consumer: Point Node-RED, Grafana (via MQTT data source plugin), or your historian at the broker.

The entire MING stack (Mosquitto + InfluxDB + Node-RED + Grafana) can be running in under 30 minutes with Docker Compose.

Tools supporting MQTT

32
Icon

 

  
  
Icon

 

  
  
Icon

 

  
  
Icon

 

  
  
Icon

 

  
  
Icon