Give industrial MQTT data a shared structure
TheSPARKPLUG_B route connects Coreflux to a Sparkplug B namespace. It can decode binary Sparkplug payloads into readable JSON, publish local MQTT topics as a Sparkplug edge node, or run both directions in one route.
When to use it
Use this route when you need to:- consume
spBv1.0/#traffic in LoT Actions, dashboards, or storage Routes; - publish Coreflux topics as
NBIRTH,NDATA, andNDEATH; - group edge-node metrics into Sparkplug devices;
- accept
NCMDorDCMDwrites for selected metrics; or - gate edge-node publishing on an external Primary Host.
Start by choosing the direction in which Coreflux participates.
Quick Start
- Decode to JSON
- Publish as an edge node
- Decode and publish
Decode every Sparkplug B publisher on the local broker into readable MQTT topics:This mode listens to all
spBv1.0/# traffic. You do not need a Group ID or Edge Node ID.Choose the Coreflux role
MODE is the canonical setting. DIRECTION remains accepted as a deprecated alias with the same values.
Configure the Sparkplug connection
TheSPARKPLUG_CONFIG block controls the route mode, edge-node identity, target MQTT broker, and optional Primary Host gating.
GROUP_ID and EDGE_NODE_ID do not filter decoded traffic. The decode path always consumes the complete spBv1.0/# namespace.Declare edge-node metrics
InENCODE or BOTH mode, add node-level metrics directly to the route and device-level metrics inside ADD DEVICE.
This complete route publishes a node metric and a writable device metric to a remote broker:
Float, Double, Boolean, String, Text, UUID, DateTime, and Bytes. DataSet and Template values can be decoded but not encoded.
Understand the message lifecycle
When the encode path connects, Coreflux:- publishes
NBIRTH, includingbdSeqandNode Control/Rebirth; - publishes one
DBIRTHfor each declared device; - publishes
NDATAorDDATAwhen a source topic changes; - republishes births after a
Node Control/Rebirthcommand; and - publishes death messages on a graceful stop or delivers
NDEATHthrough the MQTT Will after a crash.
NCMD and DCMD values. Coreflux republishes each accepted value to its local write topic.
Gate publishing on a Primary Host
SetPRIMARY_HOST_ID when an external Primary Host must be online before the edge node publishes:
spBv1.0/STATE/PlantHost topic. It defers births and suppresses data until the host reports online:true, then publishes fresh births and resumes data.
Consume decoded topics
The decode path converts the fixed Sparkplug wire namespace into a JSON topic tree:
Metric names containing
/ create deeper topic levels. The name field in the JSON payload remains authoritative.
Verify the route
1
Check route health
Publish the connection check command to Confirm
$SYS/Coreflux/Command:$SYS/Coreflux/Routes/PlantDecoder/status reports the route as connected or active.2
Observe Sparkplug traffic
Use any MQTT client to confirm messages arrive under
spBv1.0/#.3
Subscribe to decoded output
Subscribe to
sparkplug/decoded/#. After a BIRTH message, named metric topics and retained $status topics appear.Troubleshooting
No decoded topics appear
No decoded topics appear
Confirm the route is active and that a Sparkplug B publisher is sending valid protobuf payloads under
spBv1.0/#. Decoded output appears under sparkplug/decoded/#.Metrics appear with unresolved aliases
Metrics appear with unresolved aliases
Alias-only DATA arrived before its matching BIRTH. Wait for or request a rebirth and monitor
$error for alias_map_unavailable.The edge node remains silent
The edge node remains silent
If
PRIMARY_HOST_ID is configured, confirm the matching host publishes retained {"online":true} state on the same target broker configured by SERVER and PORT.Commands do not reach local topics
Commands do not reach local topics
Confirm the metric has
WRITABLE "true" and a WRITE_TOPIC or DESTINATION_TOPIC. Read-only metrics reject inbound commands.Best Practices
- Give every edge node a unique
GROUP_IDandEDGE_NODE_IDpair. - Build automations on
sparkplug/decoded/#, not on opaque protobuf topics. - Use retained
$statustopics for availability checks. - Load broker credentials with
GET ENVandGET SECRET. - Monitor
$errorand route status for repeated alias or decode failures.
Next Steps
Configure Sparkplug Host
Make Coreflux the Primary Host and issue commands to edge nodes.
Store decoded data
Persist readable Sparkplug metrics in a database.

