Transferring Data from Modbus to MQTT Broker for Advanced IIoT Data Use Cases
This article covers what is Modbus, why it is such a popular factory machine communication protocol, what is Modbus TCP, how does that compare to MQTT on different data use cases, how the two protocols can work together to enable IIoT use cases to benefit manufacturing customers.
Modbus is an open-source, royalty-free, de-facto standard for industrial communication protocols used widely by manufacturers to connect software and electronic devices.
Modicon (now Schneider Electric) originally published Modbus in 1979 to use with its programmable logic controllers (PLCs). It is still one of the most popular serial communication systems between PLC, Distributed Control Systems(DCS), controllers, sensors, actuators, field devices, and interfaces.
There are many variants of the Modbus protocol. Modbus TCP is a variant used for communications over Transport Control Protocol/Internet Protocol (TCP/IP) networks. The Modbus TCP Client-Server (Master-Slave) model caters to many applications. However, with the advent of concepts such as Industry 4.0, Industrial Internet of Things(IIoT), 3G/4G, and geographically distributed wireless devices, the use of Modbus TCP has been challenging. Manufacturers are finding that combining the power of Modbus’ open-source industrial communication with the power of MQTT, which is more suitable for IIoT use cases, is very powerful.
How ModBus TCP works
MQTT is a standard binary publish-subscribe-based messaging protocol designed for fast and reliable data transport between devices and an enterprise, especially under very constrained conditions. Constrained conditions could be unreliable network connectivity, limited bandwidth and limited battery power, or similar. MQTT is built on top of TCP/IP and is ideal for IIoT use cases. It is used across applications, including manufacturing, to connect Operations Technology (OT) data to Information Technology(IT) data.
The following diagram represents an MQTT system’s components, including clients that could be publishers or subscribers and a central MQTT broker.
How MQTT works
Combining Modbus TCP with MQTT enables advanced data analytics use cases by ensuring the right data is available in a timely manner. Before we can talk about how the power of these two protocols can be combined, let’s explore some of the fundamental differences between them.
Modbus TCP Vs. MQTT
Modbus TCP is a point-to-point connection client server-based protocol that doesn’t need any intermediaries. This works well in on-premise machine-to-machine communication but doesn’t scale for machine-to-enterprise or cloud use cases. This is where MQTT excels.
As a publish-subscribe based protocol, MQTT manages connections between publishers and subscribers efficiently through a broker. This is ideal for enterprise data movement as it bridges data between OT and IT systems.
Here is a table summarizing which protocol is preferred based on the use case.
Use case | Modbus TCP | MQTT |
---|---|---|
Factory on-premise communication with spotty or no internet access | Ideal | Yes |
Connecting globally distributed systems | Yes | Ideal |
Complex network architecture with changing addresses or unknown addresses | No | Ideal |
Simple network architecture with static addresses | Ideal | Yes |
Data security or access control needed | No | Yes |
Scalability is needed | Possible | Ideal |
ACK needed for requests and response | Ideal | Yes |
Ability to send data without waiting for a request | No | Ideal |
Unreliable network connectivity, limited bandwidth, limited battery power | No | Ideal |
Small on-premise system communication with a controlled number of connections | Ideal | Yes |
Sending data to the enterprise or cloud software like AWS, Azure, and GCP | No | Yes |
As illustrated in the above comparison, Modbus TCP is an ideal protocol for on-premise machine-to-machine or machine-to-application use cases. Contrarily, MQTT is ideal for on premise to enterprise or on premise to cloud data communication to support IIoT use cases. The combination of the two protocols can be a potent union as manufacturers have realized.
As seen from the MQTT architecture above, any MQTT client can send data to an MQTT broker. For a Modbus TCP data source to send data to an MQTT broker, that data must first be translated to MQTT and then passed through an MQTT client. There are multiple ways to achieve that.
The first method would be using a hardware device like an IIoT gateway. For example, the groov EPIC from Opto22 can support the ability to talk Modbus TCP protocol on the southbound, convert that to MQTT, and then send the data through an MQTT client to an MQTT broker.
Architecture showing how Modbus TCP data can be ingested into an MQTT broker via IIoT gateway hardware
The second method uses IIoT software modules from vendors like N3uron, which can be loaded onto the customer’s servers. This method achieves the same outcome as using an IIoT gateway hardware.
Architecture showing how Modbus TCP data can be ingested into an MQTT broker via software modules
Choosing the IoT Protocol that Suits the Customer’s Needs
Both Modbus TCP and MQTT have advantages and disadvantages. Weighing these differences and the specific manufacturing deployment needs will help determine which one or combination to employ. In the instance where combining these makes sense, you bridge the data between the two systems to get the best of both worlds.
HiveMQ offers an enterprise-grade MQTT data broker that offers scalable, reliable, and secure bidirectional data movement for IIoT use cases, including manufacturing. As we talked about, there are several challenges to IIoT data collection and movement, especially when bridging data efficiently from OT systems to IT systems. MQTT Data brokers like HiveMQ play a vital role in ensuring that the data is collected and is available for advanced instances that allow organizations to fully benefit from Industry 4.0 and IIoT technologies.
Additional Reading
Read the blog MQTT Vs. HTTP for IoT to learn the differences between MQTT and HTTP protocol or if you are contemplating using MQTT or HTTP for your use case.
Read the blog MQTT Vs. AMQP for IoT to learn the differences between MQTT and AMQP protocol.
Read the blog MQTT Vs. CoAP for IoT to learn the differences between MQTT and CoAP protocol.
Read the blog Understanding the Differences between MQTT and WebSockets for IoT to explore how MQTT and WebSockets are not really in competition with each other, but complementary
Ravi Subramanyan
Ravi Subramanyan, Director of Industry Solutions, Manufacturing at HiveMQ, has extensive experience delivering high-quality products and services that have generated revenues and cost savings of over $10B for companies such as Motorola, GE, Bosch, and Weir. Ravi has successfully launched products, established branding, and created product advertisements and marketing campaigns for global and regional business teams.