Sparkplug B adds a fixed topic structure, a binary payload and session state on top of MQTT. Birth certificates list every metric a gateway will send, death certificates tell consumers when it drops off, sequence numbers expose lost messages, and a historical flag marks backfilled values. Plain MQTT with a JSON convention is enough when one or two applications consume the data, you control both ends, and you are willing to write your own rules for online status, metadata and late data. When several applications from different suppliers must trust the same data without custom code, Sparkplug B earns its extra complexity.
Most comparisons describe Sparkplug from the publisher’s side. This article looks at it from the side of the application that consumes the data, because that is where the differences show up: what the consumer knows, what it has to assume, and what it must do when something goes wrong. It is written for controls engineers, IT/OT leads and integrators choosing a convention before the first gateway goes in.
What plain MQTT gives you and what it leaves to you
MQTT moves messages from publishers to subscribers through a broker, with three delivery levels and a few useful features for state. It says nothing about topic names or payload contents. Those are yours to define.
MQTT.org describes MQTT as “an OASIS standard messaging protocol for the Internet of Things (IoT)”, designed as “an extremely lightweight publish/subscribe messaging transport.” Two versions are in use. MQTT 3.1.1 became an OASIS Standard on October 29, 2014 and is also published as ISO/IEC 20922:2016. MQTT 5.0 is dated March 7, 2019.
What MQTT defines
- Quality of service. MQTT has “3 defined quality of service levels: 0 - at most once, 1- at least once, 2 - exactly once.” QoS 0 can lose a message; QoS 1 can deliver it twice.
- Retained messages. The broker keeps the last message on a topic and gives it to anyone who subscribes later, so a new consumer sees the current value immediately.
- Will messages. A client registers a message when it connects, and the broker publishes it if the client disappears. The MQTT 5.0 specification lists situations such as “An I/O error or network failure detected by the Server” and a client that “fails to communicate within the Keep Alive time.”
- Topics and wildcards. Topics are case-sensitive strings with levels separated by
/, and subscribers can use+and#wildcards.
What MQTT leaves open
Both versions of the specification say the same thing about the payload: “The content and format of the data is application specific.” MQTT does not define:
- How topics are named or how deep the hierarchy goes.
- How a value is encoded: JSON, CSV, a bare number or binary.
- Which data type a value has, or its engineering unit.
- How a consumer learns the full list of values a device will publish.
- How a consumer knows a value is stale because the device went offline.
- How a consumer detects that a message was lost.
- How late or buffered values are marked so they do not overwrite current ones.
Why delivery levels do not settle it
It is tempting to treat QoS 1 or QoS 2 as the answer to data reliability. They answer a narrower question: whether one message crosses one connection. They do not tell a consumer that a gateway has stopped reading its PLC while still connected to the broker, that a value it holds is an hour old, or that a message was dropped before it reached the gateway’s outbound queue. Those are application questions, and MQTT deliberately leaves them to the application.
Every plant that uses plain MQTT answers those questions, either deliberately in a written convention or accidentally in each integrator’s code. Sparkplug B answers them in a published specification.
What Sparkplug B adds, at a glance
Sparkplug B is a specification for the topic namespace, the payload and the session behavior of MQTT clients. It turns the open questions above into rules a consumer can rely on without talking to the publisher’s developer.
| Concern | Plain MQTT with a JSON convention | Sparkplug B |
|---|---|---|
| Topic structure | Your choice, usually an ISA-95 style path | Fixed: spBv1.0/group_id/message_type/edge_node_id/[device_id] |
| Payload encoding | Your choice, usually JSON text | Google Protocol Buffers, binary |
| List of values a device sends | Not defined; documented separately | Birth certificate lists every metric with name, data type and value |
| Online and offline | Your own status topic with a Will message | Birth and death certificates, with a bdSeq number linking them |
| Lost messages | Not detected unless you add a sequence | Sequence number 0 to 255 in every data message |
| Late or buffered data | Not defined | is_historical flag on each metric |
| Data types | Whatever JSON can express | Defined types, from 8-bit integers to datasets and templates |
| Who consumes | Any MQTT client that can read JSON | Any MQTT client that can decode the protobuf schema |
| Commands to devices | Your own command topics | NCMD and DCMD message types |
| Host application awareness | Not defined | Primary Host STATE messages tell edge nodes whether the main consumer is online |
The Eclipse Sparkplug home page states the two properties most plants care about: “Birth and death certificates provide subscribing clients confidence in data validity”, and the design “requires no open port for edge of network devices”. The second point is shared with plain MQTT, since both have the edge device connect outward to the broker.
Which Sparkplug you are reading: 3.0, ISO/IEC 20237 and older documents
The current version is Sparkplug 3.0, dated October 21, 2022, and also published by ISO and IEC as ISO/IEC 20237:2023. Many pages still cite version 2.2 from 2019. Check which one a document or product follows before you rely on its details.
The Eclipse Foundation’s revision history lists:
| Version | Date | Description in the revision history |
|---|---|---|
| 1.0 | May 26, 2016 | Initial release |
| 2.1 | December 10, 2016 | Payload B addition |
| 2.2 | October 11, 2019 | Migration to Eclipse Foundation branding |
| 3.0 | October 21, 2022 | Migrated to AsciiDoc, completely reorganized, explicit normative and non-normative statements added |
The same page notes that “Versions prior to v. 3.0 are listed for informational purposes only.” The ISO catalog lists ISO/IEC 20237:2023, “Information technology, Sparkplug version 3.0”, edition 1, published October 2023 (we read the catalog page through a web archive capture from April 2026, because the live page refused automated access).
Two practical consequences follow. First, 3.0 states its requirements as numbered MUST and SHOULD statements, so you can check a product against specific clauses instead of general descriptions. Second, the “B” in Sparkplug B refers to the payload definition, not the specification version. Sparkplug 3.0 defines the B payload; the older A payload is, in the specification’s words, “now deprecated”. When a product sheet says “Sparkplug B support”, ask which specification version it was tested against.
The session lifecycle from the consumer’s side
A Sparkplug consumer learns everything from four kinds of message: a birth that lists all metrics, data messages that carry only changes, a death that the broker publishes when the gateway disappears, and a rebirth the consumer can request when it loses track. The figure follows one gateway through a connection, an outage and a reconnection.
In Sparkplug terms, the gateway is an edge node, the machines behind it are devices, and the application that consumes the data is a host application. All quotations below come from the Sparkplug 3.0 specification source, chapters 4 to 6.
Birth: the full list, every time
When an edge node connects, its first message is an NBIRTH. The specification requires that it “MUST include every metric the Edge Node will ever report on”, and that each metric include “the metric name, datatype, and current value.” Devices behind the edge node then publish a DBIRTH with all of their metrics.
For the consumer, this is the most valuable message in Sparkplug. It does not need a separate tag list, because the birth is the tag list, with types and current values. A historian that subscribes at 09:15 gets a complete picture as soon as the next birth arrives, and can ask for one at any time.
The NBIRTH also carries a bdSeq (birth and death sequence) metric that “MUST match the bdSeq number provided in the MQTT CONNECT packet’s Will Message payload.” That number ties this birth to the death certificate the broker is holding.
Data: changes only, numbered
After the births, the edge node publishes NDATA and DDATA messages with only the metrics that changed. The specification calls this “Report by Exception” and notes that time-based reporting “is not explicitly disallowed by the Sparkplug Specification but it is discouraged.”
Every birth and data message carries a sequence number. The birth starts at 0, and each later message must be “one greater than the previous MQTT message from the Edge Node” until 255, after which it returns to 0. That sequence is how the consumer finds out a message went missing.
All of these messages “MUST be published with MQTT QoS equal to 0 and retain equal to false.” This surprises people who expect QoS 1 for important data. Sparkplug’s model is not to retry each message; it is to detect a gap and resynchronize the whole state.
Death: the broker speaks for the gateway
The NDEATH is not published by the edge node. It is registered as the MQTT Will message when the edge node connects, and the broker publishes it when the connection fails. Its payload contains only the bdSeq, and the Will is sent with QoS 1.
On receiving an NDEATH whose bdSeq matches the last NBIRTH, a host application “should set the data quality of all metrics to STALE.” That is the behavior plain MQTT consumers usually have to build for themselves. The bdSeq check matters: a late death certificate from an older connection must not mark a newer, live session as stale.
Devices behind the gateway: DBIRTH and DDEATH
An edge node often reads several devices: a PLC, a torque monitor, a meter. Each has its own DBIRTH and, when it stops answering, its own DDEATH. The specification makes the edge node responsible: if a device “becomes unavailable for any reason (no response, CRC error, etc.) it is the responsibility of the Edge Node to publish a DDEATH on behalf of the end device.” The host then marks only that device’s metrics stale.
This answers a question plain MQTT conventions often miss. A gateway can be online and connected to the broker while one PLC behind it has dropped off the network. With Sparkplug, the consumer sees the difference: an NDEATH means the whole edge node is gone, a DDEATH means one device is. A JSON convention needs a status topic per device, not only per gateway, to say the same thing.
Rebirth: the consumer’s way to ask again
Every NBIRTH must include a metric named Node Control/Rebirth. A host application that has lost track sends an NCMD writing that metric, and the edge node republishes its births. The specification describes when to use it: if messages with sequence numbers 1, 2 and 4 arrive, a timer starts, and if number 3 does not arrive before a configurable “Reorder Timeout”, a rebirth request should be sent.
The specification leaves part of this to the consumer. It notes that a host application that is “a time series database may want to insert all data that arrives regardless of the message order”, while a rules engine may need strict order. Decide which kind of consumer you are building, and set the timeout to match your network.
Example (fictional). The fictional Line 2 filler is published with group casper-packaging, edge node line-2 and device filler, the same levels the topic namespace builder uses by default. At startup the DBIRTH on spBv1.0/casper-packaging/DBIRTH/line-2/filler lists state, good-count, reject-count, fault-code and line-speed, each with a data type and current value. During the shift, DDATA messages on spBv1.0/casper-packaging/DDATA/line-2/filler carry only what changed, such as the fault code at 07:41 when the bottle feed jams and the state change 11 minutes later when the filler restarts. At 14:00 the last DDATA of the shift carries good-count 40,580 and reject-count 632. A board that restarted at noon asked for a rebirth and had the full picture again as soon as the new birth messages arrived.
Primary host STATE: when an edge node should hold its data
Sparkplug lets an edge node name one primary host application and wait for it. If the primary host is offline, the edge node does not publish into the void; it can store data and send it when the host returns. For a plant with one hosted application, this is the feature that most changes behavior during outages.
A host application announces itself on the topic spBv1.0/STATE/sparkplug_host_id. Its birth payload is JSON, not protobuf, with two keys: online set to true and a timestamp in milliseconds since the Unix epoch, published with QoS 1 and the retain flag set. Its death is the same topic with online set to false, registered as the host’s own MQTT Will message. The specification explains why protobuf is not used here: “This allows Host Applications to work across Sparkplug payload types.”
What the edge node does with it
An edge node configured with a primary host “must wait until the Primary Host Application is online and subscribed to Sparkplug messages before the Edge Node publishes its NBIRTH and DBIRTH messages.” If the host goes offline, the edge node disconnects and starts the connection procedure again. The specification’s own example is the single-consumer case: if the only host application “historizes the data”, it “would be better for the Edge Node to store data while the Host Application is offline”, and then “send all of its stored data and continue publishing normally.”
There can be only one primary host per edge node. Other host applications can still subscribe to everything; they simply do not decide when the edge node publishes. The specification also states that only the primary host “should have the permission to issue commands to Edge Nodes.”
Late data is flagged, not hidden
When stored values are finally sent, each metric can carry the is_historical flag. The specification describes it as marking a value that should “not be considered a real time/current value”, used “for batching, store and forward, or sending local backup data during network communication loses.” A consumer that respects the flag writes the values into history without flashing a board with an hour-old fault.
Sparkplug defines the flag and the host-state handshake. It does not define how the edge node stores data, how much it keeps or how it replays it. Those are product decisions, and the sibling article on store and forward at the edge covers sizing and replay.
One related rule is easy to miss. An edge node using MQTT 3.1.1 must connect with “Clean Session” set to true, and one using MQTT 5.0 must set “Clean Start” to true and “Session Expiry Interval” to 0. In other words, Sparkplug does not rely on the broker keeping messages for a disconnected edge node. Buffering through an outage is the edge node’s job.
Payloads: protobuf, aliases and what the consumer pays
Sparkplug B payloads are binary, encoded with Google Protocol Buffers, which makes them compact and strongly typed but unreadable without a decoder. That is the main cost a consumer pays, and it is worth understanding before you choose.
The specification explains the choice: the goal was “a simple and straightforward binary message encoding that could be used primarily for legacy register based process variables (Modbus register value for example).” The B payload adds templates for complex types, datasets, per-metric properties, aliases, historical data and file data.
What the consumer has to handle
- Decoding. A generic MQTT client shows a Sparkplug message as unreadable bytes. Every consumer needs the protobuf schema and a decoder, either in its own code or through a library or broker feature.
- Aliases. To save bandwidth, a birth can assign each metric a numeric alias. The specification is strict: births “MUST include both a metric name and alias”, and data messages “MUST only include an alias and the metric name MUST be excluded.” A consumer that missed the birth cannot tell what alias 2 means, which is one reason rebirth requests exist.
- Data types. The data type “MUST be included with each metric definition in NBIRTH and DBIRTH messages” and should be left out of data messages. The consumer has to remember types from the birth.
- Null values. A metric can carry
is_nullinstead of a sentinel such as -1. Consumers should treat it as “no value”, not zero. - Transient values.
is_transientmarks metrics that are “of interest to a host application(s) but should not be stored in a historian.” A historian should honor it. - Properties. Each metric can carry a property set of custom key and value pairs. Engineering units, ranges and descriptions can travel this way if your convention defines the keys. The specification does not fix the key names, so write them down.
Commands: NCMD and DCMD
Sparkplug also defines how host applications write to edge nodes and devices. A DCMD sends “a new metric value to an associated metric included in the DBIRTH metric list”, and an NCMD does the same for the edge node itself, including the mandatory rebirth request. The specification leaves the security of commands to the implementer and lists the options: broker access control lists that stop some clients from publishing commands, permissions in the host application, and settings in the edge node that decide whether to honor them.
For plant data collection, the safest setting is the simplest. Allow the rebirth request, which only asks the edge node to republish what it already sends. Refuse every other command at the edge node until someone has written down which value may be written, by whom and why. A gateway that reads controllers read-only should not become a write path because the payload format happens to support one.
Timestamps and case
Sparkplug requires all timestamps in UTC and asks edge nodes and hosts to keep accurate clocks, “typically” through the operating system’s Network Time Protocol service. Metric names are case-sensitive, and the specification warns that “many databases are case-insensitive”, so names that differ only by case cause trouble downstream.
The trade-off in plain terms
Protobuf is smaller on the wire than equivalent JSON and carries types, so it suits cellular links and large tag counts. JSON is readable in any tool, easy to debug with a generic client, and easy to change. For a single line with a wired connection, bandwidth rarely decides the matter. Who has to read the messages usually does.
Plain MQTT with JSON: the rules you write yourself
Plain MQTT with JSON works well when you write down the same things Sparkplug defines: topic structure, payload fields, online status, how to detect gaps and how to mark late data. Skip any of them and each consumer will guess differently.
1. Topic structure
Use an ISA-95 style path: enterprise, site, area, line, cell, then the value name, for example example-co/casper/packaging/line-2/filler/state. Our article on a unified namespace for a small plant covers the naming rules. Decide one more thing early: one topic per value, or one message per device with several values.
- One topic per value is simplest for consumers and works well with retained messages, because each value keeps its own last state. It means more messages.
- One message per device sends fewer, larger messages. A retained message then holds the whole device, and partial updates need care so a consumer does not take missing fields as zero.
2. Payload fields
Fix the field names, types and formats. A minimal convention for one value:
{"value": 632, "unit": "bottles", "ts": "2026-11-20T21:00:00Z", "quality": "good", "seq": 1841}
ts is the time the value was read, in UTC; 21:00 UTC is 14:00 Mountain Standard Time, the end of the fictional Line 2 first shift. quality takes a small set of values such as good, uncertain and stale. seq is a counter per publisher that lets a consumer spot gaps and duplicates. Publish a version number for the convention, and change it when fields change.
3. Online status
Give each gateway a status topic, such as example-co/casper/packaging/line-2/gateway/status. On connect, it publishes “online” as a retained message. In the CONNECT packet, it registers a Will message with “offline”, also retained, on the same topic. Consumers treat every value under that gateway as stale while the status says offline. MQTT 5.0 adds a Will Delay Interval, which lets a gateway reconnect quickly after a brief network blip without triggering the offline message.
4. Gaps and duplicates
Pick a QoS and say why. QoS 1 is a common choice for plant data: a message can arrive twice but should not be lost while the session lasts. The seq field and the timestamp let a consumer drop duplicates. If you use QoS 0 for high-rate values, the seq field is your only way to detect loss.
5. Late data
Add a flag, such as "late": true, for values sent from a buffer after an outage. Consumers write them into history but do not update live boards with them. This is the plain-MQTT equivalent of Sparkplug’s is_historical.
6. Metadata
Publish a retained metadata message per value or per device with unit, data type, range and description, or keep them in the signal inventory and give every consumer access. Without one of the two, the next integrator will guess.
Features of MQTT 5.0 that help
MQTT 5.0 added features that make a JSON convention easier to enforce. Its feature summary lists a payload format indicator and “a MIME style content type” that “are forwarded on to the receiver”, user properties “defined by the Client applications”, and message expiry. Set the content type to JSON and add the convention version as a user property, and a consumer can check both before parsing.
Validate payloads against a schema at the point where they cross into the hosted application. The UK’s National Cyber Security Centre recommends this in its secure connectivity principles for OT: “schemas should be applied to these data flows”, ideally following a “known good” model.
Example (fictional). For the same Line 2 filler, a plain-MQTT convention publishes ten retained topics under example-co/casper/packaging/line-2/, one per signal, plus a gateway status topic. During a 20-minute internet outage the gateway buffers values and, on reconnection, sends them with "late": true and their original timestamps. The hosted shift report writes them into history; the line board ignores them and shows the live values that follow. The convention is two pages long and lives in the namespace document next to the signal inventory.
Choosing by situation
Choose Sparkplug B when several independent consumers need state and metadata without custom code, or when your edge devices already speak it. Choose plain MQTT with JSON when one or two applications consume the data, your team controls both ends, and readability matters more than bandwidth.
| Situation | Lean toward | Why |
|---|---|---|
| One gateway, one hosted application, both configured by the same team | Plain MQTT with JSON | A written convention covers the same ground with less tooling |
| Several consumers from different suppliers (historian, SCADA, analytics) | Sparkplug B | Births, deaths and types are defined once, not negotiated per consumer |
| Edge devices or gateways already publish Sparkplug B | Sparkplug B | Converting to JSON throws away state and types you already have |
| Analysts and IT staff read raw messages for troubleshooting | Plain MQTT with JSON | Readable in any MQTT client without a decoder |
| Cellular or satellite links, or thousands of tags per edge node | Sparkplug B | Binary payloads, aliases and report by exception reduce traffic |
| Applications must send commands to machines | Sparkplug B, or a strictly separated JSON command convention | Sparkplug defines command messages and limits commands to the primary host |
| Edge node should hold data while the main application is down | Sparkplug B | Primary Host STATE gives a defined handshake; JSON needs your own equivalent |
| Team has no protobuf experience and no budget to gain it | Plain MQTT with JSON | A convention the team can maintain beats a standard it cannot debug |
Two cautions apply whichever way you lean. First, mixing both on one broker is possible but needs a rule about which data lives where, so consumers do not read the same signal twice under two names. Second, the choice is easier to change early than late. Converting a convention after five consumers depend on it means changing five applications.
For a small plant starting with one line and one hosted application, plain MQTT with a written JSON convention is usually enough, as long as the convention covers status, gaps and late data. Revisit the choice when a second independent consumer arrives. If the gateway you choose already speaks Sparkplug B well, there is little reason to turn it off.
Changing your mind later
Moving from one convention to the other is possible, and planning for it costs little. Three paths are common.
- Translate at the consumer. A historian or broker feature decodes Sparkplug B and writes values under plain names. The edge stays on Sparkplug; consumers that prefer JSON get it.
- Translate at the edge. A gateway that publishes JSON today can often publish Sparkplug B as well, on a different topic tree, while consumers move one at a time.
- Run both for a period. Publish both forms from the same gateway during a migration, with a written end date, and check that values agree before switching a consumer.
In every case, the ISA-95 levels you chose for plain topics should map one to one onto Sparkplug’s group, edge node and device, as the topic namespace builder shows. If they do, changing encoding later is a configuration task, not a renaming project.
Sparkplug B and OPC UA
Sparkplug B and OPC UA are not alternatives at the same layer. OPC UA gives a client a rich, typed and secured model of one server, usually a machine or controller. Sparkplug B gives many consumers a shared view of many edge nodes through a broker. Many plants use both.
The OPC Foundation describes OPC UA as a platform-independent architecture with security covering “encryption, authentication, and auditing”, comprehensive information modeling, and subscriptions that “report-by-exception when values change.” OPC UA companion specifications define standard models for machine types, which Sparkplug does not attempt.
Sparkplug’s strength is the other side: one broker, many publishers and subscribers, and defined session state across all of them. Its specification describes the advantage over poll and response protocols: “Additional Sparkplug Host Application MQTT clients can connect and subscribe to any of the real time data without impacting the Primary Host Application.”
OPC UA also has a broker-based mode. OPC UA Part 14, PubSub, release 1.05.06 dated October 22, 2025, defines a publish and subscribe model alongside client and server, and notes that “the use of established standard messaging protocols like MQTT with JSON data encoding supports the cloud integration path.” So the question “Sparkplug or OPC UA over MQTT” is a real one for new designs.
A common arrangement is OPC UA from the controller to the gateway, then MQTT, with Sparkplug B or a JSON convention, from the gateway to the broker and on to hosted software. Our guide to bridging Modbus devices to MQTT covers the same handover for meters and drives that speak neither.
Security is the same job either way
Neither choice secures anything by itself. Sparkplug’s security chapter states that it “is provided for guidance only and is non-normative”, and MQTT leaves encryption to the transport. The work is the same for both conventions: encrypt, authenticate each client, and limit what each client may publish.
- Encrypt the connection. The Sparkplug guidance says that “when using public networks and data is sensitive”, connections “should be encrypted”, using TLS. For plant data leaving the site, treat that as a requirement. The NCSC names “MQTT over TLS” among the secure, standardised protocols for data leaving the OT network.
- One credential per client. Every gateway and every consuming application gets its own username and password or certificate, stored in a password vault, never in a document or an email.
- Access control lists on the broker. The Sparkplug guidance suggests restricting “each Edge Node to a specific set of topics it can publish and subscribe on.” The same applies to a JSON namespace: a gateway publishes only under its own line, and a report subscribes only to what it reads.
- Outbound only. The gateway connects out to the broker; nothing connects in to the plant network.
- Validate at the boundary. Check payloads against the schema or the Sparkplug definition where they enter the hosted application, and reject what does not fit.
Our security page describes how these rules are applied to gateways, credentials and hosted data.
Test your choice before you commit
Run a short test on one gateway before the convention spreads. Each test below takes minutes and shows how a consumer will behave on a bad day, which is when the choice matters.
- Read the raw messages. Subscribe to everything with a generic MQTT client (
spBv1.0/#for Sparkplug, your enterprise level plus#for JSON). Confirm the people who will troubleshoot can read what they see, with or without a decoder. - Pull the network cable on the gateway. Check that a death certificate or offline status arrives, and that every consumer marks the values stale rather than showing them as live.
- Restart a consumer mid-shift. A Sparkplug consumer should request a rebirth and rebuild its picture; a JSON consumer should get the current state from retained messages.
- Restart the gateway. Check that births or retained values reappear, and that the bdSeq or your status topic moves on to a new session.
- Drop the internet for 20 minutes. Check that buffered values arrive with original timestamps and a late or historical flag, and that boards do not replay old events.
- Compare one count with the machine. The good count in the consumer at 14:00 should match the filler’s own counter, whichever encoding carried it.
Checklist for the convention document
- Specification and version named (Sparkplug 3.0, or your JSON convention version)
- Topic structure and level names, with examples
- Payload fields, types, units and timestamp format
- Online status mechanism (death certificates or a Will-backed status topic)
- Gap detection (Sparkplug sequence or your own
seqfield) - Late data marking (
is_historicalor your own flag) - QoS per message type, with the reason
- Who may publish commands, if anyone
- Where metadata lives
The convention goes into the documentation set our machine connectivity service delivers, next to the signal inventory and the topic namespace. Whichever encoding carries the data, it stays exportable in open formats under our open data commitments. To see both topic forms for your own plant’s levels, try the topic namespace builder.
