Imagine Industrial Internet of Things (IIoT) without the burden of re-inventing the wheel each time you change your installation.
co⚡e: Sparkplug™ MQTT edge and host has been designed to provide you with a single point of truth at the Edge of your installation. It offers you a modern, flexible, free and open way for any of your devices to exchange data using Sparkplug™ enhanced MQTT. All you need is an MQTT broker and this library!
Designed by the co-author of MQTT, Arlen Nipper, Sparkplug™ is designed to fit "on top" of regular MQTT. In 1999, when MQTT was invented, it was originally meant for SCADA systems and left out all specifications on how topics and payloads should be structured and how devices should behave. This allowed regular MQTT to be used in different industries, but lacked any standard topic or dataformat.
Sparkplug™ now fills this gap and provides a vendor-neutral specification for the data formats, topic structures, state management, and how topologies should be structured in IIoT scenarios. This way, Sparkplug™ adds several smart features on top of regular MQTT, resulting in a "Sparkplug™ enhanced MQTT". A flexible architecture which allows you to auto-discover edge nodes, devices and their metrics (data & metadata) as devices and applications can be added and removed anytime without affecting the system as a whole. Report by Exception (RBE) saves bandwidth, memory and computational power on the producer and the consumers of data. Last but not least, your data can be delivered securely via the latest industry strength security specifications and with rich meta-data for added context.
Sparkplug™ benefits at a glance
A comparison between regular MQTT and Sparkplug™ enhanced MQTT.
Fullspec MQTT v3.1.1
Sparkplug™ B MQTT
Pub / Sub
Last Will and Testament
Continuous Session Awareness
Decouples devices from applications
Latest in TCP/IP security
Setup with minimal coding
Standardized Payload definition
Standardized Topic Namespace definition
Auto discovery of Nodes, Devices, Metrics, Properties and Templates
Meta-data for Metrics
Metric Templates i.e. complex variables (nested structs)
Death and Birth Certificates
Report by Exception (RbE)
Bi-directional data-transfer between Host and Node
Providing the CODESYS ecosystem a full specification compliant implementation of Sparkplug B Edge and Host nodes, which run on any sufficient capable CODESYS based controller. Since the code is fully IEC compliant, the library is portable over various fully IEC compliant brands and types of industrial controllers. Since stability is key, the code is continuously and rigorously tested.
In short, this solution aims to "marry" CODESYS with the Sparkplug™ MQTT protocol and further open up the vendor-independent CODESYS ecosystem with the IIoT market, thus fully exploiting the synergy between CODESYS and MQTT Sparkplug.
Last but not least
Our library has been built in open source, which should allow any experienced programmer to add/remove or alter parts of the code. It allows a for peer to peer code review and to expand on the existing code base. The Sparkplug™ specification has been released with open-source in mind, and we are delighted to share our library also! Of course the CODESYS runtime and MQTT library we utilize are not open-source.
An overview of the components in this library are lined in red;
Sparkplug B Edge, ususally 1 per controller
Sparkplug B Device (plugs into an Edge), usually several per controller
Sparkplug B Primary Host, Xperimental PLC based step in replacement for any full fledged PC based SparkplugB Primary SCADA Host.
As seen the library allows for a mix with regular third party capable Sparkplug™ MQTT devices.
Details on the different components in the infrastructure:
[Infrastructure] explains various node functions like Edge, Device, Primary Host, etc etc.
[Security] explains the available security levels,
[Messages] explains the various defined sparkplug messages and their payloads.
Tools & Development
Some tools we use to develop our library.
Ignition Primary Host node
We test our code against Ignition as Primary Host node and against the Sparkplug TCK when it is available.
However, we are also in full preparation of developing a CODESYS variant of a Primary Host.
To experience the full capabilities of Sparkplug in action, you can create your own free test system using this setup guide: Setup a test system with Ignition Primary Host. When our Primary Host node has finished, there will be no explicit need for Ignition anymore.
We will test and verify our library against the TCK toolkit once it comes publicly available.
co♻e: A unittest framework for CODESYS based systems
We aim to cover the entire solution with pragmatic unit, integration and pov tests.
MQTT Client Library Usage
Under the MIT license you are free to use the co⚡e: Sparkplug™ MQTT edge and host library. You are free to implement and use another MQTT client implementation. If you do, we urge you to implement a stable & 100% MQTT v3.1.1 capable library. However, in this project we will use the following library;
Server receive Edge / Device xDEATH & LWT -> Data becomes STALE
Server send Edge / device xCMD (DATA)
Strict enforcement of SEQ / BDSEQ check,
Server sends Edge REBIRTH to Edge or Device,
Metric property support,
Unittesting and TDD - CI/CD integration to (auto)test the solution to maturity,
Debugging / Optimization/ Refactoring of Standard package
Release of Package v18.104.22.168
v22.214.171.124 Advanced version: Mature Edge, Device and Host implementation sporting user-friendly advanced features
Historical data support,
Primary Host Advanced Node Command support: dynamic discovery of supported commands from Edges / Devices,
High Availability (HA) support,
Debugging / Optimization/ Refactoring of Advanced package.
Release of Package v126.96.36.199
By downloading and using our software you abide by the MIT License
The co⚡e: Sparkplug™ MQTT edge and host library is MIT licensed and open sourced, but to run it for more than 30 minutes you will need to purchase an IIoT Libraries Bundle SL from the CODESYS Store, as we make use of the MQTT Client contained in it.
Mandatory: Contains Linked List solution and contains the common basis for the Edge/Device and Primary Host solution. You need both libraries in order to run Edge/Device or Primary Host.
You need all the libraries above to run the example. A small guide on how to get started with the example can be found here: Preview how-to
Download co⚡e: Sparkplug™ MQTT Example for Edge and Host
System requirements and restrictions
CODESYS Development System Version 188.8.131.52 or higher
CODESYS Control Version 184.108.40.206 or higher
A separate CODESYS IIoT libraries SL per PLC or Machine
Any 100% fully compliant MQTT v3.1.1 broker or cloud service. Sparkplug requires the following: QoS 0 and 1, Retained Messages, Last Will and Testament, A flexible security system.
Brokers or cloud services like AWS IoT Core, Azure IoT Hub or Google Cloud Iot Core are not supported. They do not not implement MQTT v3.1.1 in full. Ask Google, Amazon or Microsoft for a fully compliant MQTT v3.1.1 implementation.
If you have no CODESYS licenses available, you can still enjoy Sparkplug with the following limitations in mind:
Any unlicensed CODESYS runtime runs in a DEMO trial period for 2 hours, after that period you must restart the runtime,'
Any unlicensed IIoT SL library runs in a DEMO trial period for 30 minutes, after that period you must re-download the runtime.
Because this library is MIT licensed you can exchange the licensed MQTT Client SL for any other flavour MQTT client as you see fit, but you must do so yourself. Ofcourse we are happy to provide you with our advice and / or some assistance.
Ignition's SCADA as host is not necessarily needed since we implement a 'lightweight' primary host node, but if you wish you can always choose it;
Ignition Enterprise SCADA runs in a DEMO trial period for 2 hours or choose to opt in for a FREE maker Edition.
We are passionate software developers who maintain co⚡e in spare time.
CODESYS fully supports us in our efforts by providing a free and open source platform for everybody to use.
Read more on #co5e