Skip to content

03 Sparkplug B Decode

Mark Todd edited this page Jun 25, 2026 · 1 revision

Sparkplug B Decode

MQTTProbe decodes Sparkplug B messages in real time, providing a structured view of your Sparkplug B topology including nodes, devices, and metrics.

Topic Format

Sparkplug B messages follow this topic structure:

spBv1.0/{group_id}/{message_type}/{eon_node_id}[/{device_id}]

Message Types (Verbs)

Verb Sender Description
NBIRTH EoN Node Node came online — includes full metric definitions with aliases
NDEATH MQTT Broker (Last Will) Node lost connection
NDATA EoN Node Periodic data update (alias-referenced)
DBIRTH EoN Node Field device came online
DDEATH EoN Node Field device went offline
DDATA EoN Node Periodic device data (alias-referenced)
NCMD Primary App (SCADA) Command to EoN node (observed, not acted)
DCMD Primary App (SCADA) Command to device via EoN node (observed, not acted)

How It Works

Topic Parsing

MQTTProbe parses incoming MQTT messages on topics starting with spBv1.0/:

  1. Splits the topic on /
  2. Extracts: Group ID (segment 1), verb (segment 2), Node ID (segment 3), Device ID (segment 4, if present)
  3. Filters out STATE topics

Payload Decoding

The binary payload is decoded using Google.Protobuf (the Sparkplug B payload is Protocol Buffers encoded):

  1. Detects payload format (Sparkplug B binary, JSON, MessagePack, or plain text)
  2. Parses the protobuf payload into structured data
  3. Extracts metric values with their data types

Data Types

Code Type Code Type
0 Unknown 11 Boolean
1 Int8 12 String
2 Int16 13 DateTime
3 Int32 14 Text
4 Int64 15 UUID
5 UInt8 16 DataSet
6 UInt16 17 Bytes
7 UInt32 18 File
8 UInt64 19 Template
9 Float 20 PropertySet
10 Double 21 PropertySetList

Alias Resolution

Sparkplug B uses numeric aliases to save bandwidth. MQTTProbe maintains an alias map per node/device:

  • During NBIRTH/DBIRTH: Aliases are learned from metric definitions
  • During NDATA/DDATA: Metrics can be referenced by alias instead of name
  • MQTTProbe resolves aliases back to human-readable names for display

Topology View

The Sparkplug Nodes view shows your live Sparkplug B topology:

  • Left panel: Nodes grouped by Group ID
  • Right panel: Selected node details with metrics table and device accordion

Node Status

Status Meaning
Online (green) Node has sent NBIRTH and is active
Offline (red) Node has sent NDEATH or lost connection
Unknown (gray) Node has data but no NBIRTH received yet
Stale (yellow) Node has received data but never sent a birth certificate

Features

  • Group filter: Filter nodes by Group ID
  • Text filter: Search nodes and devices by name
  • Prune offline nodes: Remove offline nodes from the view
  • Request Rebirth: Send an NCMD rebirth request to a node (30-second cooldown between requests)
  • Real-time updates: Topology refreshes every 1 second

Metrics Table

For each node or device, the metrics table shows:

  • Name: Metric name
  • Data Type: Sparkplug B data type
  • Value: Current metric value (floats formatted to 4 decimal places)
  • Last Updated: Timestamp of last received value

Rebirth Command

You can request a node to send a new NBIRTH by clicking Request Rebirth in the node detail panel. This publishes:

  • Topic: spBv1.0/{groupId}/NCMD/{nodeId}
  • Payload: Boolean metric Node Control/Rebirth = true
  • Cooldown: 30 seconds between requests

Payload Format Detection

MQTTProbe automatically detects payload formats in this order:

  1. Empty — No payload
  2. Sparkplug B — Topic starts with spBv1.0/
  3. MessagePack — MessagePack binary format
  4. Binary — Non-UTF8 content
  5. JSON — JSON object/array
  6. XML — XML declaration or tags
  7. Hex — Hex-encoded string
  8. Base64 — Base64-encoded string
  9. Plain Text — Everything else

Clone this wiki locally