MQTT Transmission Module

Implementing MQTT in Ignition: Video 6

6 min video  /  6 minute read
 

< Previous Video    |    Next Video >


Travis Cox installs and configures the MQTT Transmission Module for Ignition. This module allows you to publish any configured tag in Ignition such as OPC, memory, and more to an MQTT server so that applications can subscribe to that data.


Video Transcript: 

Travis: In this session, we're going to install and configure the MQTT Transmission Module for Ignition. The Transmission Module allows us to publish any configured tag in Ignition such as OPC tags, memory tags, and more to an MQTT server so the applications can subscribe to that data.

The first thing we have to do is install the module, and for that we go to the configuration area, go to ‘Modules’, come down to the bottom, ‘Install or Upgrade a Module’, and choose the MQTT Transmission Module that we've downloaded and installed.

Once we have it installed, there are two things we have to do to get it configured. The first is to get connected to an MQTT server and the second is to specify which tags in Ignition we want to actually publish. Both of those are configured in the Transmission ‘Settings’ area.

Let's look at the MQTT server’s connections first under the ‘Servers’ tab. Here, we can specify one or more connections to different MQTT servers. Each connection is gonna have a URL or the IP address hostname to that server and the port that it's using, whether it's TLS or not. And a username/password to actually authenticate against the MQTT server along with a server set, and the service set is used to determine which set of tags go to which MQTT servers, and we'll look at that in more detail in the next session. So here, you will note that I already have an MQTT server connection established just by installing the module and we add one in there by default to the local machine and in my case, that happened to have an MQTT Distributor Module installed on the same Ignition instance, and that's why we are already connected to that MQTT server.

But of course, if I need to, I can go edit that connection or I can add new connections here. Now, once we have those configured, we then need to specify which tags in Ignition we want to publish to those MQTT servers, and we do that with transmitters. There's also an example transmitter configured in here and some example tags are already configured for us inside of our default tag provider in a folder called MQTT Tags.

So let's go on our designer and take a look at these tags because they're already being sent up to the MQTT server. We'll go ahead and log in, open up my project. In my tag database under my default provider, I should see a folder called ‘MQTT Tags’. Inside of that, we have a folder called ‘PLC’. Inside of that, we have two example tags that are already being published, and this is integer ‘Example Tag’ and this ‘MQTT Quick Start’, which is a string. So within this, since it's already configured, we can add new tags. So if I want to go in here, add a new memory tag, let's say, and we call this ‘Test,’ make an integer with a value of 1, now we can have a new tag that we can publish.

Now, any time we make a change to the hierarchy to the structure of our tags, we want the Transmission Module to then publish those new tags or any configuration changes we've done to those tags. We then need to go down to the ‘All Providers’ under the MQTT Transmission control and we need to update or refresh that list. So I'm gonna put my designer read/write, click on ‘Refresh’. At this point now it's gonna re-read all of the hierarchy and now all three of those tags are being published. We can always go back to the Gateway Interface to verify on the servers that we have one of one connected. So I have one transmitter and it is connected right now and publishing data. If I had zero of one, there will be some area we have to look into that issue.

So at this point, I've got that transmitter working. Now, this transmitter is using tags that are inside of a particular folder. In some cases, you already have tags that are configured and they're not in that folder already and you don't want to move them into that folder. So we may have tags somewhere else that we want to use and configure, whether that's in the default provider or another provider, we can then create multiple transmitters to transmit those tags. In my case, I've got another provider called Tags, and I have a lot of tags inside of that both simulation and process values that I want to get published. I want all of them to get published here. And in fact, not only are there individual tags, but there are also UDTs in these motors here that I want to get published up. The Sparkplug specification that we use for MQTT allows us to define those data types that we can send up to the MQTT server that applications can understand.

So with this, I need to go create another transmitter to go and publish that new tag database. So I'm gonna go to my transmitters, create a new setting, I'm going to call it Tags on the tag provider, in my case is named Tags and I'm going to leave the tag path empty, and that's going to mean that we're gonna be at the root tree of that tag provider. If I put a folder of course, it'll be some subset, so I want everything that's in there. And the set here is our default set, which is what the MQTT server that I'm connected to is associated with so I'm gonna publish to that MQTT server. And the last setting I wanna look at is convert UDTs. I don't wanna convert UDTs to normal tags, I'd rather publish the actual UDT definitions themselves as well so I'm going to uncheck that and then down at the bottom, we have to give for Sparkplug the three levels of hierarchy from the group ID, the edge node ID, and the device ID to uniquely identify one edge gateway and device from another. So I'm going to call the group Ignition, the edge is Edge, and the device will be Device in my case. And that's it. Now we can create those settings and all the tags in that tag provider should now be published. Now we can verify that, of course, by going back to the servers and we'll see that we have now two of two transmitters connected and working on this MQTT server.

So in the next session, we're gonna look at the servers and sets and transmitters in some more detail. But this is how we can easily connect with MQTT server and get data, get tags Ignition configured, and publishing. The last thing I want to point out is that with the example transmitter that's going to the default provider, some people may already have their tags in the default provider where they can just go simply edit this one and instead of using that folder, they can just leave that blank and do the entire tag tree within a default provider. Either way, we're gonna specify those tags we want to get published.

Posted on December 8, 2019