5 December 2026 · 8 MIN READ

Sparkplug B Explained: Bringing State and Context to Industrial MQTT

Learn how Eclipse Sparkplug B (ISO/IEC 20237) adds a standard topic namespace, binary Protobuf payloads, metric aliases, and birth/death state awareness to industrial MQTT.

MQTTSparkplug BIIoT
Chiller plant SCADA control screen showing real-time equipment telemetry and operational status
Photo: Rsparks3 via Wikimedia Commons (CC0 1.0)

MQTT won over the industrial world because it solved a painful problem: getting telemetry out of constrained edge gateways and across unreliable plant-floor or cellular networks without polling every PLC over a WAN. Yet any engineer who has scaled plain MQTT past a single pilot quickly hits a wall. Standard MQTT intentionally leaves topic naming, payload encoding, and session state to the developer. On a factory floor with dozens of gateways, thousands of tags, and multiple SCADA, historian, and analytics consumers, that freedom turns into brittle, custom-coded integration glue.

Eclipse Sparkplug B—now standardized internationally as ISO/IEC 20237—fixes those gaps without abandoning standard MQTT 3.1.1 or 5.0 brokers. It defines an opinionated specification on top of MQTT so edge nodes, devices, and host applications share a predictable topic namespace, compact binary payloads, self-describing tag metadata, and strict online/offline state awareness.

Why Plain MQTT Breaks Down on the Plant Floor

In a classic publish/subscribe architecture, the MQTT broker decouples producers from consumers. That decoupling is a superpower for scalability, yet it introduces three operational headaches in OT/IIoT environments:

  • No standard topic hierarchy: One team publishes to plant1/lineA/pump01/temp, while a vendor skid publishes to vendorX/telemetry/1002. Every downstream consumer has to write bespoke parsers and topic-mapping rules.
  • Arbitrary, verbose payloads: Most teams default to JSON because it is human-readable. Sending full tag names, units, and timestamps as repeated JSON strings wastes bandwidth over LTE or satellite links and adds parsing overhead at the edge.
  • Silent stale data: Standard MQTT's Last Will and Testament (LWT) tells subscribers that a client disconnected, but it does not automatically tell a SCADA or historian which specific PLC tags should be flagged as stale, nor does it guarantee that a newly connected application receives the full tag dictionary of an already-online gateway.

Sparkplug B addresses all three issues while running over any compliant MQTT 3.1.1 or 5.0 broker that supports QoS 1, retained messages, and Will messages.

The Sparkplug B Topic Namespace (spBv1.0)

Every Sparkplug B message follows a rigid, five-part topic structure defined in the Eclipse Sparkplug Specification:

spBv1.0/[Group ID]/[Message Type]/[Edge Node ID]/[Device ID]

Each segment has a specific architectural role:

  • spBv1.0 (Namespace): Identifies the Sparkplug B protocol version so brokers and clients can route or filter Sparkplug traffic cleanly.
  • Group ID: A logical grouping of Edge Nodes—commonly a plant site, business unit, or geographic region (for example, PlantA or MidwestWater).
  • Message Type: Indicates the lifecycle or telemetry role of the message, such as NBIRTH, NDEATH, DBIRTH, DDEATH, NDATA, DDATA, NCMD, DCMD, or STATE.
  • Edge Node ID: The unique identifier of the MQTT client (the Edge of Network node, such as an industrial gateway, IPC, or Sparkplug-capable PLC) within that Group ID.
  • Device ID (Optional): Identifies a physical or logical downstream device connected behind the Edge Node (for example, a Modbus RTU flow meter or a specific pump controller). Node-level messages (NBIRTH, NDEATH, NDATA, NCMD) omit the Device ID, while device-level messages include it—such as spBv1.0/PlantA/DDATA/BoilerGateway/Pump01 in AVEVA's Sparkplug B documentation.

Because the namespace is fixed, a host application can subscribe to spBv1.0/# (or spBv1.0/PlantA/#) and immediately understand which site, gateway, and device originated every packet.

Binary Protobuf Payloads, Aliases, and Templates

Instead of unstructured JSON, Sparkplug B encodes its payloads using Google Protocol Buffers (Protobuf). Protobuf serializes data into a compact, strongly typed binary format with explicit data types (Int32, Float, Double, Boolean, String, and more), per-metric timestamps, and quality/property metadata.

Three payload features make Sparkplug B especially efficient at industrial scale:

  • Report by Exception (RBE) with Context: Gateways only publish NDATA or DDATA messages when a tag value changes beyond a configured deadband, cutting network traffic dramatically compared to continuous polling.
  • Metric Aliases: During the initial birth message (NBIRTH or DBIRTH), the Edge Node declares each metric's full string name alongside a unique integer alias. Every subsequent NDATA or DDATA message can reference that integer alias instead of repeating long tag paths like Line2/Filler/Motor/WindingTempC, shrinking payload sizes even further.
  • Templates and Datasets: Engineers can define reusable structured types (such as a standard VFD_Motor UDT with SpeedRPM, CurrentAmps, and FaultCode) and tabular DataSet structures so downstream Unified Namespace (UNS) consumers receive consistent data models rather than flat lists of disconnected tags.

State Awareness and the Session Lifecycle

The defining feature of Sparkplug B is state management. In industrial control and monitoring, knowing whether a value is fresh is just as important as knowing the value itself.

Sparkplug B Session Lifecycle: 1. Connect and Register NDEATH Will, 2. NBIRTH and DBIRTH Discovery, 3. DDATA and DCMD Telemetry, 4. NDEATH Offline and STALE state
Sparkplug B session lifecycle from MQTT CONNECT and NBIRTH discovery to DDATA and NDEATH. Illustration: IIoTjob (original artwork).

The Eclipse Sparkplug 3.0.0 Specification enforces a strict sequence for every Edge Node and Primary Host Application:

1. Connecting and Registering the Death Certificate (NDEATH)

Before sending any telemetry, the Edge Node opens an MQTT connection and registers an NDEATH message as its MQTT Will inside the CONNECT packet. That NDEATH payload carries a special bdSeq (Birth/Death Sequence) UInt64 metric. If the Edge Node drops off the network unexpectedly—due to a power loss, switch failure, or cellular outage—the MQTT broker automatically publishes the NDEATH message on its behalf. When shutting down gracefully, the Edge Node must explicitly publish NDEATH before sending DISCONNECT.

2. Publishing Birth Certificates (NBIRTH and DBIRTH)

Immediately after connecting, the Edge Node publishes an NBIRTH message containing:

  • The exact same bdSeq number registered in its NDEATH Will.
  • Every node-level metric, its current value, data type, timestamp, property sets, and optional integer alias.
  • A Node Control/Rebirth boolean metric so authorized hosts can request a fresh birth sequence on demand.

Next, for each downstream PLC or sensor attached to that gateway, the Edge Node publishes a DBIRTH message listing that device's tags, current values, and aliases. This enables auto-discovery: a SCADA system or historian subscribing to the broker learns the complete tag inventory of a new gateway automatically, without manual CSV imports.

3. Sequencing Data (seq), Commands (NCMD/DCMD), and Host STATE

Once birth certificates are published, normal operation uses NDATA and DDATA for telemetry and NCMD / DCMD for commands (such as writing a setpoint or triggering a Rebirth). Sparkplug B uses a separate seq counter (0 to 255, wrapping back to 0) across NBIRTH, DBIRTH, NDATA, DDATA, and DDEATH messages for an Edge Node so receivers can detect missed or out-of-order packets.

Meanwhile, the Primary Host Application publishes its own retained JSON STATE message on spBv1.0/STATE/[Host ID] containing online (true/false) and a timestamp. If the Primary Host goes offline, Edge Nodes can detect the STATE change and pause or buffer critical data instead of publishing blindly into a void.

4. Handling Reconnects and STALE Data Without Race Conditions

Why does Sparkplug B require both bdSeq and seq? In distributed networks, an Edge Node can drop and reconnect quickly—causing the broker's delayed NDEATH Will from the old TCP session to arrive after the new NBIRTH. Because NDEATH and NBIRTH share a matching bdSeq per connection, the Host Application compares the incoming NDEATH's bdSeq against the active session's bdSeq. It only marks the node offline and flags its metrics as STALE if the bdSeq values match, preventing false offline alarms during brief network blips.

Where Sparkplug B Fits Alongside OPC UA and a Unified Namespace

Engineers often ask whether Sparkplug B replaces OPC UA or eliminates the need for a Unified Namespace (UNS). In practice, they solve different layers of the stack:

  • OPC UA at the machine/cell layer: OPC UA excels at rich, synchronous client-server communication, complex information models, and high-speed machine-to-machine or PLC-to-gateway connectivity on the local plant LAN.
  • Sparkplug B at the edge-to-broker layer: Edge gateways frequently read PLCs via OPC UA, Modbus TCP, EtherNet/IP, or S7, normalize those tags, and publish them over Sparkplug B to a central MQTT broker.
  • Unified Namespace (UNS) at the enterprise layer: Sparkplug B provides the standardized transport, state, and discovery backbone for the OT side of a UNS. However, because spBv1.0 topics are constrained to Group ID / Edge Node ID / Device ID, enterprises building an ISA-95 (Enterprise/Site/Area/Line/Cell) UNS often use Sparkplug B at the ingestion tier and map or bridge data into a broader enterprise topic hierarchy.

Common Production Pitfalls and Engineering Checklist

Even with a clean specification, real-world Sparkplug B deployments run into operational traps if teams treat it as "plug-and-play":

  • Confusing birth state with historical backfill: As Software Toolbox notes, NBIRTH and DBIRTH restore current values and tag definitions after a reconnect—they do not automatically backfill historical samples missed during an outage. If zero data loss is required, configure local store-and-forward buffering at the edge gateway and mark historical records with their original source timestamps.
  • Overlooking broker security and ACLs: Protobuf is a binary encoding format, not encryption. Production deployments still require TLS, client certificates or token authentication, and strict broker Access Control Lists (ACLs) so an edge gateway can publish to its own Group ID / Edge Node ID without subscribing to or spoofing another line's DCMD command topics.
  • Leaving DCMD commands unrestricted: Because NCMD and DCMD allow bidirectional writes back to the edge, isolate command permissions to authorized SCADA/MES host accounts and enforce safety interlocks inside the PLC rather than relying on the broker alone.
  • Forgetting Rebirth throttling: If a misbehaving host application or flapping network repeatedly issues Node Control/Rebirth commands across hundreds of gateways at once, the resulting flood of full NBIRTH/DBIRTH payloads can spike broker CPU and bandwidth. Rate-limit rebirth requests and monitor bdSeq churn in your broker observability dashboard.
  • Skipping alias consistency checks: If you update a gateway's tag configuration without triggering a fresh NBIRTH/DBIRTH, integer aliases can drift out of sync with host applications. Always ensure configuration edits trigger an orderly rebirth cycle.

When engineered with proper buffering, TLS/ACLs, and clear UNS governance, Sparkplug B turns MQTT from a lightweight messaging pipe into a deterministic, self-describing industrial data fabric.

Image Credits

  • Featured image: Chiller plant SCADA control screen showing real-time equipment telemetry and operational status. Photo by Rsparks3 via Wikimedia Commons (CC0 1.0 Public Domain).
  • Session lifecycle diagram: Sparkplug B Session Lifecycle diagram. Illustration: IIoTjob (original artwork).