OptoBlog

MQTT: Basic publishing with groov EPIC

Posted by Josh Eastburn on Jan 8, 2020 8:35:33 AM

Wondering how to implement MQTT with groov EPIC? Follow along with this series, starting with basic string publishing.

Ever since ‘00, when the next year rolls around I think, “Welcome to the future!” Every year it feels much truer, and how could 2020 be any less? (UPDATE: 🤦) I’m excited about what we have planned for you this year. Among other things, we’re upping our commitment to MQTT in a big way. Stay tuned for announcements on that in the coming months.

For the moment, though, I want to address the current feature set groov EPIC offers for MQTT, the lightweight pub-sub communication protocol for IoT. With so many ways to do it—via groov Manage, Node-RED, or Ignition Edge—you may be wondering which, if any, is right for your application. In this series, I’m going to look at different scenarios where you might want to use MQTT, then show you how to get started.

Basic publishing

The first scenario we’ll consider is basic publishing for data collection and operations. Let’s say you have a small sensor network or an equipment group with a small amount of I/O (less than 50 tags or so). How do you quickly take that data and share it with an application using MQTT on groov EPIC? As usual, we give you a couple of options.

Option 1: PAC Control and groov Manage with string payloads

The option for plain string payloads was added in firmware release 1.4.2 and is, by far, the simplest way to get started. You can do it in just a few steps:

  1. In groov Manage, navigate to MQTT -> Configuration, set MQTT Payload to MQTT with string payloads, and configure the topic namespace. 
  2. Select “Add MQTT Broker,” and point groov Manage to an MQTT server (broker).
  3. Select “Add Device” to add the groov EPIC controller to the MQTT network.
  4. Save your configuration.
  5. Then in PAC Control, create the tags (I/O or variables) you want to publish, make them public, and run your strategy.

groov Manage screen


Voila! Your broker will pick up the tags as new MQTT topics, and from there, your application can become a subscriber using this path:
<Base Topic>/<Group Topic>/<Subgroup Topic>/<Device Topic>/#

For more information on this option, see Chapter 8 in the groov EPIC User’s Guide.

Option 2: Node-RED

While groov Manage is great for straightforward PAC Control publishing, for more flexibility and granularity, consider Node-RED, also included with groov EPIC. It has several advantages for basic publishing. First, it’s easy to combine PAC Control tags with data from other sources, like OPC or web services. Node-RED can also subscribe to topics published by other MQTT clients. And in addition to plain strings, Node-RED lets you publish JSON-formatted data, which is common for cloud IoT platforms.

For some additional fault-tolerance, Node-RED also lets you configure the quality of service (QoS) and birth/death/will messages for MQTT topics and connections. Take a look at Terry Orchard’s video on Node-RED and MQTT for more details on the steps involved.

Trade-offs and considerations 

More important than which option you choose is understanding why it’s the right one for you.

Both of these options let you get started quickly with publishing a small amount of data and require precisely $0 in up-front costs. With either one, you can take advantage of all the network and data protections that MQTT and groov EPIC provide, like authentication, encryption, and certification.

There are a few key limitations, though. For industrial applications, plain vanilla MQTT involves some engineering effort that limits scalability and interoperability. You’ll need to manage the topic namespace for each device or application client and give instructions on how to interpret the data you are publishing, which can be difficult if the network is large and heterogeneous. 

These methods also lack the built-in fault-tolerance of Sparkplug and Ignition Edge, which we’ll look at in the future. While MQTT does monitor client connection status, manually configuring status messages for each client also adds work to the initial configuration. That’s another reason we recommend keeping a low tag count.

Here’s a quick summary of how these two options stack up:

 

groov Manage w/ strings

Node-RED

Tag count

Low (< 50)

Low (< 50)

Payload

Plain strings

Plain strings or JSON

Data source

PAC Control tags and local I/O

PAC Control tags and local I/O, databases, web services, OPC, and more

Subscribe to other publishers' topics

No

Yes

Fault-tolerance

Low

Low

Cost

None

None

In the next installment, I’ll apply these same design criteria to a slightly more complex system. Over the next few months, it’s my goal to help you understand how to accomplish whatever you need to do with MQTT using the many options groov EPIC gives you.

Until then, you can also check out this case study featuring netDNA, which provides a field-tested example of using Node-RED to build an MQTT peer-to-peer network. Enjoy!

All posts in this series

Part 1 - MQTT: Basic publishing with groov EPIC
Part 2 - MQTT: Faster, better with Sparkplug B
Part 3 - MQTT: Mission-critical fault tolerance
Part 4 - MQTT: Bringing it all together

 

Topics: Node-RED, MQTT, EPIC, groov EPIC, groov Manage, MQTT implementation

Written by Josh Eastburn

After 12 years as an automation engineer working in the semiconductor, petrochemical, food and beverage, and life sciences industries, Josh Eastburn works with the engineers at Opto 22 to understand the needs of tomorrow's customers.
Find me on:

    Subscribe to Email Updates

    Recent Posts

    Posts by Topic

    see all