00:03
MQTT is a simple flexible and popular
ISO standard communication protocol that
00:09
can be used for almost any IoT
application imaginable. But there's
00:12
always room for improvement, especially
in demanding fields like industrial
00:16
automation.The Sparkplug specification
for MQTT adds more structure to the
00:21
standard MQTT architecture so that a
better supports industrial IoT
00:25
applications. The main enhancements are
to state management the topic namespace
00:30
and the payload format. In this video
I'll go over these differences and how
00:34
they apply to the use of MQTT in
industrial automation.
00:42
The Sparkplug specification adds these
requirements to provide the extra
00:47
structure that MQTT needs to be a
powerful tool in industrial conditions
00:51
while still being an open standard
governed by the Eclipse Tahu project.
00:55
This means that it is not an entirely
new messaging protocol, just a more
00:59
strict implementation that is built on
top of MQTT. So the structure and
01:04
functionality of MQTT applies to
Sparkplug as well. If you're not familiar
01:08
with mMQTT or the publish/subscribe
architecture check out our other videos.
01:12
In this video I'll be working with MQTT
and Sparkplug for communications between
01:18
my Windows computer here connected to
the Opto 22 company network and this
01:23
Edge Programmable Industrial Controller
the groov EPIC which has a cellular
01:27
modem attached to the back for outbound
only communications using an unknown IP
01:32
address provided by the cellular network
carrier, in this case Verizon. Now with
01:39
both of these devices online there are a
lot of different interfaces for Sparkplug
01:42
and I'm going to start with the
Ignition Edge platform by Inductive
01:46
Automation, which is running on this
laptop. So let's dive in and look at that
01:50
now I'll start by navigating to my local
computer
01:54
and going to port 80 88 which is where
Ignition Edge is running. I'll go ahead
01:58
and sign in with a user I've already
created. Now I can go ahead and keep
02:04
using Ignition for another hour because
this software is free to download and
02:09
use for up to two hours at a time. From
here I'll need to configure the MQTT
02:15
server or broker that I'll be using for
this video. I'll do that in the configure
02:19
tab under MQTT engine settings there's a
separate tab here for servers and I can
02:24
go ahead and create a new MQTT server.
This is going to be the secure opto
02:31
broker
and it's sitting at SSL because it uses
02:37
the Secure Sockets Layer and that's at
chariot groov.com Also, since it is
02:43
secure I should use port 8883
instead of port 1883 which would be the
02:48
insecure port now make sure I set the
server type to chariot and put in a
02:52
username and password for the encryption
02:56
Finally I'll need to upload the
certificate required for encryption
02:59
since again we're using SSL. With that done
I can create the server and we can see
03:08
that it's already connected. Now with
that we're set up I can go ahead and
03:12
launch designer in the Ignition Edge
desktop application. I already have Java
03:18
installed so I can go ahead and launch
it. Once it loads I just log in again and
03:28
then after I select a project right away
I have access to the tag browser. And,
03:35
here under all providers there is the
mqtt engine edge nodes where you can see
03:40
there are already many devices these are
devices connected to the chariot groov
03:44
server and transmitting their data over
MQTT and Sparkplug I only just
03:48
configured this server but already all
these devices are showing up but what I
03:52
don't see in this tag browser are the
groov epic tags coming from this device
03:56
here so we'll need to set up Sparkplug.
To do that I can use this onboard screen
04:01
and use the Sparkplug menu. So just hit
configuration and I can go ahead and
04:05
start filling in the device and broker
details. Here I'll add an mMQTT broker and
04:11
set the broker URL to be the same Secure
Sockets Layer server that I have over on
04:17
Ignition Edge. So I'll make sure to
preface it with SSL and put in chariot.groov.com
04:33
And then again since it is secure I'll
need to put in port 88-83 since
04:38
that's the secure port. Next is the
client ID and I want this to be unique
04:42
so I'll make it something like workshop
DC 0 1 3. Also, I need to put in the
04:55
authentication user and password and
again since this is SSL I'll need to
05:01
point to a certificate to make sure I
can get past the encryption. While I'm
05:05
here, note that I have this keep alive
timer set to 10 seconds. I won't change
05:09
it. I just want to point it out while I'm
here. Now with the broker setup I can go
05:16
ahead and put in the device details
I'll make the group ID opto 22 since I
05:21
wanted it to show up in that folder over on
Ignition
05:23
Edge's tag browser. I'll make the edge
node ID groov epoch workshop since this
05:34
is the groov EPIC associated with the
studio workshop.
05:42
I can leave the primary host ID blank
but I should give it a device ID
05:47
I'll make this EPIC PR1 since that's the
product code for the EPIC processor and
05:54
that's where this device data is
originating from so I'll put that in
05:59
double-check my settings and hit save
06:04
once the configuration saves it'll
prompt me to start the service and then
06:10
after just a few seconds it'll report
back that sparkplug is running so with
06:16
all this done I'll hit save and I just
need to go back into Ignition Edge and
06:20
refresh my tag list. And right there
under all providers the MQTT Engine Edge
06:26
Nodes Opto 22 group has a new device
groov EPIC workshop. All this data
06:33
propagated through from the EPIC and
filled in this folder structure so here
06:37
I can see that I have my EPIC PR1 device
with strategy information i/o data
06:43
numerical tables and variables and all
sorts of data here. There are many
06:50
different internal tags now available;
that panel light states, and panel
06:54
temperature among many other.. You can
even see the panel temperatures steadily
06:58
increase if I hang on to this
temperature sensor. And then as well as
07:02
read information from the EPIC we can
also use Ignition Edge to write data
07:06
since Sparkplug is bi-directional one
of the numeric variables you see here is
07:11
tied to the panel LED rings. A boolean to
control the state. if I check that box
07:16
and choose to enable writes. There we can
see that the panel LED has turned on and
07:23
back off again.
And we did this without knowing anything
07:28
about the cell modem, opening any ports,
or changing any firewall rules. Also note
07:34
that I got access to all of this right
away without having to type in the tag
07:38
name or path. The tags in the EPIC are
the single source of truth. They
07:42
propagate all the way through the system
without having to type a single
07:45
character, without needing to poll any of
the devices, and I can still see it all
07:50
without waiting for any tag to publish
new data. The current state of the data
07:54
from each device is always known this
statefulness is different than most poll/
07:59
response systems and is also different
from the retain flag which is natively
08:03
supported by MQTT. With a poll response
system you pull the device for data and
08:11
then have to pull again to see if it's
changed but you may get a copy of the
08:15
same data and you tt's publish/subscribe
system reduces Network load by only
08:20
having the client send data on change so
the current data must be the most
08:24
up-to-date since anything newer would
arrive and override it to deal with new
08:29
subscribers MQTT allows messages to
be retained by the broker and sent out
08:34
as soon as someone new subscribes but if
that source device has already been
08:38
disconnected
there is the downside the stale data can
08:42
get delivered so to make this more
robust spark plug also enforces the last
08:46
will and testament messages that get
published by the broker when a client
08:50
disconnects without warning this last
will and testament disconnection message
08:55
relies on a very small heartbeat check
between the broker and its clients
09:00
specifically that heartbeat is based on
the keepalive timer that I've set to 10
09:04
seconds on my groov EPIC so now if I
disconnect my cellular modem from the
09:09
groov EPIC then right now the broker is
counting down from 10 for as long as it
09:17
does not receive a heartbeat from the
epic after that time is passed there we
09:21
go I can see the tag go red so the data
must be old I can still see the state of
09:26
the data but I know that no new updates
are being received
09:35
Sparkplug is able to do all this while
still keeping the network load low since
09:39
each heartbeat is just a two by packet
and then since I've plugged it back in
09:43
again it'll come back online and there
we go I'm getting fresh data once more
09:48
this setup is crucial for industrial IOT
since acting on old data can be
09:52
potentially disastrous and with spark
plug were always informed about the
09:56
state of the connections so all of this
information has to come from somewhere
10:01
and in particular it comes from the
forced use of birth and well messages
10:05
descriptive topics and a more advanced
payload in most MQTT systems the payload
10:11
is simply unmanaged text but spark plug
does things differently instead of plain
10:16
text spark plug requires that each
message be formatted in JavaScript
10:20
object notation or a JSON with specific
properties set while this may sound
10:25
limiting it's much better in industrial
applications to see what these JSON
10:29
payloads look like let's check out
another spark plug compatible client and
10:38
in MQTT FX I already have the broker set
up since it's the same as in the groove
10:43
epoch and an ignition edge I'll go ahead
and connect and subscribe to a topic to
10:49
find out what topics are being published
to this broker I'll use the MQTT FX
10:53
feature to scan topics which build up a
list of topics from the broker in this
10:57
window here one of these holds the groov
epic workshop data coming in from my
11:02
epic pr1 you can see it right there
I can subscribe to that directly or I
11:08
can type in what I know about the topic
namespace the first topic is the message
11:13
namespace type which can be a single
level wild card plus then we have the
11:18
group ID which for me is Opto 22 then
the specific message type which again
11:23
I'll make a wild card so that I get all
message types next we put the edge node
11:28
ID which is groov EPIC workshop in this
case finally I'll follow that with a
11:34
multi-level wild card to get all
subtopics of the groov epic workshop
11:39
with all that entered I can hit
subscribe and right away I can start
11:43
seeing my day to come in
I'll mute the subscription so that we
11:48
can take a look at just one message
right now the payload is not readable at
11:52
all but it's not because they're
corrupted rather each Sparkplug message
11:56
is actually encoded in MQTT FX has a
decoder with support for Sparkplug
12:01
payloads already built in so I'll go
ahead and enable the sparkplug Dakota
12:07
now we can see all of the characters as
they should be the particular encoding
12:14
Sparkplug uses is Google protocol
buffers or protobufs. These efficiently
12:18
encode structured data to be even more
compact these help keep the network
12:23
load low without losing any data so the
Sparkplug maintains the MQTT objective
12:27
of having a small network footprint
despite these additional features now
12:32
with this payload decoded I can see the
JSON information but I can't see this
12:36
structure very clearly so I'll copy this
information as plain text an open pretty
12:43
print which is simple and common plugin
for reformatting text data that is in
12:48
the JSON format when I paste this in I
can clearly see all the different
12:53
segments pretty print just adds
whitespace to separate out the parts of
12:58
the message in a typical MQTT message
there are no requirements on either
13:03
encoding or on format you can just send
the message true if you want but with
13:08
JSON that true must be part of a key
value pair just like this temperature of
13:12
value right here it also must reside in
curly braces which this entire message
13:17
does but sparkplug specification in
particular doesn't just send temperature
13:23
as a value in JSON format it also
includes a lot of other information here
13:27
we've got the timestamp we've got the
quality of the point there's also the
13:34
data type for the metric and several
other metrics included as well
13:42
while we get all this extra information
with sparkplug it's still really
13:46
efficient due to the google protobuf
encoding that we just saw the other
13:50
thing is that this information gets
resent if any damage is done to the
13:54
folder structure for example if I bring
up a my tag browser and I bring open
14:00
MQTT FX if I go ahead and clear this
topic window and then attempt to make
14:10
some kind of change to my tag browser
here for example I could attempt to
14:14
delete this groov epic workshop we can
see right away a whole bunch of birth
14:21
messages came through as these devices
reestablish themselves and if i refresh
14:26
the tag browser under the edge nodes Opto
22 group I can see that groov EPIC
14:31
workshop has come back I wasn't able to
delete it because the workshop is the
14:35
single source of truth sparkplug
takes the benefits of MQTT and uses this
14:41
extra information to create a more
connected more structured system that is
14:45
extremely powerful in industrial
applications to find out more about
14:49
spark plug ignition edge or the groov
EPIC check out opto22.com for more
14:54
details about spark plug
check out the Cirrus-Link website
14:57
Thanks for watching