Skip to end of metadata
Go to start of metadata

Prerequisites


Overview

This tutorial shows how to configure MQTT Transmission module to generate custom records and send them as MQTT messages via MQTT Distributor to be stored in MySQL database. The topology of this example shows MQTT Distributor, MQTT Engine, Record Store, and MQTT Transmission all running in the same Ignition instance.  This is done for simplicity of the tutorial, but this isn't required or even intended to be a real use case.  In a more realistic scenario MQTT Transmission and MQTT Engine would be located on separate machines.


Loading Cirrus Link Modules

The first step is to load four Cirrus Link modules specified in the 'Prerequisites' section of this document. To load the modules, launch the Ignition Gateway and open HTTP connection to it.  If Ignition Gateway is running on your development machine, use http://localhost:8088 to connect.  You should see the 'Welcome to the Ignition Gateway' screen shown below:

From here, click the "Config" and you will see the 'Configuration' page. Go to 'SYSTEM' on the left hand side of the screen and select 'Modules'. 

Scroll down and click the 'Install or Upgrade a Module' link to install four modules listed above. Here is what you should see at the end:

These modules can be configured by clicking 'Settings' on the left hand side below each module. Note that the MQTT Distributor and MQTT Engine modules should not be touched; they will use default configuration. The MQTT Recorder module should be configured to point to the datasource used for storage, but this needs be done after configuring database connections. Finally, the MQTT Transmission module needs to be configured to define custom records to be published. This will be described in subsequent sections of this document.


Configure Database Connections

To configure a database connection in Ignition follow the direction here https://docs.inductiveautomation.com/display/DOC80/Connecting+to+MySQL.


Configure the 'Record Store' Module

As was mentioned above, the 'Record Store' module needs to be configured to point to the database connection just created. To do this go to the 'Record Store' module configuration page and set the 'Datasource' field to connection configured in the previous step, as shown below:

Configure Ignition Tag Provider

The next step is to configure the Tag Provider in Ignition in a way that MQTT Transmission understands. The Tag Provider needs to be set up in Ignition via the Ignition Designer.  To launch it, click 'Get Designer' near the upper right corner of Ignition page. 

Use the Designer Launcher to launch a Designer connection to the Ignition Gateway and create a new project.

For this Tutorial the Example Transmitter will be used in MQTT Transmission which is monitoring the Tags in the "MQTT Tags" folder in the default provider, shown below.

Pressing the 'Refresh' checkbox causes the Transmitter to publish NBIRTH and DBIRTH messages.

Note that the 'Engine Nodes' folder under 'MQTT Engine' is no longer empty; the following directory tree was created there:

MQTT Engine/Edge Nodes/My MQTT Group/Edge Node 4b6054/PLC1

Setting Records in MQTT Transmission

At this point, everything is ready to setup Record publishing.  Go to the MQTT Transmission module configuration page and select the 'Records' tab as shown below:

Click the 'Create new Records...' link and configure new custom record. Use the following settings:

  • Tag Provider: default
  • Tag Folder Path: Event Tags
  • Record Type: Event
  • Group ID: My MQTT Group
  • Edge Node ID: Edge Node 4b6054
    • Note: This should match the ID generated by MQTT Transmission
  • Device ID: PLC1

When new record is submitted, it appears in the MQTT Transmission 'Records' table as shown below: 

Verify in the Designer Tag Browser that the 'Event Tags' folder now exists with a 'Publish' Tag under the 'default' tag provider as shown below. 

Now, Create a few tags in this 'Event Tags' folder as shown below:

Publishing Custom Records:

We are now ready to publish tags we just created in the 'Customs Record' directory under 'default' tag provider. To do this click the 'Publish' check box, and it should automatically become unchecked in a second. 

The follow process should have taken place when the Record was published:

  • MQTT Transmission constructed a Record containing Fields representing the Tags in the "Event Tags" folder along with their current values.
  • MQTT Transmission published the Record
  • MQTT Engine received the Record and delivered it to the MQTT Recorder module
  • MQTT Recorder stored the Record in the database

Verify the Record now exists in the database by using the Database Query Browser tool available in Ignition Designer.  The database should contain an "rs_event" table with one row as shown below:


Additional Resources

  • No labels