Marcio Cunha

How to integrate legacy factory systems with MQTT and Node-RED

Learn how to connect older factory floor machines to modern web dashboards using MQTT and Node-RED without replacing existing hardware.

Marcio Cunha•4 min
Also available in:PortuguêsEspañol
Summary
  • Older industrial protocols isolate data in local silos that hinder real-time remote reading
  • The MQTT protocol works as a lightweight messaging hub that consumes minimal bandwidth in unstable factory networks
  • Node-RED translates binary signals and complex PLC registers into JSON readable by web browsers
  • Proper use of decoupled flows prevents IT network failures from bringing down critical factory floor controls
  • Modern web dashboards can display machine status instantly after proper protocol conversion

The challenge of connecting older machinery to the industrial internet

Visitors to traditional manufacturing plants quickly realize that many machines have been running perfectly for decades, yet they operate in complete digital isolation. These devices typically rely on proprietary protocols or older standards, such as Modbus RTU over RS-485 serial cables, which were created long before connecting a drill press to the internet was even a concept. In practice, this means engineers and managers must physically walk to the machine panel to write down production counters or check error codes, wasting valuable time.

Modernizing a factory by replacing all machinery with brand-new equipment is financially unviable for most businesses. The good news is that automation engineering makes it possible to build an intermediate layer of lightweight software and hardware to extract data from these legacy systems. Much like addressing performance bottlenecks in slow legacy systems, we must plan industrial data extraction by calculating return on investment without interrupting daily manufacturing output.

Understanding the role of MQTT in factory floor communication

To send data from an isolated machine to a web server in the cloud or on a local network, we need a communication protocol suited for noisy industrial environments and unstable connections. MQTT, which stands for Message Queuing Telemetry Transport, acts like an extremely efficient mail carrier that delivers messages using very little bandwidth. It operates on a publish-subscribe model where a machine publishes information to a specific topic, and any interested system simply listens to that topic without burdening the source device.

Unlike traditional HTTP requests that constantly open and close connections and cause sluggishness, MQTT maintains a lightweight, persistent channel with a central broker. In practice, this means that if the factory Wi-Fi blips for a few seconds, the protocol handles automatic reconnection and ensures essential telemetry packets are not lost along the way. This resilience is reminiscent of partition-tolerant distributed systems, where applications must keep running even when the primary network link suffers physical instability.

Structuring PLC data reading using Node-RED

Node-RED is a visual programming tool based on blocks connected by wires that greatly simplifies system integration without requiring thousands of lines of complex code. Originally developed by IBM, it runs seamlessly on small, low-cost computers installed right on the factory floor, such as a Raspberry Pi or an industrial mini PC. Inside Node-RED, we can install specific packages to communicate directly with programmable logic controllers, known as PLCs, which are the electronic brains controlling assembly line motors and sensors.

The workflow starts with a polling block that requests memory registers from the PLC using serial ports or industrial Ethernet networks. Next, we transform these raw numbers into structured messages in JSON format, which is the universal standard understood by any modern web programming language. To ensure this software bridge does not suffer from memory crashes or processing spikes, many architects apply best practices similar to those used in tuning concurrent database connections, limiting the volume of simultaneous requests sent to legacy hardware.

Implementing the data pipeline from PLC to web dashboard

To get hands-on and structure data collection for an assembly line, we can follow a logical configuration sequence directly inside the Node-RED environment. This approach ensures that industrial protocol conversion happens in an orderly and secure manner before exposing information in visual dashboards for machine operators.

  1. Install Node-RED on the local factory server and add industrial communication nodes compatible with your PLC, such as the Modbus TCP node.
  2. Configure the IP address of the legacy machine and define the memory register addresses containing current temperature and production count.
  3. Add a JavaScript function block to convert raw binary data into a clean, readable JSON object.
  4. Connect this object to an MQTT output node configured to periodically send the message to the local network broker.
  5. Create a visual interface using dashboard nodes or connect an external web application to listen to the real-time MQTT topic.

The code snippet below illustrates how a simple function inside Node-RED processes raw payload data received from an industrial register and prepares it for publication:

// Example script executed inside a Node-RED function node
let rawValue = msg.payload;
// The PLC sends temperature multiplied by 10 to avoid decimals
let actualTemperature = rawValue[0] / 10.0;

msg.payload = {
    machineId: