What Is MQTT? How Is It Used in Factories?

What Is MQTT? How Is It Used in Factories?

MQTT (Message Queuing Telemetry Transport) is a lightweight communication protocol, designed for low bandwidth and unreliable networks, in which devices publish and subscribe to topic-based messages through a central server (broker). In factories it is widely used to carry data between sensors, counters, PLC gateways and the MES.

In brief

  • Model: publish/subscribe; a broker sits in the middle.
  • Standard: OASIS and ISO/IEC 20922; runs over TCP and is encrypted with TLS.
  • Delivery guarantees can be chosen with QoS levels 0/1/2.
  • Used by: IIoT sensor networks, edge devices, cloud/MES integrations.
  • Benefit: connecting thousands of devices with low load and decoupling the data source from the consumer.

What Is MQTT?

In classic client-server protocols, the party that wants the data asks the source every time. In MQTT, the source (for example a temperature sensor) publishes the data to the broker under a topic : factory/line1/press2/temperature. Every system interested in this data (MES, energy board, maintenance app) subscribes to the topic, and the broker forwards new values to them when they arrive. The publisher does not need to know who is listening.

This decoupling makes the protocol particularly suitable for environments with many small devices: the message header is a few bytes, the connection is kept open and the device only speaks when something changes.

Key Concepts

ConceptMeaning
BrokerThe server that receives messages and distributes them to subscribers (Mosquitto, EMQX, HiveMQ, etc.)
TopicHierarchical topic name; bulk subscription with the + and # wildcards
QoS 0At most once; loss is accepted (high-frequency measurements)
QoS 1At least once; may arrive twice (counters, status)
QoS 2Exactly once; the slowest (critical commands/events)
Retained messageThe last value is kept on the broker; a new subscriber gets it immediately
Last WillAn “offline” message the broker publishes automatically if the device drops

How Is It Used in the Factory?

Sensor and counter networks

Energy analysers, temperature/humidity sensors and cycle counters publish over MQTT directly or through a gateway. It is particularly suitable for wireless nodes; short disconnections are detected with Last Will.

Moving PLC data to the centre

An edge device converts values read from the PLC via Modbus or OPC UA into MQTT and publishes them. This way the MES subscribes to a single broker instead of connecting to each PLC separately. The Sparkplug B specification standardises topic and data format in this scenario.

Decoupling MES from other systems

The MES, the energy management system and an analytics platform can each consume the same data; no change is needed in the source system. Adding a new consumer is simply adding a subscription.

Common Mistakes

  • Building the topic hierarchy without a plan: a consistent structure such as site/line/machine/signal should be set from the start.
  • Sending everything with QoS 2: broker and network load increase needlessly.
  • Not putting a timestamp in the payload: the real time of a delayed message cannot be known.
  • Leaving the broker as a single point: if production monitoring depends on the broker, redundancy is essential.
  • Opening it to the production network without TLS and authorisation.

Frequently Asked Questions

What is an MQTT broker, and where does it sit in a factory?
The broker is the central message server where publishers and subscribers meet. It usually runs in the factory server room or on an edge device; sensors and gateways publish to it, and the MES and reporting systems subscribe. It can be clustered for high availability.
Is MQTT data secure?
The protocol itself does not include encryption; security is provided by TLS at the transport layer, by username/password or certificate authentication, and by topic-based authorisation on the broker. A broker without TLS and with anonymous access should not be used on a production network.
What is Sparkplug B?
Sparkplug B is a specification on top of MQTT that standardises the topic structure, data format and device online/offline status reporting for industrial data. It is used so that devices from different manufacturers speak consistently on the same broker.

MQTT in EFFIX MES

The EFFIX MES data collection layer can subscribe to sensor, counter and gateway data published over MQTT; protocols such as OPC UA, Modbus, EtherNet/IP and MTConnect are also supported in the same layer. Counter and status data collected through the Inolink wireless IoT network are passed to machine monitoring screens and the OEE calculation; energy measurements are tracked in kWh and m³ through the SEM energy management system integration. Incoming values are evaluated by Proactive Alert System detectors, which generate notifications when thresholds are exceeded. For details, see the EFFIX MES page or request a demo.