Modbus gateways: connecting Modbus TCP and RTU devices

Modbus Gateways is the ideal IoT solution for remote access and management of Modbus data via the cloud.

Companies around the world are realizing that digital transformation is the key to faster, automated and more efficient operations. Since Modbus is a widely used communication protocol in equipment and industrial environments, companies that want to integrate their processes with the latest technologies, pull data from their machines, equipment and systems, are looking to Modbus gateways to achieve this.

What is Modbus?

Modbus is a popular communication protocol or messaging structure widely used in industrial automation and control systems to transfer data between devices. The Modbus protocol allows devices in an industrial network, to exchange information with each other in a standardized format. It should also be noted that the Modbus protocol is independent of the underlying physical layer.

Why is Modbus so popular?

The popularity of Modbus can be summed up in a few words: simple, open, robust and flexible,

  • Simple:The protocol has a very well-defined structure in terms of rules for the request-response model. This means that there is a certain way to make a request for information and a consistent way to get a response with the requested data. In the sense that when you implement it and follow the rules, the device will always be easy to troubleshoot and know what your error was,
  • Open: Since its inception, Modbus has been widely available as an open standard, meaning manufacturers have been able to build it into their devices without paying licensing fees. Its ability to be incorporated into many types of devices from different manufacturers and vendors has contributed to its wide acceptance and adoption, making it a reliable and well-known data transmission protocol today,
  • Solid: Despite its simplicity, the Modbus protocol offers a number of advanced features that make it ideal for use in industrial automation and control installations. Modbus uses cyclic redundancy check (CRC) as part of its error checking mechanism to ensure accurate and reliable data transmission,
  • Flexible:Modbus can be used on different physical media or layers, such as RS-232, RS-485 and Ethernet. This makes it suitable for use in a wide range of industrial environments, from small local networks to large distributed systems. Different Modbus data types are used to represent different types of information in the system, such as coils, discrete inputs, input registers and storage registers
  • Examples of Modbus devices

    Because of their popularity in the market, there are now hundreds of thousands of Modbus devices available. These can be simple things such as motor controllers that control a garage door, sensors or industrial components and machines such as:

  • Programmable Logic Controllers (PLCs),
  • Remote Terminal Units (RTUs),
  • Power meters,
  • Flow meters,
  • Motor drives,
  • Valves and Actuators,
  • Photovoltaic Inverters,
  • Battery charging circuits,
  • Power conditioning units,
  • Energy storage systems,
  • Environmental sensors, for monitoring, for example, temperature, humidity and pressure
  • Modbus 3onedata gateway

    Is Modbus RTU the same as Modbus TCP?

    The simple answer to this common question is: No. The Modbus RTUs are the same as Modbus TCP. Although they are related and have some similarities, the physical layer or interface is independent of the protocol and can therefore be different. In this case, one is RTU (Remote Terminal Unit) and the other is TCP (Transmission Control Protocol).

    In Modbus RTU, the physical layer is a serial communication protocol that uses a binary representation of data. Although there are several standard transports, the most common are RS232 and RS485. RS232 is the predecessor to RS485, which was developed to allow longer distances, higher speeds and the ability to signal multiple devices. Modbus RTU uses a client-server architecture, where a single clinet device sends commands to one or more server devices, which respond with data. Modbus RTU is commonly supported by legacy devices and is used in industrial automation, building control systems and other applications requiring long-distance communication.

    Modbus TCP (also known as Modbus IP and Modbus TCP/IP) uses a TCP/IP network for communication between Modbus devices. It is an extension of Modbus RTU, which is used by Ethernet or other IP-based networks. Modbus TCP is often used to connect Modbus devices over longer distances or to integrate Modbus networks with other types of networks. Unlike Modbus RTU, the more modern Modbus TCP allows for multiple clients (devices that initiate and control communication with servers) and has the ability to send parameters such as point name, resolution, units, etc. Modbus TCP is more common at the enterprise level, IoT applications or utility-scale applications where there are relatively newer devices that can connect to the network.

    Because of its wide applicability and diversity of applications, Modbus is present in a wide variety of hardware and software configurations that may not even be compatible with each other. Modbus gateways are particularly useful in these scenarios for integrating different systems.

    What are Modbus gateways and how do they work?

    Modbus gateways are devices that act as a bridge to retrieve data from individual Modbus devices in the environment, collect the data and - using a GSM modem - send it to a cloud application and database over the Internet. In other words, the gateway stores the Modbus pattern and enables seamless data transfer to clarify the situation in the environment by collecting data from individual devices and publishing messages to the cloud so that people can later use the data as information.

    In an environment, Modbus gateways essentially act as a client that instructs Modbus devices on the network to send the requested data so that the user can see it. Communication is bidirectional, which also allows remote management of the device over the Internet. Since most Modbus devices do not have direct access to the Internet, a Modbus Gateway is needed to connect Modbus devices to the cloud.

    The Modbus Gateway works by receiving data from devices on the Modbus network, converting it to a format that can be understood by cloud applications, and sending it to the IoT platform. The gateway can also perform other tasks such as data filtering, protocol conversion or signal buffering to ensure accurate and reliable data transmission.

    It may be counterintuitive, but even with a Modbus TCP device, you will still need a Modbus Gateway to establish communication and get data to the cloud because the communication protocol is different, even though the physical layer is on Ethernet. To establish a connection with these Modbus devices, the gateway will "speak Modbus," but then, to send data to the cloud, it will use a different application layer (e.g. HTTPS, MQTT, etc.).

    Are there different forms and configurations of Modbus gateways?

    When selecting and configuring a Modbus gateway, it is important to consider that they are available in different forms and can be configured to meet specific user requirements. The first decision to make, based on the devices in the environment, is whether you need a Modbus gateway RTU or Modbus TCP.

    Next, since the gateway can be used in a variety of configurations, including single, multiple and network configurations, the correct configuration must be set for each Modbus gateway to successfully communicate with devices in the field. The proper configuration depends on the specific requirements of the system and devices in the environment.

    Some important Modbus communication parameters

  • Data model: Both devices use the same four types of information: coils, discrete inputs, input registers and holding registers,
  • Coils:Coils are binary registers that can store the value 1 or 0. They are used to represent the on/off state and are typically used for control signals,
  • Discrete inputs: Discrete inputs are binary registers that represent the status of an input, such as the state of a sensor,
  • Input registers: Input registers are 16-bit registers that store read-only data, such as sensor readings or other input values,
  • Storage registers:Storage registers are 16-bit registers that store read and write data, such as controller settings or other output values,
  • Addressing: Both protocols use the same addressing scheme to access data. This includes the device address, the function code and the starting address for the data to be accessed (also known as the register),
  • Read and write commands: Both protocols support read and write commands to access data. For example, the "read holding registers" command can be used by both Modbus RTU and Modbus TCP to read data from device registers,
  • Data format: Both protocols use 16- and 32-bit data formats to represent data. Modbus TCP also supports 8- and 64-bit data formats,
  • For Modbus RTU, there are several communication parameters:

  • Baud rate: Modbus is designed to operate in the range of 1200 - 115,200 Kbps. Baud rate is otherwise known as the "speed" of data transmission in an RS-485 network,
  • Data bits: Data transmitted in frames on the Modbus network. Modbus RTU typically uses 8 data bits (7 is rarely used),
  • Stop bits: Stop bits determine the number of bits used to signal the end of a data character. Modbus RTU typically uses 1 stop bit, it can also be 2,
  • Parity: Error control setting. This parameter can be set to none, even or odd. Most devices usually do not use parity,
  • Device address: Used to specify the address of a Modbus device on the network. It is also known as the server ID. Modbus RTU supports device addresses in the range of 1-254,
  • Timeout limit: specifies the length of time a device will wait for a response from another device before assuming that communication has failed,
  • Response delay: determines the length of time a device waits before responding to a Modbus command
  • Typical communication parameters for Modbus TCP gateways:

  • IP address: is a unique identifier assigned to each device on the network and is used to determine the Modbus TCP device address,.
  • Unit ID: is an overarching addressing type in the Modbus protocol and is commonly used in devices connected to multiple Modbus devices. For example, in some solar inverters, Unit ID: 1 is used for device information and Unit ID: 2 for system parameters and measurements.
  • These configuration parameters are important from the perspective of setting up and configuring Modbus RTU devices, so they can be adjusted to optimize communication between devices. If devices on the same Modbus RTU or TCP network have parameters set to different values, they cannot communicate with each other.

    What are the benefits of using a Modbus gateway?

    Modbus gateways IoT provide the ability to connect remote devices to a mobile or web application for monitoring and control. With the information gathered from connected devices, stakeholders can, for example, optimize the device, utilize it efficiently, reduce costs, respond to clients faster and provide a better client experience.

    Additionally, Modbus gateways are typically less costly than other industrial communication solutions and can be a cost-effective way to improve system connectivity and compatibility.

    Furthermore, IoT gateways provide reliable communication and can handle large amounts of data, making them suitable for a variety of automation applications in several industries.

    Finally, the Modbus Gateway allows for greater flexibility in system design. For example, if there is a need to connect multiple Modbus RTU devices to a central control system or application, a single gateway can be used to achieve this.

    In this sense, the Modbus Gateway is a versatile and powerful solution for connecting remote devices to a central control system. If you want to upgrade your business or connect an existing system, the Modbus gateway is an excellent choice.

    What important features should you look for in Modbus gateways?

    Key features to look for in a Modbus gateway include:

  • Ease: Configuration and management to add new devices, registers and security parameters should be easy through a user-friendly interface. Downloaded information and any errors should be easily visible to the user for troubleshooting,
  • Response: During the discovery phase - especially when connecting a new Modbus device - the gateway user should be able to immediately see the result of their action and be able to iterate to quickly make sure they are dealing with the right information. Getting the information quickly in the form of a visual indication will help the user solve any problem,
  • Scalability: When the decision is made to scale up or remove devices from the network, the gateway should be able to do so without complexity, with the same flow and experience, and without affecting other devices on the network,
  • Flexibility: The gateway should be able to handle and support different baud rates, parity settings and other parameters to enable greater compatibility with a wider range of devices and applications,
  • Reliability: The gateway should provide reliable operation, enabling wireless updates (OTA) and monitoring 24/7

  • What are the potential applications and use cases for Modbus gateways?

    Modbus gateways have many potential applications and use cases in various industries. The best use cases for customers always involve particularly important equipment or devices that are critical to their business, and therefore should be monitored continuously and in real time to receive alerts and take immediate action in case of problems or irregularities.

    The following are two examples of potential use cases:

  • Monitoring and controlling solar energy systems:
  • The Modbus gateway can be used to monitor the performance of solar panels (photovoltaics), inverters, battery systems and metering systems connected to the same solar network. Through the gateway, users can collect key inputs for all devices on the solar grid, optimize their output and use surplus energy in their own system. For example, the extra energy can be used to run boilers, heaters or set a lower temperature in the refrigerator when it doesn't make sense to sell energy back to the grid,

  • Track sales revenue and product quality with flow meters:
  • Modbus gateways can be used in the beverage and chemical industries where there are flow meters and pumps that require real-time monitoring to collect and analyze key data.