# Connect devices via Modbus

## About Modbus

The *Modbus*-protocol is a widely used communication protocol that was developed in 1979 by *Gould-Modicon* It was developed. 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 transmission can take place using one of three variants: **ASCII**, **RTU** or **TCP**.

In *Eliona* are mainly **Modbus TCP** as well as **RTU over TCP** used, but the platform also supports other schemes such as **UDP** and **RTU over UDP**, to enable flexible integration of older or special devices.

***

## Modbus TCP

With *Modbus TCP* data transmission takes place over 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.
* Transfers these requests to the Modbus client interface.
* Usually, the client is 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.
* Usually, the server is the device that provides the data (e.g. a PLC or a sensor).

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

***

## Procedure for connecting devices via Modbus

To connect devices via Modbus with *Eliona* follow these steps:

1. #### Connect to a Modbus server (slave)

   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* server. These requests are used for **read** or **write** reading registers on the server.

   * **read**: The client reads certain 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* client.
3. #### Specify a unique device address (ID)

   Each 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 requests are sent to the correct device.

***

## Internal Modbus versions in Eliona

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

* **Modbus TCP**: Enables communication over 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.
