The leader in industrial automation and control solutions

cMT Series HMIs and Gateways offer additional advanced MQTT features including support for Amazon AWS Things and Device Shadows, as well as support for the Sparkplug B payload specification.

AWS IoT

Overview of AWS IoT

AWS (Amazon Web Service) is a cloud platform widely used in the market, and AWS IoT (Internet of Things) supports the MQTT protocol. EasyBuilder Pro now supports AWS IoT service. Apart from using AWS IoT as a broker in the publish-subscribe mode, users can also create Amazon Things and Device Shadows offered by AWS IoT to make the most of MQTT.

Notes on AWS IIOT:

  1. The maximum number of layers in a topic is 8 (iot-2/type equals to 2 layers).
  2. Authentication via username and password in the General tab is not supported, you must use TLS/SSL.
  3. AWS supports only QoS 0 and QoS 1.
  4. Retaining the latest message in the MQTT broker is not supported.

This section goes through the steps to use AWS IoT and create a Thing and Shadow in EasyBuilder Pro.

AWS is a cloud platform; therefore, the settings are all configured on the web. You must sign up on the Amazon website before hosting an MQTT Broker. Amazon adds features to AWS frequently. The screenshots below may not be entirely accurate at the time of reading, and feature names may have changed.

Hosting an MQTT Broker

Follow these steps to host an MQTT Broker on AWS.

Remember, Amazon adds features to AWS frequently. The screenshots below may not be entirely accurate at the time of reading, and feature names may have changed.

Instructions: Hosting an MQTT Broker
  1. Visit AWS page

    Visit Amazon Web Services website at: https://aws.amazon.com
  2. Sigh Up and Sign In

    Sign up and sign in. Amazon offers a one year free evaluation trial for first time users.
    AWS Root user sign in screen. This is where you'd sign in to your AWS account.
  3. Browse for IoT Core

    After sign in, browse for IoT Core.
    Browsing for IoT Core AWS Services on the AWS website.
  4. Click ‘Get Started’

    Click [Get started] to enter user interface.
    AWS IoT main page. Click the 'Get Started' button to begin
  5. Create Policy

    Create a Policy and a Certificate. Click [Secure] » [Policies] and then click [Create a policy].
    AWS Policies page. Navigating here is done via the left menu. Secure menu on the left then Policies link underneath.
  6. Configure Policy Settings

    This page is for defining actions that can be performed by a resource. You may use the settings in the screenshot below or set your own. Click [Create] when finish.
    Policy Settings configuration page. This page is for defining actions that can be performed by a resource.
  7. Create Certificate

    Click [Secure] » [Certificate] and then click [Create a certificate].
    AWS Certificates page. Navigating here is done via the left menu. Secure menu on the left then Certificates link underneath.
  8. Click the (Create) button

    Click [Create certificate] near [One-click certificate creation].
    There are three options to create a certificate. In our example we will use the recommended method; the one-click certificate creation method.
  9. Attach the Policy after Certificate Creation

    After saving the four download files, click [Activate] » [Attach a policy].
    Certificate Created, download the files and then click the 'Attach a Policy' button
  10. Select the policy created previously

    Select the policy created in the preceding steps and then click [Done].
    Selecting the Policy that we created in the steps prior to the certificate creation.
  11. Success Box Pops up

    Security setting is done successfully when the following box shows.
    Success message for policy attachment
  12. Copy the link to your newly created AWS Broker

    Click [Settings]. The URL marked in the red frame below is the domain name of your AWS IoT broker, and will be used when setting up the MQTT object in EasyBuilder Pro.
    Once Policy and certificate are created and linked, you will have a custom endpoint. this is the URL of your newly created AWS broker domain.

EasyBuilder Pro MQTT Settings

After hosting an AWS MQTT Broker, launch EasyBuilder Pro and open the MQTT settings window.

Configure the MQTT Server Object

Here is how our MQTT Server Object will be configured in order to interface with the AWS broker we just created.

Instructions: Configure the MQTT Server Object
  1. General Tab Settings

    In the General tab, select [Normal] as cloud service to use publish-subscribe mode, or select [AWS IoT] to use Thing/Device Shadow mode.

    Use the URL obtained above for the domain name, and use port 8883.

    EBPro MQTT Server Object, general tab. This tab has the link to the AWS Domain that we created in the earlier set of steps.
  2. Address Tab Settings

    Configure the Status, Buffer, and Control addresses as normal.
    MQTT Server Object, Address tab. Status and Control addresses are configured, while our buffer usage address is not.
  3. TLS/SSL Tab Settings

    In the TLS/SSL tab, import the files generated when creating the AWS certificate.

    Server verification, CA certificate: Import a .pem file.

    Client verification, Certificate: Import a .crt file. (certificate.pem.crt)

    Client verification, Private key: Import a .key file (private.pem.key)

    MQTT Server, TLS/SSL tab configured for our AWS settings. In this case we are using the certificates that are on the HMI first.
  4. System Topic Tab Settings

    The System Topic tab includes Topic List and Connection State topics that cMT device will automatically send once it connects to broker. Be sure to conform to AWS restriction by changing the [QoS] and unchecking [Retain message] for each topic.

    Restrictions of using AWS IoT as MQTT Broker:

    Only QoS 0 and QoS 1 are available.

    Retain message is not supported

    The maximum number of layers is 8.

    MQTT Server, System Topic Tab. For our example, we are enabling the topic list and connect state System Topics.
  5. Configure Topic Publisher and Topic Subscriber Settings

    If using AWS as a [Normal] cloud service broker, configure the Topic Publisher and Topic Subscriber as described earlier in this manual.
    If using Things/Device Shadows ([AWS IoT] selected for cloud service on the General tab), see the next section for Publish/Subscribe settings.

Thing and Device Shadow

With AWS IoT, Publisher->Broker-> Subscribe is no longer the only path that data is accessed over MQTT. By introducing the Device Shadow service, a Thing (a device, app…etc) can interact with cloud applications and other devices connected to AWS IoT. The device shadow (sometimes referred to as a thing shadow) is used as a communication layer between your mobile/cloud application and the devices (HMIs) connected to AWS IoT.

The shadow is a persistent, virtual representation of the HMI or Gateway. Because it always has a point-in-time view of the state of your device, it’s easy to write applications that interact with your devices through device shadows. A Shadow can be maintained for each Thing (device/HMI) connected to AWS IoT. The Shadow can be used to get/set the state of a Thing over MQTT, regardless of whether the Thing is connected to the Internet.

Create a Thing and Device Shadow

Follow the below steps to create a Thing connected to AWS.

Instructions: Create a Thing and Device Shadow
  1. Go to the Things menu

    In your AWS IoT Dashboard, click [Manage] » [Things] » [Register a thing].
    AWS Things menu. In the 'Manage' section on the left, click 'Things'.
  2. Create a Thing

    Select [Create a single thing] and enter the name for the Thing. The additional Thing options can be ignored. Click [Next].
    AWS Create a Thing page. Tis is where you name your Thing.
  3. Create without Certificate

    Select [Create thing without certificate]. The Thing is created.
    We will be referencing the certificate created earlier at the next step.
    Skip Certificate and Create Thing page
  4. Select the previously-created certificate

    Navigate to [Secure] » [Certificates] and select the certificate created previously.
    Certificates Page. Accessed via the "Secure" toolbar on the left, certificates link below that. Select the certificate that you created previously
  5. Attach Thing

    Select [Attach thing] from the [Actions] menu.
    Actions menu, 'Attach Thing' option. This attaches the certificate to the thing you will choose in the next step.
  6. Select the Thing you created in Step 3

    Select the Thing created previously and click [Attach] to finish.
    We just attached the certificate we created earlier to the Thing we just crated in Step 3.
    Selecting the Thing that was created in Step 3. This is the linkage between the Thing and the Certificate.
  7. EBPro Configuration: AWS IOT as Cloud Service

    In EasyBuilder Pro, make sure that [AWS IoT] is selected as the cloud service option in the MQTT Server settings window.
    To Publish to AWS IoT properly, make sure AWS IoT is the selected Cloud Service in the MQTT Server General Tab.
  8. Add a Device

    Click [New} to add a device. We’ll add our Thing here.
    Click New to add a device. We will be adding our Thing here.
  9. Configure General Tab Properties

    Enter the Thing name and set a minimum time between publishes. Only QoS 0 and 1 are available.
    AWS IoT Thing dialog. This is where we enter the name of our Thing and general parameters.
  10. Configure Address Tab Properties

    In the Address tab, click [New] and select addresses for “reported” status and “desired” setting.

    The arrows “->” and “” indicate the direction in which data is transmitted between the HMI and AWS.

    By default, the “reported” data is only sent from the HMI to AWS and “desired” data can be sent in both directions.
    AWS IoT Thing Address tab. This is where you can set the reported/desired bit addresses in the HMI or connected PLC.
  11. Advanced Mode selection (optional)

    If the Advanced Mode checkbox is selected, the Status (reported) and Setting (desired) can use different addresses for each data transmission direction to allow more granular control from AWS.
    If the Advanced Mode checkbox is selected, the Status (reported) and Setting (desired) can use different addresses for each data transmission direction to allow more granular control from AWS.
  12. Success!

    You should now be able to subscribe and publish to your Thing with the following topics:
    This information is found in the [Interact] section of the Thing Dashboard.
    You should now be able to subscribe and publish to your Thing
  13. Test within AWS

    From the [Test] section of the AWS IoT Dashboard, you should be able to subscribe and publish to topics and interact with your test project.
    Testing the topic subscribe/functionality of the Thing within the AWS Dashboard

Sparkplug B

Overview of Sparkplug B

Sparkplug is a specification for MQTT enabled devices and applications to send and receive messages in a stateful way. Sparkplug provides a mechanism for ensuring that remote device or application data is current and valid by using device lifecycle messages such as the required birth and last will & testament messages that must be sent to ensure the device lifecycle state and data integrity.

It also is utilized in connecting with the Inductive Automation Ignition Platform utilizing the Cirrus Link MQTT modules. The Sparkplug specification provides the necessary details for any MQTT enabled device to connect to MQTT servers and integrate with zero configuration into Ignition via the Cirrus Link MQTT Engine Module or other Sparkplug supported applications.

Sparkplug B features include:

  • Complex data types using templates
  • Datasets
  • Richer metrics with the ability to add property metadata for each metric
  • Metric alias support to maintain rich metric naming while keeping bandwidth usage to a minimum
  • Historical data
  • File data

The Sparkplug B specification can be found here. Topics are formatted as:

spBv1.0/group_id/message_type/edge_node_id/[device_id]

The following message_type elements are defined for the Sparkplug Topic Namespace:

  • NBIRTH – Birth certificate for MQTT EoN nodes.
  • NDEATH – Death certificate for MQTT EoN nodes.
  • DBIRTH – Birth certificate for Devices.
  • DDEATH – Death certificate for Devices.
  • NDATA – Node data message.
  • DDATA – Device data message.
  • NCMD – Node command message.
  • DCMD – Device command message.
  • STATE – Critical application state message.

EasyBuilder Pro Settings

To configure a Sparkplug B payload, launch EasyBuilder Pro and open the MQTT settings window.

Configure the MQTT Server Object

Follow these steps to configure your MQTT Server Object for a Sparkplug B payload

Instructions: Configure the MQTT Server Object
  1. MQTT Server: General Tab Settings

    In the General tab, select [Sparkplug B] for the cloud service. In this example, we will use the test.mosquitto.org public broker.
    EBPro MQTT Server Object, general Tab. Sparkplug B is configured as our Cloud Service.
  2. Sparkplug B Dialog: General Tab Settings

    Configure the Domain and Sparkplug B general tab information to your desired values.
    Sparkplug B General tab Settings. This is where the server address and groups are configured.
  3. Sparkplug B Device tab

    In the Device Tab, this is where we can add new Groups and new Tags for the payload.
    Sparkplug B Device Tab settings. This is where we will add new groups or tags to the Sparkplug B payload.
  4. Click ‘New Tag’

    In the [Device] tab, click [New Tag] to add data to the payload.
    Configuring the new Tag in the Device tab to reference the Local HMI registers.
  5. New tag is shown in Device Tab

    The Newly Created Tag is now shown in the Device Tab
    The newly created tag shows up in the Device tab under "Local HMI".
  6. Simulate in EBPro

    Add a way to change the specified tag to a screen and run the project in [Online Simulation] mode
    EBPro Project toolbar, with the Online Simulation button selected.
  7. View in MQTT.fx Client

    Open the MQTT.fx client program and connect to test.mosquitto.org. The preceding setup results in data being updated on topic [spBv1.0/default_group/DDATA/default_edge_node/Local HMI]. Be sure to set the [Payload decoder] to [Sparkplug Decoder] to view the payload in a readable format.
    Project running in MQTT.fx client window