6 min | By Nelson Atipo
SUMMARY
In large industrial setups, MQTT alone can become hard to manage. Different teams invent their own topic structures; everyone sends payloads however they want—JSON, XML, or something else. Sparkplug B fixes that by adding consistency (in topics and payloads) and built-in device lifecycle awareness (birth/death messages). But before diving into an example, let’s define the key terms that Sparkplug B uses.
With these terms in mind, let’s see Sparkplug B in action! 🤖✨
Imagine we have Machine1 in a factory. It has:
An EoN node called Machine1Node
acts as a small gateway or software agent for these two sensors. When Machine1Node
connects to the MQTT broker, it will publish messages on behalf of both sensors using Sparkplug B’s topic namespace and payload format.
EoN Node (Machine1Node
) connects to the broker with a “last will” that says:
mathematicaCopierModifierIf I disappear, please publish an NDEATH message for me: spBv1.0/MyFactoryGroup/NDEATH/Machine1Node
This ensures that if the node’s connection is unexpectedly lost, the broker automatically tells subscribers, “Machine1Node
is offline.”
But as soon as the node successfully connects, it sends an NBIRTH message:
cppCopierModifierTopic: spBv1.0/MyFactoryGroup/NBIRTH/Machine1NodePayload (binary, conceptually): {
"metrics": [...],
"seq": 0}
That NBIRTH might contain general metrics about the node (e.g. gateway version, uptime).
Our two sensors—TempSensor and VibSensor—are considered devices behind Machine1Node
. The node publishes a Device Birth (DBIRTH
) for each sensor. For example:
cppCopierModifierTopic: spBv1.0/MyFactoryGroup/DBIRTH/Machine1Node/TempSensorPayload (binary, conceptually): {
"metrics": [
{
"name": "temperature",
"dataType": "Float",
"value": 72.5 }
],
"seq": 0}
This DBIRTH tells subscribers:
Similarly, for the vibration sensor:
swiftCopierModifierTopic: spBv1.0/MyFactoryGroup/DBIRTH/Machine1Node/VibSensor{ "metrics": [ ... ], "seq": 0 }
Now everyone knows that Machine1 has two devices: one measuring temperature, one measuring vibration. 🎉
Once born, each device publishes its ongoing data as DDATA:
makefileCopierModifierTopic: spBv1.0/MyFactoryGroup/DDATA/Machine1Node/TempSensor Payload: {"metrics": [
{
"name": "temperature",
"value": 73.1,
"dataType": "Float" }
],
"seq": 1
}
No random naming—everything follows spBv1.0/<group_id>/DDATA/<edge_node>/<device_id>
.
No custom JSON—Protocol Buffers keeps it consistent.
Your SCADA or analytics app just subscribes to:
bashCopierModifierspBv1.0/MyFactoryGroup/#
It automatically receives births, data, and future death messages for all nodes and devices in MyFactoryGroup
. Easy-peasy! 😄
Two ways things can die:
Machine1Node
loses its connection to the broker, the broker itself publishes:
spBv1.0/MyFactoryGroup/DDEATH/Machine1Node/TempSensor Payload: { "seq": 2, ...}
Signaling the entire node is offline, so all its devices are effectively gone too.
Machine1Node
realizes it’s no longer reachable and sends:
spBv1.0/MyFactoryGroup/NDEATH/Machine1Node
Now subscribers know only TempSensor is gone. VibSensor could still be active.
No more guesswork or silent data dropouts! 🚀
spBv1.0/MyFactoryGroup/#
—lets you see everything that’s happening: births, data updates, deaths, etc.
Sparkplug B is a powerful way to bring order to MQTT in industrial environments, ensuring uniform topic names, consistent payload formats, and automatic detection of who’s online and offline. With EoN nodes bridging physical devices to the broker, plus birth and death messages to track lifecycles, you can confidently manage data streams from dozens or thousands of sensors.
But at least now you know how Sparkplug B works—so you can decide whether it’s the right fit for your Industrial IoT project. Happy MQTT-ing! 🤖✨