Getting Started With MQTT in Groov Products
Getting Started With MQTT in Groov Products
GROOV PRODUCTS
Wired+Wireless controllers and brains are licensed under one or more of the following patents: U.S. Patent No(s). 5282222,
RE37802, 6963617; Canadian Patent No. 2064975; European Patent No. 1142245; French Patent No. 1142245; British Patent
No. 1142245; Japanese Patent No. 2002535925A; German Patent No. 60011224.
Opto 22 FactoryFloor, groov, groov EPIC, groov RIO, mobile made simple, The Edge of Automation, Optomux, and Pamux
are registered trademarks of Opto 22. Generation 4, groov Server, ioControl, ioDisplay, ioManager, ioProject, ioUtilities,
mistic, Nvio, Nvio.net Web Portal, OptoConnect, OptoControl, OptoDataLink, OptoDisplay, OptoEMU, OptoEMU Sensor,
OptoEMU Server, OptoOPCServer, OptoScript, OptoServer, OptoTerminal, OptoUtilities, PAC Control, PAC Display, PAC
Manager, PAC Project, PAC Project Basic, PAC Project Professional, SNAP Ethernet I/O, SNAP I/O, SNAP OEM I/O, SNAP PAC
System, SNAP Simple I/O, SNAP Ultimate I/O, and Wired+Wireless are trademarks of Opto 22.
ActiveX, JScript, Microsoft, MS-DOS, VBScript, Visual Basic, Visual C++, Windows, and Windows Vista are either registered
trademarks or trademarks of Microsoft Corporation in the United States and other countries. Linux is a registered
trademark of Linus Torvalds. ARCNET is a registered trademark of Datapoint Corporation. Modbus is a registered trademark
of Schneider Electric, licensed to the Modbus Organization, Inc. Wiegand is a registered trademark of Sensor Engineering
Corporation. Allen-Bradley, CompactLogix, ControlLogix, MicroLogix, SLC, and RSLogix are either registered trademarks or
trademarks of Rockwell Automation. CIP and EtherNet/IP are trademarks of ODVA. Raspberry Pi is a trademark of the
Raspberry Pi Foundation. The registered trademark Ignition by Inductive Automation® is owned by Inductive Automation
and is registered in the United States and may be pending or registered in other countries. CODESYS® is a registered
trademark of 3S-Smart Software Solutions GmbH.
groov includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org)
All other brand or product names are trademarks or registered trademarks of their respective companies or organizations.
Opto 22
Your Edge of Automation.
INTRODUCTION
Opto 22’s groov EPIC® edge programmable industrial controller and groov RIO® edge I/O give you many ways
to use MQTT data communications—via groov Manage, Node-RED, or Ignition Edge from Inductive
Automation®. The goal of this guide is to help you understand which approach is best for you and to help you
get started fast.
If you already know which approach you’ll take, you can jump to the how-to section that best describes the
application you have in mind. If you’re still thinking about your approach, continue reading for a perspective
on the general trade-offs between the available options.
If you are a groov product user but you’re on the fence about whether MQTT is for you, we’ve also included a
chapter to help you build your own proof-of-concept system.
In this Guide
This guide includes:
Chapter 1: Getting Started with MQTT—This chapter, which includes how-to steps for enabling public tag
access, configuring simple data collection, and configuring high-reliability SCADA/IIoT using MQTT
Chapter 2: Fault Tolerance and Security—Configuring system security and additional options for fault
tolerance in communications
Chapter 3: Build a Proof of Concept—Steps to build a simple proof of concept
Appendix A: MQTT Brokers—Help for choosing an MQTT broker if you don’t already have one
For Help
Related Documents
groov product user’s guides are available under Help in groov Manage, and the most recent versions are
available on our website. Follow the links below or go to www.opto22.com and search on the form number.
Guide name Contents Form #
Installing and using a groov EPIC system; using
groov EPIC User’s Guide 2267
Node-RED, MQTT, and Ignition or Ignition Edge
Installing and using a groov RIO module; using
groov RIO User’s Guide 2324
Node-RED and MQTT
Using groov products in your network and over the
Guide to Networking groov Products 2161
internet
OptoForums
OptoForums focused on groov products and their tools are available 24 hours a day, 7 days a week, so you can
get advice from experienced groov product users:
• groov EPIC Forum
• groov RIO Forum
• Node-RED Forum
• Ignition Edge Forum
Product Support
If you can’t find the help you need in this guide or in the product user’s guides, contact Opto 22 Product
Support. Product Support is free.
Phone: 800-TEK-OPTO (800-835-6786 toll-free NOTE: Email messages and phone calls
in the U.S. and Canada) to Opto 22 Product Support are
951-695-3080 grouped together and answered in the
Monday through Friday, order received.
7 a.m. to 5 p.m. Pacific Time
Fax: 951-695-3017
Email: [email protected]
GENERAL PREREQUISITES
This guidebook is best for people who have some background knowledge of MQTT and want to try it out on
their Opto 22 hardware. In addition, the following are required to make use of the examples in this guide:
• Administrator access to a groov RIO or groov EPIC device (If you don’t have access to one, reach out to
Opto 22 for a demo. For steps to log in or complete initial setup, see the groov EPIC User’s Guide or the
groov RIO User’s Guide.)
• The basic information to connect to an MQTT broker, such as:
– Broker URL and port number
– Username
– Password
If you don’t have access to a broker or aren’t sure which one is right for you, take a look at Appendix A: MQTT
Brokers or at Chapter 3: Build a Proof of Concept, a walkthrough that will help you set up a complete MQTT
system quickly.
If your application requires something more resilient, configuring groov Manage for Sparkplug payloads gives
you the guarantee of state awareness, important if you rely on high-quality data for operations, auditing, or
historization. (With some extra work, Node-RED can work with Sparkplug data also.) Sparkplug also unlocks
additional fault tolerance features and makes it easier to work with larger data sets.
Ignition Edge can handle even larger data sets and provides more integration and fault tolerance options, but
it does impose some additional licensing costs.
groov Manage w/ string groov Manage w/
Node-RED Ignition Edge
payloads Sparkplug B payloads
groov EPIC groov EPIC groov EPIC
Platform groov EPIC
groov RIO groov RIO groov RIO
Tag count < 50 < 50 <1000 1000+
Strings, JSON, Strings, JSON,
Payload Strings Sparkplug B
Sparkplug B Sparkplug B
Local I/O, PAC Control1, PAC Control, databases,
Data source Local I/O, PAC Control™1 databases, web services, Local I/O, PAC Control1 legacy PLCs, devices, or
OPC, and more OPC2
Subscribe to other Yes, with MQTT Engine
No Yes No
publishers' topics module
User authentication User authentication User authentication User authentication
Security SSL/TLS encryption SSL/TLS encryption SSL/TLS encryption SSL/TLS encryption
Certificate management Certificate management Certificate management Certificate management
Non-volatile storage
Volatile storage
Historization None None (optional)
Max 65K records
100K records or 1 week
Multiple brokers
Multiple brokers Multiple failover groups
Failover Multiple brokers None
Primary host designation Multiple clients
Primary host designation
$8003
Additional Cost $0 $0 $0
+$2004 w/ MQTT Engine
1 groov EPIC only
2 Other data sources are possible through the use of additional Ignition modules.
3 GROOV-LIC-EDGE current list pricing as of 6/10/20.
4 Special pricing when purchased with Ignition Edge license; all Ignition features are free to try with unrestricted functionality.
A general consideration when working with Sparkplug B, however, is the need for compatible clients. Since
MQTT is data-agnostic, any broker can handle Sparkplug B traffic alongside string payloads without an issue.
However, any device or application clients that want to use your Sparkplug data will need to support
Sparkplug as well.
Exposing I/O and tag data in PAC Control (groov EPIC only)
Use PAC Control to expose I/O or variable tags from a control strategy running on your groov EPIC processor to
Ignition Edge, the groov Manage MQTT service (when the Device Type is set to Controller), or by the PAC
Control nodes (node-red-contrib-pac) in Node-RED.
To enable access, open the edit dialog box of each I/O point or variable to be published, and check Make
Public (Readable). Then save and run your control strategy.
Voila! Your broker will pick up your tags as new MQTT topics, and from there, your back-end applications can
become subscribers using this path:
<Base Topic>/<Group Topic>/<Subgroup Topic>/<Device Topic>/#
In our example, the path would look like this:
opto22/warehouse/shipping/epic/#
For more information on using groov Manage for MQTT, see Chapter 8 in the groov EPIC User’s Guide or
Chapter 9 in the groov RIO User’s Guide.
Option 2: Node-RED
While groov Manage is great for straightforward tag publishing, for more flexibility and granularity, consider
Node-RED. It has several advantages for basic publishing.
First, Node-RED makes it easy to combine tags with data from other sources, like OPC or web services.
Node-RED can also subscribe to topics published by other MQTT clients, where groov Manage can only detect
updates communicated on its own topics. And in addition to plain strings, Node-RED lets you publish
JSON-formatted data, commonly used with cloud IoT platforms and other services. Finally, Node-RED lets you
configure quality of service (QoS) levels and last will and testament (LWT) messages for each topic, if you want
to take advantage of these features.
Prerequisite: You should be familiar with the basics of the Node-RED environment and how to build,
configure, and deploy flows. If not, check out our online training first or review the beginning of Chapter 14 of
the groov EPIC User’s Guide or Chapter 10 of the groov RIO User’s Guide.
Here is how you would set up basic publishing in Node-RED:
1. Log into your groov EPIC or groov RIO, navigate to the Node-RED page, and open the Node-RED editor.
2. Install the groov I/O nodes (node-red-contrib-groov-io) or your data source of choice, add a
groov I/O input node to the workspace, and configure it to grab the I/O data you want to publish. (For
help with configuration, see the groov I/O Nodes section on developer.opto22.com.)
3. Add an MQTT Out node to the workspace and connect it to your data node.
4. Double-click the MQTT Out node, click the pencil next to Add new mqtt-broker, and enter your broker
URL, port, and security details (if needed; see “Security in Node-RED” on page 20). Click Add when
finished.
5. Back in the MQTT node configuration panel, enter your desired topic path and click Done.
groov Manage will generate a topic path based on the ID fields in combination with others required by
Sparkplug B, as follows:
spBv1.0/<Group ID>/+/<Edge Node ID>/<Device ID>/#
In this example, MQTT subscribers would use the following topic path:
spBv1.0/opto22/+/shipping/epic/#
More details are available in Chapter 8 of the groov EPIC User’s Guide and Chapter 9 of the groov RIO User’s
Guide.
7. Open Ignition Designer, configure your topic path, and publish your tags:
a. In the upper right-hand corner of Ignition Edge, click Launch Designer and open the designer.jnlp
file when the download is complete.
b. Log in with your credentials (default: admin/password).
c. In the Tag Browser panel, navigate to All Providers > edge > Edge Nodes.
d. Right-click the Edge Nodes folder and select New Folder. Then enter a name to represent the Group
ID, and click OK.
e. Right-click the new folder and click New Folder again. Then enter a name to represent the Edge
Node ID, and click OK.
f. Right-click the latest folder and click New Folder again. Then enter a name to represent the Device
ID, and click OK.
Here’s an example of the folder structure:
8. Open the OPC Browser (View > Panels > OPC Browser), open the Devices folder, and drag the desired
tags from your EPIC device folder into the Device ID folder you have just created.
9. Publish tags by navigating to MQTT Transmission > Transmission Control in the Tag Browser and clicking
the checkbox next to the Refresh tag.
A dialog box may appear with the prompt “Change to Read/Write Mode?” If so, click Enable Read/Write
Mode.
The checkbox is checked and then immediately cleared when refresh has been completed.
10. Repeat step 9 any time you modify the folder structure or add a new tag.
11. Once you have finished adding tags, return to the Ignition page in groov Manage, disable Ignition
Designer, and click Save.
This setup produces an MQTT/Sparkplug B topic path according to the folder structure you have created:
spBv1.0/<Group ID>/+/<Edge Node ID>/<Device ID>/#
In this example, MQTT subscribers would use the following topic path:
spBv1.0/opto22/+/shipping/epic/#
Out of the box, you’ll have unrestricted access to all of the features of Ignition Edge on a two-hour timer. At the
end of two hours, just reset the timer. For uninterrupted use, you can purchase an Ignition Edge license
(GROOV-LIC-EDGE).
See Chapter 8 of the groov EPIC User’s Guide for more information on using Sparkplug B with Ignition Edge.
Option 3: Node-RED
If you need your groov device to only subscribe to Sparkplug B data, it’s possible to read in and decode
Sparkplug messages directly in a data flow. Besides being free to use, Node-RED has the advantage of easily
mashing up data from other sources and even creating dashboards or a light UI as well.
Using this method, Node-RED does not become a Sparkplug-compliant device; it is just a data consumer
subscribed to an MQTT broker. But sometimes that’s all you need.
Here’s the procedure:
1. Log into your groov EPIC or groov RIO, navigate to the Node-RED page, and open the Node-RED editor.
2. Place an MQTT In node, and configure the broker connection, security details (if needed; see “Security in
Node-RED” on page 20), and topic path. The path should use this format:
spBv1.0/<Group ID>/+/<Edge Node ID>/<Device ID>/#
3. Download the sparkplug_b.proto file from the Eclipse Tahu Project on GitHub, and place it in the
unsecured file section of your groov device.
4. Install the protocol buffer nodes (node-red-contrib-protobuf), add the Decode node to the
workspace, and connect it to the MQTT In node.
5. Configure the Decode node by setting Proto File to the .proto file path and setting Type to Payload.
6. Connect the output of the Decode node to wherever you want to send the subscribed data, and click
Deploy to start receiving data.
Publishing Sparkplug payloads with Node-RED is also possible but is much more involved. Check out this
guide published by Cirrus Link if you are seriously considering that option:
https://docs.chariot.io/display/CLD79/B%3A+Example+Node-RED+Client
Failover connections
A basic fault tolerance measure is to set up multiple MQTT brokers and configure your groov device with
connections to each.
NOTE: By default, the MQTT client connects to the first available broker and switches round-robin if it loses
connection. However, this behavior changes if you configure the Primary Host ID property (see page 16).
groov Manage
To set up failover connections, navigate to MQTT > Configuration > Add Broker, and create as many
connections as you want.
The example above shows a connection to Opto 22’s on-site Mosquitto broker as well as a second connection
to a Chariot broker hosted on AWS.
Ignition Edge
Add new server connections from the (MQTT Transmission) Settings > Servers tab. Any broker connections
that share the same Server Set property become part of an automatic failover group.
Ignition Edge allows you to create additional failover groups under the (MQTT Transmission) Settings > Sets
tab.
For advanced scenarios where you might group MQTT clients around specific brokers, you can create
additional MQTT clients, each with its own server set and history store, by defining custom transmitter settings
under (MQTT Transmission) Settings > Transmitters > Custom > Create new Settings.
Node-RED
In Node-RED, broker connections are configured individually for each MQTT node, but only one connection
can be configured per node. To add some redundancy, you can create duplicate nodes with connections to
different brokers.
Primary host ID
If you’ve configured multiple broker connections for failover (see page 15) in groov Manage or Ignition Edge,
you can also set a Primary Host ID. This setting causes the MQTT client to give preference to broker
connections that publish an ONLINE status for the specific client ID you enter.
Be aware that if none of the available broker connections is publishing an ONLINE status for that ID, the MQTT
client will continue to rotate through available brokers without staying connected.
In these examples, an Ignition SCADA server running on a local laptop (not Ignition Edge, but full Ignition), has
a client ID of laptop-ignition-scada.
groov Manage
To designate a primary host application, go to the main MQTT configuration screen and set the Primary Host
ID to the MQTT client ID of your target application.
Ignition Edge
A broker failover group, called a Server Set in Ignition Edge, can have a designated Primary Host ID.
Set it up by editing the desired server set under the (MQTT Transmission) Settings > Sets tab.
Store-and-forward history
With a primary host ID set, groov devices can also store MQTT records temporarily when they lose connection
to the broker, and then forward these records to the primary application when the connection is restored.
To get the full advantage of store-and-forward history, you’ll need to be communicating with an in-network
MQTT subscriber that is watching for these historical records. Currently, there are two applications that can do
this: the Ignition MQTT Engine module and the Canary Labs MQTT Sparkplug B Data Collector.
You can set up store-and-forward history in groov Manage or, for groov EPIC only, in Ignition Edge.
groov Manage
To enable historization, navigate to MQTT > Configuration > Device and enter a number into the Historic
Queue field.
We recommend a queue size of 3,600 to strike a balance between storage and performance, but you could go
much higher, depending on the rate of data production.
Note that records are stored in RAM and will be lost in the event of a power failure.
Additional performance details on the Historic Queue can be found in Chapter 8 of the groov EPIC User’s Guide
and Chapter 9 of the groov RIO User’s Guide.
groov EPIC’s Ignition Edge client offers larger capacity and a non-volatile storage option. If you select the
disk-backed option, you get the additional benefit of groov EPIC’s power-fail-safe file system and industrial SSD
(solid state drive).
1. To enable historization, navigate to Configure > (MQTT Transmission) History and edit the Default
In-Memory Store. Select Enable this History Store and change Type to Disk-Backed (if desired).
See the groov EPIC User’s Guide and groov RIO User’s Guide for more information on security features, including
certificate creation and management.
2. To upload a security certificate to your groov device, navigate to the Security > Client SSL page, click
Add/Update, and locate the appropriate file.
Once this is done, the certificate appears as an option in the MQTT Broker > Select Certificate dialog box.
2. In the TLS section below, click Choose File next to Certificate File Upload, and locate the desired
certificate file.
Security in Node-RED
1. When editing the MQTT broker details, be sure to specify TLS port 8883. Then check the box to Enable
secure (SSL/TLS) connection and click the pencil next to Add new tls-config.
3. Click Update.
4. To enter user credentials, switch to the Security tab. Enter your username and password.
Here’s our go-to formula for setting up an MQTT network that provides a full set of integration options and can
be fully tested at no additional cost:
1. Download and install Ignition to a local computer (Linux, Mac, Windows). It takes only a few minutes, and
Ignition is fully functional in two-hour increments.
2. Within Ignition, install the Cirrus Link MQTT Distributor module (Modules > Install or Upgrade a Module).
You now have a scalable MQTT broker.
3. Next, install the Cirrus Link MQTT Engine module. Non-MQTT applications can now access your MQTT
data through Ignition's OPC UA Server.
4. Finally, use one of many integration options to turn your groov device into an MQTT gateway for your
legacy systems:
– On your groov EPIC, enable the Cirrus Link MQTT Transmission module in Ignition Edge (see “Option
2: Ignition Edge (groov EPIC only)” on page 10) and install OPC drivers for Allen-Bradley, Siemens, and
Modbus/TCP devices; or leverage integration kits for PAC Control to access a variety of serial
protocols.
– On your groov RIO, connect wired I/O signals and serial devices, then publish them through
groov Manage or Node-RED.
Ready to go, and you haven’t spent a dime! Experiment as much as you want, and when you're ready for
production, all you have to do is license the system (for Ignition Edge on groov EPIC, just purchase
GROOV-LIC-EDGE; for other Ignition components, contact Inductive Automation). Or, once you are satisfied
that MQTT can do what you need, you can opt for no-cost components like the Eclipse Mosquitto broker and
groov Manage client, instead.