Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Knowledge of Ignition and Module installation process: Cirrus Link Module Installation
  • Install the following MQTT Modules
    • MQTT Distributor
      • v4.0.X if using Ignition 8.0.x
    • MQTT EngineTransmission
      • v4.0.X if using Ignition 8.0.x


Overview:

MQTT Engine Transmission provides a mechanism for publishing MQTT Messages from an Ignition script.  This can be useful for general messaging outside of Sparkplug.  For example, one may want to interface to another system that uses MQTT.  This method allows arbitrary MQTT messages to be published based on events that exist in Ignition.

...

Start by opening an Ignition Designer window and double clicking 'Scripting-> Gateway Event Scripts' from the Project Browser as shown below:

Image RemovedImage Added

Now select 'Tag Change' click the 'new Tag+' icon at the bottom of the window shown below and create a new Tag Change Script called 'Publish Script'.

Image RemovedImage Added

Set After setting the name of the script and then select a tag path.  In this case we're using an MQTT Engine tag from an emulated device.a tag in the default tag provider called 'MyTriggerTag' as shown below.

Image AddedImage Removed

Now select the 'Script' tab near the top.  In it, type the following line:

Code Block
system.cirruslink.enginetransmission.publish("Chariot SCADA", "a/b/c", str("hello world").encode(), 0, 0)

...

Code Block
system.cirruslink.enginetransmission.publish(String serverName, String mqttTopic, byte[] payload, int qos, boolean retain)

...

  • serverName: The server name as shown in the MQTT Engine Transmission Settings configuration shown below
  • mqttTopic: The MQTT Topic to publish on
  • payload: The MQTT payload
  • qos: The MQTT quality of service to publish on
  • retain: Whether or not to set the retain flag in the MQTT message

When complete, the script should look something like this.  Now click OK.

Image RemovedImage Added

Finally, save and publish the project.  At this point every time this tags value, quality, or timestamp changes it will result in a MQTT message being published on topic 'a/b/c' with a payload of 'hello world'.


Note

MQTT Transmision currently has a max inflight message limit of 10. Depending on the frequency of MQTT publishes and the QOS selected, you may see the error "Too many publishes in progress" in the Ignition logs.

There are a couple of options to work around this now:

  • Slow down the publish rate if possible
  • Use QoS0 for publishing
  • Set up multiple clients and spread the load across them

Additional Resources