# Modbus and Serial Configuration

The Gateway has a very advanced Modbus master application with a convenient graphical interface. Below are the capabilities of the application:

- Modbus TCP/IP and Modbus RTU support.
- Any number of serial ports
- Support for external USB/serial interfaces
- JSON, TCP/IP and MQTT string formation
- Data logging in the event of no connection to a server
- Storage of all data in internal memory

> The Modbus Master application is optimized for industrial use, allowing you to easily configure communication parameter, define polling schedules, and integrate Modbus data into your automation or monitoring workflows.

<p class="callout info">A detailed guide to **Modbus Master** configuration is available [here.](https://docs.atreyo.in/books/modbus-master/page/modbus-master-562)</p>

---

#### 1.1 Modbus Fundamentals

Modbus is an industrial communication protocol used to exchange data between a client/master and one or more server/slave devices. The client starts the request and the server returns the requested data. This guide only covers the Modbus TCP and Modbus RTU functions used by this Modbus Master application.

<table id="bkmrk-modbus-tcp-uses-ethe" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 28%;">**Modbus TCP**</td><td>Uses Ethernet/TCP networking. Configure the slave IP address and TCP port. Port `502` is the standard Modbus TCP port.</td></tr><tr><td style="width: 28%;">**Modbus RTU**</td><td>Uses a serial communication link such as RS-485. Configure the serial port and the serial communication settings to match the slave.</td></tr></tbody></table>

<p class="callout info">**Always start with the slave manufacturer's Modbus map.** It tells you the communication settings, slave/unit address, function code, register/coil address, quantity and data format required for that device.</p>

#### 1.2 Select the Communication Method

<table id="bkmrk-requirement-use-what" style="border-collapse: collapse; width: 100%;"><thead><tr><th>Requirement</th><th>Use</th><th>What the user connects/configures</th></tr></thead><tbody><tr><td>Slave is on an Ethernet/IP network</td><td>**Modbus TCP**</td><td>AG-702 Ethernet → network/switch → Modbus TCP slave; configure IP address and port.</td></tr><tr><td>Slave is a field device on a serial bus</td><td>**Modbus RTU over RS-485**</td><td>AG-702 RS-485 → RS-485 slave bus; configure serial port, baudrate, data bits, parity, stop bits and slave ID.</td></tr><tr><td>Slave requires point-to-point serial</td><td>**Modbus RTU over RS-232**</td><td>Use the AG-702 RS-232 interface only when the slave and application support that serial interface.</td></tr></tbody></table>

<p class="callout success">**Do not mix the settings.** Modbus TCP uses an IP connection; Modbus RTU uses serial communication parameters.</p>

#### 1.3 Wiring &amp; physical connections

Use the examples below as connection patterns. Exact connector names and polarity markings must always be checked against the connected device's own hardware manual.

##### Example A — Modbus RTU over RS-485 (2-wire)

[![tw-wire-rs485-wiring.png](https://docs.atreyo.in/uploads/images/gallery/2026-10/scaled-1680-/tw-wire-rs485-wiring.png)](https://docs.atreyo.in/uploads/images/gallery/2026-10/tw-wire-rs485-wiring.png)

<table id="bkmrk-use-use-the-ag-702-r" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 28%;">**Use**</td><td>Use the AG-702 RS-485 interface with a compatible Modbus RTU slave.</td></tr><tr><td style="width: 28%;">**Cable**</td><td>Use a twisted-pair cable suitable for RS-485. Keep the bus physically ordered and avoid unnecessary long stubs.</td></tr><tr><td style="width: 28%;">**Termination**</td><td>For a properly terminated bus, termination matches the cable impedance; Schneider recommends 100–120 Ω at the two physical ends of the RS-485 network where required.</td></tr><tr><td style="width: 28%;">**Biasing**</td><td>Failsafe biasing may be required when the bus can be left electrically idle. Only one node should provide the biasing.</td></tr></tbody></table>

##### Example B — Modbus RTU over RS-232 (point-to-point)

[![RS232-wiring-diagram.png](https://docs.atreyo.in/uploads/images/gallery/2026-10/scaled-1680-/rs232-wiring-diagram.png)](https://docs.atreyo.in/uploads/images/gallery/2026-10/rs232-wiring-diagram.png)

<p class="callout warning">**Important:** RS-232 is a point-to-point serial interface. Do not use an RS-485 bus wiring model on an RS-232 port. Match TX/RX/GND and the slave's serial parameters exactly as specified by the slave hardware manual.</p>

##### Example C — Modbus TCP over Ethernet

[![ethernet-wiring-diagram-modbus.png](https://docs.atreyo.in/uploads/images/gallery/2026-10/scaled-1680-/ethernet-wiring-diagram-modbus.png)](https://docs.atreyo.in/uploads/images/gallery/2026-10/ethernet-wiring-diagram-modbus.png)

<table id="bkmrk-use-connect-an-ag-70" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 28%;">**Use**</td><td>Connect an AG-702 Ethernet interface to the IP network containing the Modbus TCP slave.</td></tr><tr><td style="width: 28%;">**Configure**</td><td>Use the slave IP address and TCP port in the Modbus Master application. Port `502` is the standard Modbus TCP port.</td></tr></tbody></table>

### 2. Modbus Deployment Scenarios

These diagrams show how the AG-702 can collect data from multiple RS-485 Modbus RTU slaves and multiple Modbus TCP/IP slave devices.

#### 2.1 AG-702 Mixed TCP/IP &amp; RS-485 Deployment

[![modbus-tcp-ip-ethernet.png](https://docs.atreyo.in/uploads/images/gallery/2026-10/scaled-1680-/modbus-tcp-ip-ethernet.png)](https://docs.atreyo.in/uploads/images/gallery/2026-10/modbus-tcp-ip-ethernet.png)

In this example the AG-702 is the central Modbus Master. Five RTU slaves share one RS-485 daisy-chain connected directly to the AG-702 RS-485 port: three slaves are shown on the left and two on the right. Four separate TCP/IP slaves connect through the Ethernet network on the AG-702 LAN side.

<table id="bkmrk-rs-485-side-%E2%80%94-five-r" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 28%;">**RS-485 side — five RTU slaves**</td><td>- All five devices connect to the **AG-702 RS-485 port**.
- Three slaves are shown on the left and two on the right.
- All five share one RS-485 daisy-chain.
- Each slave has a unique Slave ID.

</td></tr><tr><td style="width: 28%;">**Ethernet side — four TCP/IP slaves**</td><td>- TCP/IP Slave A, B, C and D are **slave devices**.
- They connect to the AG-702 LAN through the same Ethernet network.
- Each slave has its own reachable IP address.
- They are **not gateways** in this example.

</td></tr></tbody></table>

<table id="bkmrk-device-group-physica" style="border-collapse: collapse; width: 100%;"><thead><tr><th>Device group</th><th>Physical connection</th><th>Protocol</th><th>Addressing</th></tr></thead><tbody><tr><td>RTU Slave 1–5</td><td>AG-702 RS-485 → shared A/B bus</td><td>Modbus RTU</td><td>Slave IDs 1–5</td></tr><tr><td>TCP/IP Slave A–D</td><td>AG-702 LAN → Ethernet network → slave</td><td>Modbus TCP</td><td>IP address + device/unit identifier as required</td></tr></tbody></table>

<p class="callout info">**Important:** RTU slaves are connected to the AG-702 RS-485 port. TCP/IP slaves are connected through the AG-702 Ethernet/LAN port. These are two separate physical communication paths.</p>

#### 2.2 RS-485 Daisy-Chain Wiring — Multi-Slave Field Example

A single AG-702 RS-485 port can serve multiple Modbus RTU slave devices on one shared two-wire bus. Connect **A (D+)** to **A (D+)** and **B (D−)** to **B (D−)** throughout the chain, assign a unique Slave ID to every device, and install a **120 Ω termination resistor between A and B** only at the two physical ends of the bus.

[![RS485-daisy-chain-wiring.png](https://docs.atreyo.in/uploads/images/gallery/2026-10/scaled-1680-/rs485-daisy-chain-wiring.png)](https://docs.atreyo.in/uploads/images/gallery/2026-10/rs485-daisy-chain-wiring.png)

<p class="callout success">**Important:** RS-485 is a shared two-wire bus. Keep the topology physically ordered as a daisy-chain, keep drop cables short, connect A to A and B to B consistently, and place 120 Ω termination resistors only at the two physical ends of the bus.</p>