Skip to content

MQTT Sparkplug B

Beta

Reads Eclipse Sparkplug B edge nodes over MQTT, for example Inductive Automation Ignition with MQTT Transmission publishing through the MQTT Distributor. The payload is binary (Protobuf), and every edge node announces its metric list, with names, data types and aliases, in its BIRTH messages. CONNECT reads the metrics as ordinary signals, so they can drive the model like any other PLC output.

Sparkplug B is a fourth topic mode of the MQTT interface. One MQTT interface can hold Sparkplug B groups next to single, process image and JSON topics.

  • One session per edge node. CONNECT keeps the state of every edge node it hears: the metric aliases and data types from the last BIRTH, the bdSeq of the current session, the message sequence number and whether the node and each of its devices is online.
  • BIRTH sets the context. An NBIRTH replaces the whole context of the edge node, including all of its devices; a DBIRTH replaces the context of one device. The values in a BIRTH are written to the bound signals right away.
  • DATA by name or alias. NDATA and DDATA messages are matched by metric name, or by alias when the edge node sends aliases only (Ignition does this after the BIRTH).
  • DEATH marks signals offline. An NDEATH is accepted only when its bdSeq matches the current BIRTH session; an older NDEATH is ignored. After NDEATH or DDEATH the affected signals keep their last value and show an offline issue until the next BIRTH.
  • Passive participant. CONNECT publishes no STATE message, sets no last will and never acts as Primary Host, so Ignition’s Primary Host handling and Store and Forward stay as they are. STATE messages of other hosts are ignored.
  • Historical values are not process values. Metrics flagged is_historical (Store and Forward backlog) are not written to the signal. A metric flagged is_null keeps the last value and shows an issue until a valid value arrives.
  • The metric context survives a reconnect. CONNECT keeps the BIRTH context while it runs, also when the interface restarts after you bind new signals or when the broker connection drops. After a restart of CONNECT itself, it needs a new BIRTH (see Allow rebirth).

The Add interface dialog with the catalog row Ignition Sparkplug B (MQTT) and its Beta badge under Fieldbus & IT

  1. Add the catalog row Ignition Sparkplug B (MQTT) in Add Interface, or use an existing MQTT interface. The row sets Protocol version to 3.1.1, which the Ignition MQTT Distributor requires. Enter the broker URL and, if needed, username and password as for any MQTT interface.

  2. In the signal list of the interface, open ⋮ → Add Sparkplug B group… and enter the Group ID. Leave Edge Node ID empty to read every edge node of the group, or enter one to read only that node. CONNECT derives the topic itself, for example spBv1.0/Plant/+/+/#; it is shown in the dialog and cannot be edited.

  3. Optionally tick Allow rebirth (see below) and save.

    The Add Sparkplug B group dialog: Group ID DemoPlant, Edge Node ID Line1-Edge, Allow rebirth ticked, Rebirth interval 30 s and the derived topic spBv1.0/DemoPlant/+/Line1-Edge/#

  4. Press Browse. CONNECT listens for BIRTH messages for up to 20 seconds and lists every metric as a tree of group, edge node, device and metric, with its data type and current value. Pick the metrics you need and add them. They land in the Sparkplug B group, named <Device>_<Metric> (or <EdgeNode>_<Metric> for node metrics); a name that is already taken gets a suffix.

The Browse window for a Sparkplug B group: metrics of the edge node Line1-Edge grouped by device, each with its metric key, data type and direction, five selected for Add to signals

The CONNECT panel with the Ignition Sparkplug B (MQTT) interface connected and five bound Sparkplug B signals showing live values

If no BIRTH arrives in that time, Browse says so in a hint line above the list. Without a BIRTH it still lists the metric names it saw in DATA messages, with guessed data types. Enable Allow rebirth or reconnect the edge node in Ignition, then browse again.

FieldRule
Group IDrequired; must not contain /, + or #
Edge Node IDoptional, empty = every edge node of the group; must not contain /, + or #
Allow rebirthoff by default
Rebirth interval5 to 3600 s, default 30 s

Two Sparkplug B groups on one interface must not overlap: the same group with an empty Edge Node ID and with a concrete one, or the same group and edge node twice, is refused with sparkplug-overlap. Use one group container per group, or distinct concrete edge nodes.

The address of a Sparkplug B signal is the metric key <GroupId>/<EdgeNodeId>/<DeviceId>/<Metric>; for a node metric without a device the device part is -. Browse fills it in; you rarely type it. The metric key includes the group, so the same edge node, device and metric names in two groups stay separate signals.

One metric can be bound to one signal per group container. Binding the same metric again under another name is refused with address-already-bound; rename the existing signal instead.

Sparkplug B signals are PLC outputs only. A PLC input in a Sparkplug B group is refused with sparkplug-read-only, both when you save the configuration and when you bind from Browse.

The signal’s configured type always wins. Browse suggests a type from the Sparkplug data type; when you bind to a model signal that already has a type, the value is converted:

Sparkplug typeSuggested signal typeConversion
Int8, Int16, Int32, UInt8, UInt16Intinto a Float signal as a number
UInt32, Int64, UInt64Int if the value fits Int32, else Floata large integer in a Float signal raises a one-time precision issue
Float, DoubleFloatinto an Int signal rounded (half away from zero)
BooleanBoola number into a Bool signal: not 0 = true; a Bool into a number signal: 1 or 0
String, Text, UUID, DateTimeStringtext goes only into text signals; any value can go into a text signal
DataSet, Template, Bytes, Filenot offeredunsupported metric type issue

A value that does not fit the signal (overflow, NaN or infinity, text into a number) is dropped and reported as value not representable.

BIRTH messages are not retained on the broker, so CONNECT learns the metric list only when an edge node starts or reconnects. With Allow rebirth ticked (in the Add Sparkplug B group dialog, or later in the topic settings of the group), CONNECT sends the Sparkplug Rebirth command to an edge node whose context it does not know, and the node republishes its BIRTH:

  • after connecting, when no BIRTH arrived within 5 seconds;
  • when a DATA message carries an alias CONNECT does not know;
  • when the message sequence (seq, 0 to 255) has a gap, which means messages were lost;
  • when you press Browse.

The command is the standard NCMD spBv1.0/<GroupId>/NCMD/<EdgeNodeId> with the metric Node Control/Rebirth = true, sent with QoS 0 and without the retain flag. It goes only to concrete edge nodes CONNECT knows (configured, bound or seen on the broker), and at most once per edge node within the Rebirth interval.

Without this permission CONNECT only listens. After a CONNECT restart its signals show waiting for BIRTH until the edge node reconnects or republishes its BIRTH.

  • MQTT 3.1.1 on the CONNECT interface. The Ignition MQTT Distributor refuses MQTT 5.0; the catalog row sets 3.1.1.
  • Convert UDTs on in MQTT Transmission (the Ignition default). UDT instances are then published as flat metrics, which CONNECT reads. Template and DataSet metrics are not read yet; they are reported and skipped.
  • Primary Host and Store and Forward need no change; CONNECT is not a Primary Host.
  • The user CONNECT logs in with needs subscribe rights on spBv1.0/<GroupId>/#, and publish rights on spBv1.0/<GroupId>/NCMD/# only if you allow rebirth.

Problems appear as signal issues on the interface card. Each one is raised once when it starts and cleared when it is gone:

IssueMeaning
waiting for BIRTHno BIRTH context for this edge node or device yet
offlinethe edge node or device sent NDEATH or DDEATH; the last value is kept
seq gapmessages from the edge node were lost; values resync with the next BIRTH
unknown aliasDATA used an alias without a known BIRTH
payload errora message was not a valid Sparkplug B payload and was skipped
NDEATH without bdSeqthe death message could not be matched to a session and was ignored
metric null / unsupported metric type / value not representable / precisionsee Direction and data types

The interface status (GET /status of CONNECT) lists the Sparkplug B edge nodes with online state, last BIRTH, sequence gaps and rebirths sent. Interfaces without a Sparkplug B group report exactly as before.

  • Writing to an edge node (NCMD/DCMD for metrics other than Rebirth).
  • Template, DataSet, Bytes and File metrics.
  • Acting as Sparkplug Primary Host (STATE).
  • Sparkplug B in the browser’s own MQTT adapter (Direct mode); Sparkplug B runs in CONNECT only.