How the serial RS485/RS232 communicates with the MQTT protocol via gateway

How the serial RS485/RS232 communicates with the MQTT protocol via gateway

The contemporary industrial scenario is marked by a dilemma: the coexistence of legacy assets, rugged and fully functional, installed decades ago, with the urgent need to adopt the principles of smart automation. The challenge is to optimize efficiency and competitiveness, which requires the visibility of operations in real time.

The complete replacement of these old equipment with modern connected equipment is, in most cases, impractical due to the capital costs and the prolonged downtime necessary for installation. Thus, modernization, also known as industrial retrofit, emerges as the most viable and sustainable alternative, as it allows extending the useful life of the equipment only by updating the controls and connectivity.

To meet this need, the Altus’ TLE IoT gateway can be implemented as a digital bridge for industrial transformation, connecting the existing equipment's machine-to-machine (M2M) communication to the IIoT universe.

The focus of this article is to detail how TLE performs protocol conversion intelligently and securely.This analysis is based on the communication triad that defines the retrofit of legacy systems: the physical layer (serial RS-485/232), the field application protocol (Modbus), and the most modern and scalable standard (MQTT). Follow this analysis in the next paragraphs.

The scope of the digital bridge

Serial protocols have been the physical basis of automation for decades, known for their simplicity and stability in adverse environments. TLE offers support for both RS-232 and RS-485, covering different distance and topology needs on the factory floor.  

RS-232 is an asynchronous and full-duplex serial data communication standard,which means it can transmit and receive data simultaneously. Historically, it was common in short-distance applications, such as the connection between a computer (DTE) and a modem (DCE).  

However, RS-232 has critical limitations in modern industrial environments, especially due to its unbalanced transmission, which makes it highly susceptible to electromagnetic noise, and a distance restriction for which it was designed. Despite these limitations, the physical support for RS-232 on TLE helps ensure compatibility with legacy control instruments or equipment located close to the gateway, such as scales or meters.  

RS-485, on the other hand, is the standard that enables data collection in large installations. Unlike 232, it was designed for rugged and reliable communications in noisy environments. One of its greatest advantages is its range, supporting cables up to 1,200 meters, ideal for covering extensive industrial plants.. Furthermore, it maintains transmission speeds between 9.6 Kbps and 115.2 Kbps.  

The differentiator of RS-485 in a retrofit architecture is its multi-point communication capability. This enables connecting multiple equipment (Slaves) on a single pair of wires.

Modbus Serial: the universal language of automation

Modbus is a universally recognized application protocol in automation, being the "language" that travels over the physical layer RS-232 or RS-485. It is widely used in PLCs, meters, HMIs, and other industrial equipment.  

There are two main variants of serial Modbus:

  • Modbus RTU: this variant is the most efficient, as it uses compact binary coding and the error checking system (CRC) to ensure data integrity. Due to its high efficiency, it is the most recommended form for most applications.

  • Modbus ASCII: uses ASCII characters for data representation. Although it is more legible for operators, it is less efficient, requiring twice the equipment to transmit the same content. Its application is restricted to equipment that do not support the RTU format.  

The main limitation of Modbus lies in its communication model based on polling (master-slave). In this format, the master equipment needs to periodically consult the slave to obtain status updates or register values. This process generates repetitive traffic, consumes bandwidth, and adds latency, contrasting directly with the efficiency and event-driven flow of IIoT protocols.

MQTT: optimized and scalable connectivity for IIoT systems

MQTT (Message Queuing Telemetry Transportwas developed to solve the communication challenges in environments with restricted bandwidth and high latency, as is the case with cellular networks.

The main difference between MQTT and serial protocols lies in the communication architecture. While Modbus is master-slave and TCP is client-server, MQTT adopts the Publish/Subscribe model.

The main components of this architecture are:

  • Broker (Server): is the central equipment responsible for receiving all messages, filtering them by topics (subjects), and distributing them. The broker allows for temporal and geographical disengagement between the participating equipment.

  • Publisher: sends the payload with the translated data to a specific Topic (for example: factory/machine/status/vibration).

  • Subscriber: destination applications, such as Cloud platforms (AWS, Google Cloud) or SCADA systems, which subscribe to the Topics of interest to receive only the relevant data.  

The advantage of this model is its scalability and efficiency: the Publisher does not need to know who or how many Subscribers exist, and vice-versa. Data is sent only when it occurs (event-driven model), eliminating the need for constant polling on the network.

However, the most critical factor for the application of MQTT in telemetry is its lightness. The protocol was designed to operate with low processing capacity and limited internet. A minimum header of only two bytes is necessary for message control. For industrial data, the guarantee of delivery is imperative.

MQTT addresses this need with the Quality of Service (QoS) functionality, which is supported by our TLE gateway:

  • QoS 0 (At Most Once): the message is sent without confirmation of receipt. Fast, but there is no guarantee of delivery.

  • - QoS 1 (At Least Once): the message is delivered, at least, once, using an acknowledgment mechanism. Ideal for important process data where occasional duplication is acceptable.  

  • QoS 2 (Exactly Once): guarantees that the message is delivered uniquely, through a two-step handshake. Essential for critical commands, such as control commands or safety alarms, where loss or duplication is intolerable.  

The ability to select the appropriate QoS enables TLE to be configured to manage the criticality of each data separately: routine temperature data can use QoS 0 or 1, while remote emergency commands must use QoS 2 to ensure operational safety.

Watch our complete playlist of TLE tutorials

TLE as an edge intelligence center

TLE is an IoT gateway that concentrates multiple functions, going beyond simple protocol translation to offer resilience, rugged connectivity, and integrated security. Designed for rigorous environments, TLE has a rugged metal alloy casing in compliance with the IP30 protection level,ensuring durability against impacts and vibrations.

The physical interfaces are key to a successful retrofit:  

  • Serial: 1x RS-232/RS-485, essential for collecting legacy data.

  • Ethernet: 1x 10/100Mbps for local Modbus TCP and LAN connection.

  • - Digital I/O: 1 digital input (DI, Logic 1: 5~30Vdc) and 1 digital output (DO, Relay 24Vdc/300mA), which support the creation of alarm triggering rules or the direct reading of sensors. 

  • Storage: MicroSD Slot, fundamental for data logging. 

  • Dual Micro SIM: enables for failover configuration. If the gateway detects the drop of the SIM-A connection (for example, carrier failure), it automatically performs the dynamic anti-disconnection switch to SIM-B. This redundancy mechanism ensures that WAN connectivity maintains high availability.

  • LTE Cat 4 Module (3G/4G/LTE): the main WAN interface that supports local connectivity via LAN-WIFI 802.11n 1T1R (2.4GHz).  

Check out our webinar with all the details about the TLE's connectivity.

Converting Serial Connections to IoT

TLE's main function is protocol translation, transforming structured Modbus data into the lightweight and scalable MQTT format.

In the most common conversion scenario, Modbus RTU → Modbus TCP/MQTT, TLE begins the verification. It acts as a Modbus Master, reading the legacy data from the Modbus RTU Slave connected via RS-485. TLE then maps these values into lightweight data units. For example, a Modbus register that contains the temperature of a motor is collected and translated internally: the numerical value is encapsulated in a payload (it can be JSON format or pure string) and logically structured into an MQTT Topic, such as, for example, clients/altus_factory/motor_x/temperature.

However, it is important to remember that in telemetry environments that rely on the cellular network, the loss of connection, even if brief, is a constant threat that can create data gaps and compromise predictive maintenance analysis.

TLE solves this vulnerability with advanced data logging functions that use local storage (MicroSD card). The most important feature for this is the off-line Proxy mode.

When TLE detects that it has lost the connection with MQTT (via WAN), it assumes the function of Modbus Master, continuing to check (act as a Proxy) the serial Slaves. The collected data is immediately stored locally, in a store-and-forward mechanism. This functionality ensures that no process data will be lost during the interruption of WAN connectivity, drastically minimizing the operational risk associated with cellular network dependency. As soon as TLE re-establishes the connection (thanks to Dual SIM), it re-sends the stored data to MQTT, filling the gaps in the history.

TLE also supports Sniffer Mode, which monitors and logs Modbus traffic for diagnostic purposes. In addition, TLE’s versatility is further reinforced by its support for multiple communication protocols, going beyond Modbus and MQTT.

The gateway also supports the Virtual COM mode (RFC2217, TCP Client/Server/UDP). The Virtual COM enables engineering systems and legacy PC applications, which were originally designed to connect to a serial device through a local physical COM port, to continue functioning. TLE maps the remote serial device to a virtual COM port on the technician's PC via the IP network. This functionality eliminates the need to rewrite old engineering software, ensuring total interoperability and facilitating maintenance.  

Asset optimization and predictive maintenance

TLE can unlock hidden productivity from legacy equipment. By converting static data from Modbus registers into a continuous MQTT stream, many companies achieve real-time visibility of the factory floor for the first time.  

The main strategic benefit is the possibility of migrating from corrective maintenance (based on failures) or preventive maintenance (based on time intervals) to predictive maintenance (based on condition).

For example, the continuous monitoring of a vibration value via a Modbus sensor (collected by TLE and published via MQTT) enables cloud algorithms to detect anomalies at the initial stage, triggering an intervention before the failure itself occurs. This anticipation of problems results in process optimization and cost reduction, minimizing waste in all stages of the operation.

O investimento em inteligência de campo nunca foi tão acessível!

Aproveite a oportunidade de adquirir o gateway TLE com uma condição de preço especial, válida somente até o final deste mês de outubro. Converta o custo potencial de uma falha inesperada em um investimento estratégico de longo prazo que impulsionará a eficiência e a competitividade da sua empresa.

Share

Learn more