How to Publish E2C Trinity Tag Data to an MQTT Broker

How to Publish E2C Trinity Tag Data to an MQTT Broker


Document Header

FieldValue
ProductRobustel E2C Trinity (E2C Factory / E2C Field)
Document TypeKnowledge Base Article — How-to Guide
Intended AudienceUsers who have already configured data collection in E2C Trinity and need to forward tag data to an MQTT broker
PrerequisitesThis guide does not cover how to install or configure an MQTT broker. Before starting, obtain the broker address, port, authentication details, and certificates (if using TLS) from your MQTT administrator or cloud platform.
Tested SoftwareE2C Factory V2.1.4.1
Tested Gateway OSRobustOS Pro V2.4.2
Tested ModelEG3120
Last Verified2026-07-22
Estimated Time20–30 minutes

Overview

This article shows you how to publish tag data collected by E2C Trinity to an external MQTT broker. You will create a Tag Group, configure an MQTT Cloud Service, add a publish rule, and verify the data using MQTTX.

Stage 1 — Southbound Collection: E2C Trinity reads data from your industrial devices (PLC, sensor, meter, etc.) using protocols like Modbus TCP, OPC UA, or BACnet, and stores the values as internal "Tags."

Stage 2 — Northbound MQTT Publish (this guide): E2C Trinity connects to your MQTT broker as a client, packages the collected tags into JSON payloads, and publishes them to configured topics.

Stage 3 — Cloud Consumption: Your cloud platform (AWS IoT, Azure IoT Hub, or a custom application) subscribes to the MQTT topics and processes the data.

Note: E2C Trinity also supports Sparkplug B (an industrial IoT specification built on MQTT 3.1.1) and HTTP for cloud data forwarding. These are covered in separate articles.


Core Concepts & Glossary

If you are already familiar with MQTT, feel free to skip this section.

TermWhat It Means in Plain English
MQTT (Message Queuing Telemetry Transport)A lightweight messaging protocol designed for IoT. Think of it as a "post office" system: devices publish messages to specific topics, and any system subscribed to that topic receives them instantly.
MQTT BrokerThe central server that receives all messages and routes them to the right subscribers. Popular brokers include Mosquitto (open-source), EMQX, AWS IoT Core, and Azure IoT Hub.
TopicA text string that acts as the "address" of a message. For example, factory/workshop-a/temperature tells the broker that this message contains temperature data from Workshop A.
QoS (Quality of Service)Defines how reliably a message is delivered. QoS 0 = "fire and forget" (fastest). QoS 1 = "delivered at least once" (good balance). QoS 2 = "delivered exactly once" (slowest).
TLS (Transport Layer Security)Encryption that secures the MQTT connection. Always use TLS when sending data over the public internet.
Tag GroupIn E2C Trinity, a logical collection of data points (tags) that you organize together. MQTT publishes data by Tag Group — not by individual tags.
Client IDA unique identifier for each MQTT client connecting to the broker. No two clients can share the same ID simultaneously.

Example Configuration Used in This Guide

To make it easier to follow, all steps in this guide use the same example values:

ItemExample
MQTT Broker192.168.0.100
Port1883
Cloud Service NameMES_MQTT
Client IDgateway-workshop-a-01
Tag GroupMachine_Data
Report Interval10 seconds
Publish Topicpublish/machine
QoS0

Before You Start

Before beginning the configuration, make sure you have:

  • An E2C Trinity gateway with live tag data already being collected from your industrial devices.
  • A running MQTT broker accessible from the gateway — either a cloud service (AWS IoT, Azure IoT Hub, EMQX Cloud) or a local broker (EMQX, Mosquitto).

Security Notice: Public MQTT brokers (such as broker.emqx.io) should only be used for testing with non-sensitive data. Do not publish production, customer, credential, or personally identifiable data to a public broker. Always use TLS when sending data over the public internet.

  • An MQTT client tool for testing: MQTTX (desktop app, recommended) or mosquitto_sub (command-line).
  • The following information from your MQTT administrator:
    • Broker address and port
    • Username and password (if authentication is required)
    • TLS certificates (if encryption is required)

Step-by-Step Configuration

Important: The screenshots use E2C Factory as an example. The workflow is also applicable to E2C Field, although some menu names or interface details may differ depending on the software version.

Workflow Overview

StepWhat You Will DoEstimated Time
Step 1Verify that E2C Trinity is already collecting live tag data2 minutes
Step 2Create a Tag Group to organize the data points you want to publish5 minutes
Step 3Create an MQTT Cloud Service and test the connection to your broker10 minutes
Step 4Add a publish rule — choose which Tag Group to publish and under which MQTT topic5 minutes
Step 5Verify that your broker is receiving data using MQTTX3 minutes

Skip ahead: If you already have a Tag Group with live tags, jump to Step 3.


Step 1: Verify Live Tag Data

Purpose: MQTT only forwards data that already exists as live tags. Before configuring anything, confirm that your data collection is working.

  1. In the E2C Trinity web interface, navigate to Data Collection in the left sidebar.
  2. Verify that your device is listed and shows a green status icon.
  3. Confirm that the Latest Value column shows real-time data and the Update Time is current.

If you do not see live data, complete the device and tag configuration first. Refer to the relevant protocol guide (e.g., "How to Configure Modbus TCP Data Collection in E2C Factory") on the Robustel Support Center.


Step 2: Create a Tag Group

Purpose: E2C Trinity publishes data to MQTT by Tag Group — not by individual tags. You must create at least one Tag Group before configuring message publishing. Think of a Tag Group as a "folder" that bundles related tags for batch transmission.

2.1 Create the Group

  1. Navigate to Data to Cloud > Tag Group.
  2. Click + Create Group.

  1. In the Add Group pop-up window, configure:
ParameterDescriptionExample
NameA recognizable name for this group of tags.Machine_Data
Report TypePeriod (fixed intervals), Change (only when a value changes), or Change & Period (both).Period
Cycle UnitSubsecond-level or Millisecond-level.Subsecond-level (default)
Report IntervalInterval in seconds for periodic reporting. Range: 1–999999.10
DescriptionOptional notes about this group's purpose.Packaging machine production data

  1. Click Save and Configure Tag to assign tags immediately (recommended), or click Save to add tags later.

2.2 Add Tags to the Group

  1. The Add Tag window shows all available tags from your configured devices on the left.
  2. Select the tags you want to include and click > to move them to the group. Use ALL to move all tags at once.

  1. Click Close when done. Your Tag Group is ready.

Note: You can always add or remove tags later by selecting the group and using the Add and Batch Delete buttons.


Step 3: Create an MQTT Cloud Service

Purpose: Create a connection in E2C Trinity that defines the target MQTT broker and how to connect to it.

3.1 Basic Connection Settings

  1. Navigate to Data to Cloud > Cloud Service.

  1. Click + Create Cloud Service. Enter a Cloud Service Name (e.g., MES_MQTT) and select MQTT as the Cloud Service Type. Click Save.

  1. Fill in the Basic Settings:
ParameterDescriptionExample
Server AddressThe IP address or domain name of your MQTT broker.192.168.0.100
Port NumberThe TCP port of your broker. Default is 1883 (non-TLS). For TLS, use the port specified by your broker administrator — commonly 8883.1883
MQTT Client IDA unique identifier for this gateway. Leave blank to auto-generate.gateway-workshop-a-01
Enable User AuthenticationTurn on if your broker requires a username and password.Enabled (if required)
Username / PasswordYour broker credentials (appear when authentication is enabled).e2c-gateway / your-password
Enable TLSTurn on to encrypt the connection. Requires TLS certificates — see TLS Configuration below.Enabled (recommended for cloud)
Clean SessionWhen enabled, the broker discards session state on disconnect. When disabled, the broker persists subscriptions and queued messages.Enabled
MQTT VersionSelect v3.1 or v3.1.1. v3.1.1 is recommended for most brokers.v3.1.1

3.2 Save and Test Connection

Critical Step: After completing the configuration, you must save and verify the connection.

  1. Click the Save button at the top-right corner.
  2. Click the Test Connection button. The Cloud Service Status indicator shows whether the connection is successful.

  • A green status with "Connected" means the gateway has successfully connected to the MQTT broker.
  • If the status shows Disconnected, refer to the Troubleshooting section.

Important: Gateway Time Synchronization

MQTT connections — especially TLS connections — rely on accurate timestamps. If the gateway's system clock is incorrect, the connection may fail.

To check and synchronize the gateway's time:

  1. In the gateway's Web GUI (RobustOS Pro), go to Services > NTP.
  2. Use the NTP tab to configure NTP servers (e.g., pool.ntp.org).
  3. Use the Status tab to verify the System Time. If the Last Update Time shows "Not Updated," click Sync to manually synchronize.


For detailed instructions, refer to the RobustOS Pro Software Manual on the Robustel Support Center.


Step 4: Add a Publish Rule

Purpose: Tell E2C Trinity which Tag Group to publish and under which MQTT topic.

  1. After saving the MQTT Cloud Service, scroll down to Message Management. Make sure the Publish tab is selected.
  2. Click Add.

  1. In the Add Publish pop-up window, configure:
ParameterDescriptionExample
Data Source TypeSelect Tag Data to publish real-time tag values.Tag Data
GroupSelect the Tag Group you created in Step 2.Machine_Data
TopicThe MQTT topic to publish to.publish/machine
Topic AliasA human-readable label for this topic in the rule list.machine
QoS0 = at most once, 1 = at least once, 2 = exactly once. For high-frequency telemetry, QoS 0 is sufficient.0

  1. Click Save. After saving, E2C Trinity starts publishing data according to the Tag Group reporting settings.

Customizing the Payload Format: The Function Code panel allows you to write a JavaScript function to transform the data payload before publishing. If you leave the default return msg;, the data is published in E2C Trinity's standard JSON format. For advanced customization, click View Help in the right-side panel for the full API reference.


Step 5: Verify the Published Data

Purpose: Confirm that the MQTT broker is receiving data from E2C Trinity.

Using MQTTX (desktop app — recommended):

  1. Open MQTTX and create a new connection to your broker (same address and port as in Step 3).
  2. Click Connect, then + New Subscription, enter the topic (e.g., publish/machine), and click Confirm.
  3. You should see JSON messages arriving at the configured reporting interval:

Each message follows this structure:

{
"groupName": "Machine_Data",
"groupTime": 1784633235145,
"messageId": "66b517bf-192c-4522-b08a-7b5087964d96",
"messageType": "normal",
"payload": {
"cycle_count": {
"deviceName": "A_Packaging_Machine",
"tag": "cycle_count",
"time": 1784633234000,
"value": "2780"
}
}
}
FieldDescription
groupNameName of the Tag Group that was published
groupTimeUnix timestamp (milliseconds) when the group was published
messageIdUnique message identifier (UUID v4)
payload.{tag}.deviceNameSource device name
payload.{tag}.tagTag name
payload.{tag}.timeUnix timestamp (milliseconds) of the tag's last update
payload.{tag}.valueCurrent tag value

Note: The value field is shown as a string in this example. Verify the output format for your tag data type and software version — the encoding may vary depending on the tag type.

If you see real-time data in the MQTT client, your configuration is complete.


Troubleshooting

IssuePossible CauseSolution
Cloud Service Status shows "Disconnected"The gateway cannot reach the broker, or the broker rejected the connection.1. Verify the Server Address and Port. Use the Ping tool in the gateway's System menu to check network reachability. 2. Check that the gateway's system time is synchronized (see NTP note in Step 3.2). An incorrect clock can cause TLS certificate validation to fail. 3. Check if a firewall is blocking the port.
Connected but no messages are receivedNo publish rule is configured, or the Tag Group is empty.Verify that a publish rule has been added with a valid Tag Group assigned. Check that the Tag Group contains tags with live data (see Step 1 and Step 2).
Messages are received but values are nullThe underlying tags are in an error state.Go back to Data Collection and check the device and tag status. If a tag shows a red icon or null value, troubleshoot the southbound connection first.
Authentication failedWrong username or password.Verify the credentials with your broker administrator. If the broker requires TLS, make sure TLS is enabled.
TLS connection failsCertificate is invalid, not trusted, or wrong authentication method.1. Verify the correct Authentication Method is selected (CA Cert Auth or Mutual Cert Auth). 2. Check that certificate contents are complete and correctly pasted. 3. Ensure the gateway's system time is correct.
Broker rejects the Client IDThe Client ID is already in use by another client.Change the Client ID to a unique value, or leave it blank to auto-generate.

Where to Find Logs

  • Debug Logs: In E2C Trinity, navigate to Debug Logs in the left sidebar.
  • System Logs: In the gateway's management page (RobustOS Pro), go to Services > Syslog.

Advanced Topics

TLS Configuration

TLS (Transport Layer Security) encrypts the data between your gateway and the MQTT broker, preventing unauthorized access or tampering. When you enable TLS in the MQTT Cloud Service settings, you need to select an authentication method. Select the authentication method according to the requirements provided by your MQTT broker administrator — do not guess.

Authentication MethodWhen It Is UsedWhat You Need
CA Cert AuthThe broker presents a certificate that must be verified against a trusted Certificate Authority (CA). This covers both public CAs (common for cloud brokers like AWS IoT or Azure IoT Hub) and private/self-signed CAs (common for self-hosted brokers like EMQX or Mosquitto).The CA certificate file. For public CAs, download it from your cloud platform's documentation. For private/self-signed CAs, obtain it from your broker administrator or generate it using OpenSSL.
Mutual Cert AuthThe broker requires the client (gateway) to also present its own certificate to prove its identity. Used in high-security environments.The CA certificate, plus a client certificate and client key pair issued by your broker administrator or cloud platform's device provisioning service.

After selecting the method, paste the certificate contents into the corresponding fields and save the configuration.

Last Will Message (LWT)

A Last Will Message is a pre-defined message that the MQTT broker automatically publishes to a specified topic if the gateway disconnects unexpectedly — for example, due to a power failure or network outage. This allows your cloud platform or monitoring system to detect offline gateways.

To configure LWT, expand the Last Will Message section in the MQTT Cloud Service settings and specify:

  • Topic — where the message is published (e.g., gateway/status)
  • QoS — the delivery guarantee level
  • Payload — the message content, typically a JSON string like {"status": "offline"}

Custom Payload Formatting

By default, E2C Trinity publishes tag data in its standard JSON format (see the example in Step 5). If your cloud platform expects a different JSON structure, you can use the Function Code panel in the Add Publish window to write a JavaScript function that transforms the payload before publishing.

The function receives a msg parameter containing the tag data. You can use Edge.ReadTags() to read additional tag values, perform calculations, filter data, or restructure the JSON output. Other APIs are available for advanced logic. Click View Help in the right-side panel for the full API reference.

Sparkplug B

Sparkplug B is an industrial IoT data exchange specification built on top of MQTT 3.1.1. It adds standardized topic structures (e.g., spBv1.0/{Group ID}/DDATA/{Edge Node ID}/{Device ID}), binary Protobuf payloads, and device lifecycle state management (birth/death certificates). It is commonly used in SCADA and industrial platforms that require self-describing, interoperable data models.

To use Sparkplug B, create a new Cloud Service and select Sparkplug B as the type instead of MQTT. In the current E2C Trinity implementation, Sparkplug B uses a fixed reporting model and does not expose user-defined Topic, Last Will Message, or Clean Session settings.

Cloud Platform Integration

The Standard MQTT configuration described in this guide can be used with MQTT 3.1/3.1.1-compatible brokers, provided that the broker's authentication, client ID, topic, and access-policy requirements are met. Guides for connecting E2C Trinity to specific cloud platforms and brokers — including AWS IoT Core, Azure IoT Hub, and EMQX — are planned for future release. For more E2C Trinity articles, visit the Robustel Knowledge Base.


Appendix


    • Related Articles

    • How to Integrate MQTT-Telegram Alarm

      This guide explains how to set up a system where your ROS PRO device acts as an MQTT broker and forwards alarm messages to Telegram. Prerequisites ROS PRO device with network connection Telegram account Step 1: Create Telegram Bot Open Telegram app ...
    • How to Configure LoRa to MQTT

      This guide provides a detailed walkthrough for using a Robustel R1520LG gateway to transmit data from LoRa nodes to a cloud-based MQTT broker. This setup leverages the built-in ChirpStack Network Server and the Edge2Cloud (E2C) framework to achieve a ...
    • How to install the MQTT broker service on EG series devices?

      Overview This article provides a step-by-step guide for installing and configuring the Mosquitto MQTT broker on a Robustel EG series gateway (e.g., EG5120, EG5200) running RobustOS Pro. This setup is ideal for scenarios where you need a reliable, ...
    • How to Deploy Zabbix for SNMP to MQTT Data Forwarding on Robustel EG/MG Series

      Overview This guide describes how to manually configure a Robustel EG/MG series gateway (running RobustOS Pro) to act as an SNMP collector and MQTT forwarder. By deploying Zabbix Server and Agent 2 via Docker, the gateway can poll data from local ...
    • How to Deploy Zabbix and SNMP Data Simulation via MQTT on RobustOS Pro

      Overview When using Robustel's edge computing gateways (such as the MG460) running RobustOS Pro, users may need to monitor end-device data using Zabbix via SNMP and MQTT protocols. This comprehensive deployment solution bridges end-devices to a ...