Skip to content
Mohammad Awadallah
All posts

Modbus, MQTT or OPC UA: choosing a protocol for your plant's sensors

Three protocols come up in every industrial digitalization project, and each has its place. A practical comparison for a small plant: what each offers, where it falls short, and how to combine them safely.

4 min readAlso in:العربيةFrançais

When you start connecting a plant’s sensors and devices to a data system, three names come up everywhere: Modbus, MQTT and OPC UA. “Which one is best?” is the wrong question. The right one is: what do your devices speak today, and where do you want the data to go?

Modbus: the language of old and new devices

Modicon (now part of Schneider Electric) introduced Modbus in 1979, and it is still present in a huge number of instruments and controllers.

How it works. A master asks, a slave answers. Data sits in fixed tables: one-bit digital inputs and outputs, and 16-bit registers for numeric values. It runs over a serial line (RTU) or over the network (Modbus TCP) on port 502.

Strengths:

  • Very simple, and supported almost everywhere.
  • One tool can read devices from different manufacturers.

Weaknesses:

  • The protocol carries no meaning. Register 40001 doesn’t tell you “temperature in °C”. You need the device’s documentation to know what each register means and how to convert the raw value.
  • No security in the classic version. Anyone who reaches the network can read and write. A Modbus Security specification adds TLS and X.509 certificates on port 802, but most installed devices don’t support it.
  • Constant polling doesn’t suit hundreds of sensors over a wide network.

MQTT: publish and subscribe through a broker

MQTT is an OASIS standard; version 5 became a standard in March 2019. The idea is completely different: a device doesn’t wait to be asked — it publishes its readings to a topic on a central broker, and anyone interested subscribes to that topic.

What it offers:

  • Three delivery levels (QoS): at most once, at least once, exactly once. You choose by how much the message matters.
  • Retained messages: a new subscriber gets the last value immediately instead of waiting for the next reading.
  • The Will message: if a device drops off suddenly, the broker publishes a message on its behalf, so you know it’s gone.
  • Port 1883 for plain connections, 8883 for MQTT over TLS.

The weakness: MQTT moves messages but doesn’t define their shape. Every project invents its own topic names and payload format. That’s where Sparkplug B from the Eclipse Foundation comes in — now an international standard as ISO/IEC 20237:2023. It defines:

  • A uniform topic layout: spBv1.0/group_id/message_type/edge_node_id/device_id.
  • “Birth” messages in which a device announces itself and its values when it connects, and “death” messages when it disconnects.
  • A state message for the central application, so devices know whether the system receiving their data is up.

OPC UA: data and its meaning together

OPC UA comes from the OPC Foundation and is published as the international standard IEC 62541. What sets it apart is information modeling: a device doesn’t just send a number, it describes itself — this is a reactor, it has a temperature sensor, the value is this, in this unit, with this range.

What it offers:

  • Built-in security: every client and server identified by an X.509 certificate, session encryption and message signing.
  • Client/server, and publish/subscribe as well.
  • Runs from small microcontrollers to the cloud. The well-known port for the local discovery service is 4840.

The weakness: harder to set up and understand, and certificate management is real work. Support in small, cheap devices is thinner than for Modbus.

Combining them

In a small plant you won’t pick just one. The pattern that usually works:

  1. At the device level: read whatever your devices speak. If that’s Modbus, use Modbus — inside the isolated plant network only.
  2. An edge gateway: a small box that reads Modbus or OPC UA locally, turns every value into a clear name and unit, and publishes it.
  3. To the central system: over MQTT with TLS, preferably in Sparkplug B format so you don’t invent your own.
  4. When buying new equipment: prefer devices that support OPC UA or MQTT directly; it saves you a translation layer later.

Security first

A joint fact sheet from CISA, the FBI and other US agencies (May 2025) sets out five basic mitigations for operational technology. The most important for a small plant:

  • Remove any direct connection between OT systems and the internet. No exposed Modbus, no control panel on a public address.
  • Change default passwords on every device.
  • Make remote access go through a VPN with multi-factor authentication.
  • Separate the plant network from the office network with a DMZ.
  • Practice running manually, so production doesn’t stop when the system does.

And remember that a secure protocol can be implemented insecurely: in September 2026, CISA published an advisory about a critical flaw, scored 9.8, in the MQTT client of the lwIP embedded networking library. Update your devices’ firmware the way you update any server.

The takeaway

Modbus to reach the devices you already have, MQTT with Sparkplug B to move data efficiently to the central system, and OPC UA when you need data, meaning and built-in security together. And the constant rule in every case: the plant network is never exposed to the internet, and every value that leaves the gateway carries its name and its unit.