# Connect Devices via Modbus

## About Modbus

The *Modbus* protocol is a widely used communication protocol that was developed in 1979 by *Gould-Modicon*. It is based on a **client-server architecture**, in which a *master* device (usually a computer) is connected to one or more *slave* devices. This protocol makes it possible to monitor and control various measuring devices from a central system. Data transfer can take place via one of three variants: **ASCII**, **RTU**, or **TCP**.

In *Eliona*, **Modbus TCP** and **RTU over TCP** are mainly used; however, the platform also offers support for other schemes such as **UDP** and **RTU over UDP** to enable the flexible integration of older or special devices.

***

## Modbus TCP

With *Modbus TCP*, data is transferred via Ethernet in binary form using TCP/IP packets. The **standard port 502** is reserved for this purpose. For older devices with serial interfaces, a protocol converter or router can be used to integrate them into the TCP system.

***

## Roles in the Modbus Protocol

### Modbus Client (Master)

* Communicates with a remote device.
* Sends Modbus requests that are controlled by the application.
* Transmits these requests to the Modbus client interface.
* The client is usually the device that retrieves the data (e.g., a PC or Modbus Poll).

### Modbus Server (Slave)

* Waits for Modbus requests (via TCP port 502).
* Reads and processes these requests.
* Returns Modbus response messages.
* The server is usually the device that provides the data (e.g., a PLC or a sensor).

{% hint style="info" %}
Every *slave* has a unique address in the range of **1 to 247**.
{% endhint %}

***

## Procedure for Connecting Devices via Modbus

To connect devices to *Eliona* via Modbus, follow these steps:

#### Establish a connection to a Modbus server (slave)

1. To establish a connection to a *Modbus server* (slave), you need the **IP address** and the **port** of the server. The standard port for Modbus TCP is **502**.
2. **Read or write registers**

   After the connection has been successfully established, the *Modbus client* (master) can send requests to the *Modbus server*. These requests are used to **read** or **write** registers on the server.

   * **Read**: The client reads specific values from the server's register addresses.
   * **Write**: The client sends data and writes it to the server's registers. ⚠ **Note**: All requests are initiated by the *client*.
3. **Specify a unique device address (ID)**

   Every device in the Modbus network has a unique **address (ID)** in the range of **1 to 247**. This ID must be specified when configuring the client to ensure that the requests are sent to the correct device.

***

## Internal Modbus Versions in BuildingPro Suites

In *Eliona*, several Modbus protocols are supported to integrate different device types and networks:

* **Modbus TCP**: Enables communication via Ethernet with the standard port **502**.
* **RTU over TCP**: Enables the integration of devices with the older RTU protocol via a TCP connection.
* **UDP**: Provides a connectionless transmission option for Modbus messages.
* **RTU over UDP**: Uses the RTU protocol over UDP to integrate devices with low connection overhead into the network.
