A diagram explaining the MQTT publish/subscribe model, showing an IoT gateway (publisher) sending data to an MQTT broker, which then distributes it to subscribers.

MQTT and the IoT Gateway: The Perfect Pair for IIoT Communication

Written by: Robert Liao

|

Published on

|

Time to read 7 min

Author: Robert Liao, Technical Support Engineer

Robert Liao is an IoT Technical Support Engineer at Robustel with hands-on experience in industrial networking and edge connectivity. Certified as a Networking Engineer, he specializes in helping customers deploy, configure, and troubleshoot IIoT solutions in real-world environments. In addition to delivering expert training and support, Robert provides tailored solutions based on customer needs—ensuring reliable, scalable, and efficient system performance across a wide range of industrial applications.

Summary

In the world of IIoT, the IoT Gateway and the MQTT protocol are the perfect partnership. This article explains why. A traditional IoT Gateway solves the problem of protocol translation (like Modbus to MQTT), but MQTT itself solves the problem of efficient and reliable data transport over unreliable networks (like 4G/5G). We'll explore the MQTT publish/subscribe model, why it's superior to legacy polling, and how an industrial IoT gateway acts as the perfect, intelligent MQTT client on the factory floor.

Key Takeaways

Different Jobs: An IoT Gateway collects data; MQTT is the lightweight protocol it uses to send that data.

Pub/Sub Model:MQTT uses a "Publish/Subscribe" model, which is far more efficient and scalable than old poll/response protocols like Modbus. An IoT Gateway publishes data to a central MQTT broker.

Built for Unreliable Networks:MQTT is lightweight and includes Quality of Service (QoS) and "Last Will & Testament" (LWT) features. This makes it the perfect choice for a cellular IoT Gateway on a 4G or 5G connection.

The Perfect Translation: The most common job for an edge computing gateway (a smart IoT Gateway) is to poll a local PLC via Modbus and then publish that data as Modbus to MQTT.

MQTT and the IoT Gateway: The Perfect Pair for IIoT Communication

Let's be honest: most industrial data protocols are heavy, "chatty," and were designed for a wired factory floor in the 1990s. Now, try to run a "chatty" protocol like Modbus directly over an expensive, high-latency 4G cellular connection. It's a nightmare. It's slow, it's unreliable, and it will eat your data plan for lunch.

This is where the perfect partnership comes in.

  1. The IoT Gateway: The powerful, local "translator" that speaks the old, heavy languages.
  2. The MQTT Protocol: The modern, lightweight "language" for sending data to the cloud.

The IoT Gateway does the "heavy lifting" locally, and MQTT does the "lightweight lifting" to the cloud. Together, they form the backbone of nearly every successful IIoT project. Let's explore why this iot gateway mqtt combination is so powerful.

What is MQTT? (And Why Is It So Different?)

MQTT (Message Queuing Telemetry Transport) is a messaging protocol. Its genius lies in its simplicity and a model called "Publish/Subscribe" (Pub/Sub).

This is not like Modbus.

  • Modbus (Poll/Response): A Master must ask a Slave for data. ("Hey, PLC, what's your temperature?" ... "It's 25C." ... "Okay. Hey, PLC, what's your temperature now?" ... "It's 25.1C.") This is constant, inefficient polling.
  • MQTT (Publish/Subscribe): This model has three parts:
    1. Publisher (The IoT Gateway): This is your IoT Gateway. It publishes data once to a specific "topic." (e.g., Topic: factory/line1/motor/speed, Message: 1800).
    2. Broker (The Server): This is the central server. It's like a post office. It receives all messages and sorts them by topic.
    3. Subscriber (The Application): This is your cloud dashboard or SCADA. It "subscribes" to the topic factory/line1/motor/speed.

The IoT Gateway (Publisher) and your application (Subscriber) never talk to each other directly. The MQTT Broker decouples them completely. This is the magic key to scalability. Your IoT Gateway just publishes its data; it doesn't care if zero or 50 applications are listening.


A diagram explaining the MQTT publish/subscribe model, showing an IoT gateway (publisher) sending data to an MQTT broker, which then distributes it to subscribers.


The IoT Gateway as the Perfect MQTT Client

This Pub/Sub model is perfect for the cloud, but your PLC on the factory floor doesn't speak MQTT. This is where the industrial IoT gateway becomes the essential "MQTT Client" at the edge.

From "Chatty" Polling to "Smart" Publishing (Modbus to MQTT)

This is the single most important job for an IoT Gateway.

  1. Local Polling: The IoT Gateway (like a Robustel EG5120) runs locally and polls the PLC via Modbus every 100 milliseconds. (This is the "chatty" part, but it's on a local wire, so it's fast and free).
  2. Edge Logic: The IoT Gateway thinks. It sees the temperature is 25.1C, 25.1C, 25.1C... It doesn't need to report this.
  3. Event-Driven Publishing: Suddenly, the value changes to 25.2C. Now, the IoT Gateway publishes one singleMQTT message to the broker: {"topic": "factory/plc1/temp", "value": 25.2}.

Instead of sending 1,000 redundant messages, your IoT Gateway only sends one, precisely when the data matters. This is the Modbus to MQTT translation, and it saves you massive amounts of cellular data and cloud processing costs.

Handling the "Last Mile": Why MQTT is Built for an Unreliable Cellular IoT Gateway

What happens if the 4G/5G connection at your remote site is flaky? This is where MQTT truly shines, and why any cellular IoT gateway should use it.

  • It's Lightweight: An MQTT message header is tiny (as small as 2 bytes). A standard HTTP header can be 800+ bytes. When you're paying per kilobyte on a cellular plan, MQTT is vastly cheaper. This makes it the ideal protocol for an IoT Gateway on the move.
  • Quality of Service (QoS):MQTT has built-in reliability levels. When your IoT Gateway publishes a critical alarm, it can use:
    • QoS 0: "Fire and forget." (Fastest, but a packet might get lost)
    • QoS 1: "At least once." (Guarantees delivery, but might get duplicates)
    • QoS 2: "Exactly once." (Guarantees delivery, no duplicates. Slower, but 100% reliable) A professional IoT Gateway lets you choose the QoS level for each data point.
  • Last Will & Testament (LWT): This is a brilliant feature for any remote IoT Gateway. When the IoT Gateway first connects to the MQTT Broker, it gives it a "Last Will":

"Hey, Broker. If you don't hear from me for 60 seconds (no ping, no message), assume my 4G connection died or I lost power. When that happens, please automatically publish this message on my behalf to the topic factory/gateway1/status: Offline."

This LWT feature is how platforms like RCMS can instantly tell you a remote IoT Gateway has gone offline, even when the device itself had no chance to send a "goodbye" message.


A diagram showing how an IoT Gateway performing 'Modbus to MQTT' translation saves data by filtering redundant packets locally before sending over cellular.


Where Does the MQTT Broker Live?

Your IoT Gateway is the "Client." It needs a "Broker" (Server) to talk to. You have two main options:

  1. Cloud-Based Broker (Most Common): You use a cloud service like AWS IoT Core, Azure IoT Hub, or a self-hosted broker on a server. Your IoT Gateway uses its 4G/5G connection to publish data to this public internet address. This is the standard for most IIoT applications.
  2. Local Broker on an Edge Computing Gateway: What if your internet fails, but you still need local systems to talk? A powerful Edge Computing Gateway (the most advanced type of IoT Gateway) like the Add One Product: EG5120 can run its ownMQTT Broker using Docker. This allows a local HMI (subscribing) and the IoT Gateway (publishing) to keep talking to each other inside the factory, even if the internet is down.

Conclusion: The IoT Gateway and MQTT are Built for Each Other

The IoT Gateway and MQTT are the perfect pair because they solve each other's problems.

  • The IoT Gateway solves MQTT's problem: It provides the "feet on the street" to go out and get the dirty data (Modbus, S7, etc.) that MQTT itself can't read.
  • MQTT solves the IoT Gateway's problem: It provides a super-lightweight, reliable, and scalable "language" for the gateway to send that data over expensive and unreliable cellular networks.

A "smart" factory isn't just about having data; it's about moving that data efficiently and reliably. The combination of a powerful industrial IoT gateway (like a Robustel) doing the local translation and an MQTT protocol handling the transport is the undisputed, modern standard for building a scalable and cost-effective IIoT solution.


A timeline showing how an IoT Gateway uses the MQTT LWT (Last Will & Testament) feature to instantly notify a platform like RCMS when it goes offline.


Frequently Asked Questions (FAQ)

Q1: What is an MQTT Broker and do I need one for my IoT Gateway?

A1: Yes, 100%. The MQTT Broker is the central "post office" or server that manages all MQTT messages. Your IoT Gateway (the "Publisher") sends data to the broker. Your cloud application (the "Subscriber") receives data from the broker. You must have a broker, either in the cloud (like AWS/Azure) or self-hosted.

Q2: Can't my new PLC just publish MQTT directly? Do I still need an IoT Gateway?

A2: Some new PLCs can. But even if they can, you still want a separate IoT Gateway for three critical reasons:

  1. Security: You should never plug a PLC directly into the internet. The IoT Gateway acts as a critical firewall, protecting your PLC from the outside world.
  2. Connectivity: The IoT Gateway provides the 4G/5G cellular connection with dual-SIM failover, which your PLC doesn't have.
  3. Management: The IoT Gateway is managed by a platform like RCMS, which handles security, OTA updates, and remote access. Your PLC's MQTT client does not.

Q3: Is MQTT secure?

A3: Yes, when implemented correctly. MQTT itself supports SSL/TLS encryption for the data transport (MQTTS) and username/password authentication. A secure IoT Gateway will use these features to ensure that its connection to the MQTT Broker is fully encrypted and authenticated.