Home


IEC Sparkplug B Payload for MQTT

This page: Introduction | Development | Progress | Download

General SparkplugB Information: Infrastructure | Security | Messages

Guides: Setup a test system | Add SparkplugB to an existing CODESYS project

Introduction

(reading time 20 seconds)

Sparkplug is truly unique and offers a modern, free and open way for any of your devices to exchange data using MQTT as a basis. By exploiting the scalability of MQTT and adding a well defined payload to the MQTT contents, the protocol provides you a flexible architecture. It allows you to auto-discover Nodes, Devices and their Data (Metrics). By combining the properties of the existing MQTT infrastructure and the Sparkplug payload definition, this is the most flexible and powerful protocol out there. You can add or remove nodes/devices on the fly. Whether your devices are state-of-the-art or legacy, this protocol is able to handle all types of devices. Last but not least, your data can be delivered securely and with rich meta data for added context.

Goal

(reading time 60 seconds)

Giving Sparkplug B a full specification compliant vendor independent implementation for CODESYS based systems. In theory this library can run on any sufficient capable hardware platform.

At this moment in time, there seem to be two big IIoT protocols on the market: OPC-UA and MQTT family based protocols (like AWS, Google Cloud or MZ Azure etc).
Sparkplug is part of the MQTT based protocols. Both families of protocols are great, very reliable and very secure. However, Sparkplug is simple, lightweight, flexible, very fast and very secure and vendor independent, while at the same time keeping CPU and bandwidth consumption to a minimum*.

Also, there are some caveats in using OPC-UA as at this time. While a pure IEC-code implementation of Sparkplug is nowhere to be found, OPC-UA is not open IEC-code and "Store & Forward" is not mandatory and so OPC-UA has a lot of untapped potential.
MQTT however, is merely a means to get information from point A to B. It does not prescribe the user how data should be mapped and transported. The user is free to use any data format and the user is responsible for adding context themselves. While this seems great on first sight, it hinders quick, smart and vendorneutral data exchange between all parties.
This is where Sparkplug steps in, it provides you with open, lightweight, vendor-neutral, well defined data exchange, state aware transmission and state aware data on top of what MQTT allready offers.

With the benefits of MQTT we already have:

  • Simple and open
  • Pub/Sub
  • Last will and testament per MQTT node
  • Bandwidth efficient (fast)
  • State aware connection
  • Decouples devices from applications
  • Utilizes latest TCP/IP security

With the added benefits of Sparkplug on top we get:

  • Fully auto discover nodes, tags and capabilities
  • Including tag metadata,
  • State aware (meta) data,
  • Report by Exception (RbE), polling is a thing of the past due to built in session and data state awareness. Polling and watchdogs are thus unnecessary and redundant
  • Historical Store and forward,
  • File Transfer,
  • High Availability
  • Open standard,
  • Provides industry interoperability with other open standards.

Therefore this project aims to "marry" any CODESYS based controller with Sparkplug and open up the vendor-independent CODESYS ecosystem with the IIoT market using all advantages that Sparkplug protocol offers.

We like having a major part of the code such as the communications built in open source allows experienced programmers to add/remove or alter parts of the code. It allows peer to peer code review and to build/expand on the code base.

Stateful? Why do I need it?

Sparkplug is a specification for MQTT enabled devices and applications to send and receive messages in a stateful way. This means that each participant is fully aware of each other's connection and data state. While MQTT itself is stateful by nature, it does not ensure that all data on a receiving MQTT application is neither current or valid.
Sparkplug B provides a mechanism on top of MQTT for ensuring that device or application data is always current and valid, it adds a layer validation into the transmission itself. Next to this, Sparkplug B can be used to act as a gateway between legacy and modern devices for seamless interaction. Lastly, Sparkplug B is capable of leveraging historical "store & forward" to ensure that data-gaps are a thing of the past.

Flexible Architecture

An overview of the Sparkplug architecture can be found here. These links will take you to a different page.

Development

Additional Information About Sparkplug

Any additional information about Sparkplug can be found at the Eclipse Sparkplug® Working Group website

https://sparkplug.eclipse.org/

Current Sparkplug specifications:

https://www.eclipse.org/tahu/spec/Sparkplug%20Topic%20Namespace%20and%20State%20ManagementV2.2-with%20appendix%20B%20format%20-%20Eclipse.pdf

Primary (SCADA) Host node

At this point in time we test against Ignition as the Primary SCADA Node, however, we are in full preparation of developing a CODESYS variant of the Primary Node.
While we are busy building and testing this CODESYS based primary node, we advise you to install a version of Iginition (a Primary SCADA node) to see the full capabilities of SparkplugB in action. You will not regret doing so as it demonstrates the power and ease of Sparkplug. See this step by step guide to create your own test system: Setup a test system

CODESYS based Primary Host node (BYOS)

Planned and in preparation, hold on!

The envisioned variant of a CODESYS based Sparkplug Primary Node should be able to act as a lightweight alternative to Ignition SCADA. Since this version will (obviously) not implement it's own SCADA, you can bring your own SCADA (BYOS). A typical CODESYS PLC will have no issue being integrated into a modern SCADA and thus expose all SparkplugB Nodes, capabilities and data.

A machine 2 machine (m2m) host node is also planned, this will let PLC's directly communicate with each other without user interaction. Note that Sparkplug enabled m2m can offer a lot of added value in comparison with standard MQTT or even classic peer to peer communication. Allthough the PLC's will seemingly communicate directly, they physically do not communicate peer to peer. In reality they share no direct connection, since the MQTT broker acts as a (secured) proxy.

PLC M1 <> MQTT-BROKER <> PLC M2

Ignition SCADA

It's up to you to decide which version of Ignition you wish to run as they are identical but differ in use-case scenario.
The provided information is thus not intended as advertisement but merely to provide you with enough information for you to make a choice on what installation to choose.

Maker Edition

Ignition Maker Edition has powerful industrial-grade features of Ignition Enterprise by Inductive Automation️® to any number of your personal or educational projects
at no cost. All you need is a permanent internet connection for it to work (so called 'always connected').

https://inductiveautomation.com/ignition/maker-edition for more information

Enterprise Edition

This is the full fledged version of Ignition Enterprise SCADA. Without proper licensing it runs in a DEMO trial period for 2 hours. The trialperiod can be extended an unlimited amount of times by a single push of a button.

https://inductiveautomation.com/ignition/ for more information

Public MQTT Brokers

Developers and testers will find the following public brokers useful:

Mosquitto MQTT Testbroker

Host: test.mosquitto.org
TCP Port: 1883
TLS Port: 8883
TLS with Client Certificate Port: 8884

HiveMQ MQTT Testbroker

Host: broker.hivemq.com
TCP Port: 1883

These broker channels are entirely open, so beware what data you share.
Read Caveats for a good understanding of their service availability

https://test.mosquitto.org/ for more info
http://broker.hivemq.com/ for more info

MQTT Explorer

MQTT.fx supports limited SparkplugB payload protobuffer decoding, so it is a very good & flexible test client.

http://www.jensd.de/apps/mqttfx for more information
MQTT.fx is published under Apache License, Version 2.0.

MQTT Client Library Usage

You are free to use any MQTT Library implementation you wish.
However in this project we will use the following Library

https://store.codesys.com/iiot-libraries-sl.html
Without a license, the software runs for 30 minutes in demo mode.

Progress

Timeframe

The fruits of our labour can be enjoyed here, in the download section. Our software is aimed to be "best in class", although it is written by (Professional) enthusiasts. We develop this software as individuals. We choose to to give this project our valuable resources: time and effort. This form of development stimulates our creativity in full freedom without boundaries or limitations.
This means that we do not have any hard deadlines to meet apart from those we impose on ourselves. Of course, we set milestones and progress is being made. .

Download

By downloading and using our software you abide by the MIT License
The Sparkplug library itself is MIT licensed and open sourced, but to run it for more than 30 minutes you will need to purchase an IIoT Libraries SL from the CODESYS Store, as we make use of the MQTT Client SL. Because the library is MIT licensed you can exchange the MQTT Client SL for any other MQTT client you wish but you must do so yourself.
Offcourse we are happy to provide with assistance or advice.

  • NOTE If you have no licenses available, you can still preview 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 minutess, after that period you must re-download the runtime
  • Without proper licensing, Ignition Enterprise SCADA runs in a DEMO trial period for 2 hours or opt in for a FREE maker Edition

SparkplugB v2 preview (v1.3.3.0) Library available

27 Dec 2020: We implemented working Bidirectional communication from Primary SCADA to EoN/Device.

If an EoN or Device metric gets written on SCADA side, it will be written back to the EoN or Device instantaneously. When the next EoN publish interval expires, the written values will be reflected to SCADA again. Since SparkplugB reports by exception, only changed values are sent and thus reflection will trigger 'by-design'. Useful when checking if a command or setpoint has processed. Handling of multiple devices connected to an EoN. Updated TLS handling. Updated to MQTT Client SL v.1.0.2.0 (current latest version).

Download the preview and try it for yourself but beware as this library can contain bugs.
If you stumble upon any bugs, please share them with us by posting a ticket or leaving a message (at the bottom of the page).
For a list of capabilities see Roadmap


* v1.3.1.1 Ignition SCADA in combination with CODESYS based EoN and 3 Devices visualised (Initialisation, Connection, BIRTH and DATA and the session and data state awareness)

Download PREVIEW SparkplugB v1.3.3.0 library

Download PREVIEW SparkplugB v1.3.3.0 example

SparkplugB v1.0.0.0 Library

30 nov 2020: A package and a complete guide are available.

With version 1.0.0.0, you can turn your CODESYS controller into a Sparkplug Edge of Network Node.
So far we have implemented only sending data from CODESYS, you cannot receive data from the SCADA. This feature will not be far behind.

1/1
IEC SparkplugB v1.0.0.0 Installation

For a list of capabilities see Roadmap. The package contains all components in a convenient single installer.

Download v1.0.0.0 Package

Roadmap

Our general vision and milestones. Milestones which have been completed are clearly marked.
This roadmap is subjected to change and priorities.

Basic (v1.0.0.0)

  • Basic MQTT Publisher/Subscriber implementation (FB_MQTT_PubSub),
  • Basic Google Protobuf payload encoder / decoder (FB_Payload_Simple),
  • Basic Metric Support for Bool, Real, DWord, Int, Byte etc, etc (FB_SparkplugBSimple, etc, etc.),
  • Basic SparkplugB implementation, responsible Topics & sending messages (No support for receiving commands apart from Rebirth),
  • Basic EoN Node, responsible for publishing Node/Device metrics (FB_Edge_Of_Network_Node),
  • Basic EoN Node TLS Connection Support,
  • Basic EoN Node Server Command support: Rebirth,
  • Debugging / Optimization/ Refactoring of Minimal Viable Product.
  • Release of Minimal Viable Product v1.0.0.0

Standard (v2.0.0.0)

  • Standard Metrics Support,
  • Standard FB_Device, acts as a digital representation of a physical device sending simple metrics,
  • Standard Support for receiving Server Commands, setpoints etc,
  • Standard Bind Multiple Devices to an EoN (see v1.3.3.0 preview),
  • Standard AWS IoT Core Support,
  • Standard CODESYS based SparkplugB Primary Node Implementation: Bring your own SCADA (BYOS)
  • Standard Support for Aliases for optimized communication data bandwidth and CPU load,
  • Debugging / Optimization/ Refactoring of Standard Product,
  • Release of Standard Product v2.0.0.0

Advanced (v3.0.0.0)

  • Advanced general Metrics support (templates, alias),
  • Advanced FB_EoN, sending advanced metrics,
  • Advanced FB_Device, sending advanced metrics,
  • Advanced M2M node, sending advanced metrics,
  • Advanced CODESYS based SparkplugB Primary Node Implementation: Bring your own SCADA (BYOS)
  • Advanced File transfer,
  • Advanced Historical data support,
  • Advanced Store & forward,
  • Advanced Server High Availability (HA),
  • Advanced CODESYS based SparkplugB Server Node implementation,
  • Debugging / Optimization/ Refactoring of Advanced Product.
  • Release of Advanced Product v3.0.0.0