# Modbus Master

Modbus Master is an application that allows full operation of devices connected to the gateway over Modbus RTU and Modbus TCP/IP. Also, the application allows sending data to the server via MQTT, TCP/IP JSON and saving to storage.

---

### Configuration of Modbus Master

To open Modbus master, go to **Modbus &gt; Modbus Master**

Add Slave Device in Modbus Slave Devices

[![ag-221-web-modbusmaster-start.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-start.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-start.png)

Enter a slave device name of your choice &amp; Select communication protocol.

[![AG-221-web-modbusmaster-advanceSettingsAlert.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/TEaag-221-web-modbusmaster-advancesettingsalert.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/TEaag-221-web-modbusmaster-advancesettingsalert.png)

#### Modbus RTU

Need to enter the serial port configuration according to the slave device. In AG-221 is for RS485 **dev/ttyS1**.

**/dev/ttyS1 = RS485**

[![ag-221-web-modbusmaster-serial.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-serial.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-serial.png)

Change the baud-rate according to your slave device requirement. In Modbus RTU 9600 baud-rate is most common used.

[![AG-221-web-modbusmaster-baudrate.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-baudrate.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-baudrate.png)

Data bits are used to represent each character or data unit in a communication protocol. Select the appropriate setting.

[![AG-221-web-modbusmaster-databit.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-databit.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-databit.png)

Parity is an error-checking mechanism to detect data transmission errors. Most devices use the **None** option.

[![AG-221-web-modbusmaster-parity.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/xbBag-221-web-modbusmaster-parity.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/xbBag-221-web-modbusmaster-parity.png)

A stop bit signals the end of a data frame, helping the receiver recognize when one byte is complete.

- 1 Stop Bit: For stable connections and higher speed.
- 2 Stop Bits: For increased reliability or when devices need more processing time.

Select the option according to the slave device.

[![AG-221-web-modbusmaster-stopbit.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-stopbit.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-stopbit.png)

#### Modbus TCP/IP

In Modbus TCP/IP, only the IP address and port number (typically 502) are required for communication.

[![AG-221-web-modbusmaster-tcp.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-tcp.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-tcp.png)

### Modbus slave

<p class="callout info">After entering these parameters, the next configuration steps are the same for both Modbus TCP and Modbus RTU.</p>

You should enter the slave ID (1-255), polling interval, and request timeout according to your requirements.

[![ag-221-web-modbusmaster-slaveidpollingrequest.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-slaveidpollingrequest.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-slaveidpollingrequest.png)

---

##### Query Configuration

To make a Query, click on **ADD QUERY**

[![AG-221-web-modbusmaster-rtu2.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-rtu2.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-rtu2.png)

Enter the **Function code**, **Start Address**, Register/Coil number as per the Slave documentation or instruction. Here 1-50 register/coil quantity is supported.

[![AG-221-web-modbusmaster-Query1.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-query1.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-query1.png)

##### Parameter Configuration

Enter and select the option as per your requirement.

[![AG-221-web-modbusmaster-parameter2.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-parameter2.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-parameter2.png)

[![AG-221-web-modbusmaster-parameter1.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-parameter1.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-parameter1.png)

[![AG-221-web-modbusmaster-parameter.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-parameter.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-parameter.png)

Click on **SAVE** after entering and selecting the Parameters.

This is how we can configure Modbus and view the details.  
And for another slave do the same process by click on **ADD SLAVE DEVICE.**

[![ag-221-web-modbusmaster-save-modbusconfig.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-save-modbusconfig.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-save-modbusconfig.png)

---

### Data output configuration  


Click on Output configuration. There are two option:

1. Save Data to File.
2. Send Data to Server.

We can choose both options and then the data is both sent to the server and saved locally.

[![ag-221-web-modbusmaster-outputconfig.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-outputconfig.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-outputconfig.png)

If Save Data to File is selected, it is necessary to specify the folder path.

#### Send data to server

In Send Data to Server. There are 2 option:

- ATRA-DATA
- 3rd-PARTY-PLATFORM

Atra-Data is Atreyo's system for quick and easy presentation of data in the cloud. In the case of 3rd-PARTY-PLATFORM, we can choose any data platform that communicates using one of the selected ports: HTTP, MQTT or TCP/IP.

##### ATRA-DATA

ATRA-DATA. In This Data is send direct to the ATRA server without any aditional configuration.

[![ag-221-web-modbusmaster-outputconfig1.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-outputconfig1.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-outputconfig1.png)

##### 3rd-PARTY-PLATFORM. 

There are some parameter required to select protocol – HTTP, MQTT, TCP/IP.

[![ag-221-web-modbusmaster-outputconfig-select.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-outputconfig-select.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-outputconfig-select.png)

##### HTTP(s)

Enter the URL For HTTP Post and Header. Where able to Change default header or add new one if needed.

[![ag-221-web-modbusmaster-outputconfig2.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-outputconfig2.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-outputconfig2.png)

##### Certificates

To enhance security for data transmission, you can use **certificate-based TLS** along with **credentials**.  
**Certificate-based TLS (Transport Layer Security)** require **CA(Certificate Authorities)** file, **Client Certificate** and **Private key**   
Credentials often require a username and password for authentication and access control in secure systems.

[![ag-221-web-modbusmaster-outputconfig-certificates.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-outputconfig-certificates.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-outputconfig-certificates.png)

##### MQTT

Enter the Server **Hostname/IP**, **Server Port**, **Publish Topic** and **Subscribe Topic**. Select **QoS level** as per requirement and Client ID it is Auto-generate.

[![ag-221-web-modbusmaster-outputconfig-mqtt-cert.png](https://docs.atreyo.in/uploads/images/gallery/2025-12/scaled-1680-/ag-221-web-modbusmaster-outputconfig-mqtt-cert.png)](https://docs.atreyo.in/uploads/images/gallery/2025-12/ag-221-web-modbusmaster-outputconfig-mqtt-cert.png)

QoS (Quality of Service) level

- QoS 0 (At most once): Fast, no acknowledgment, possible message loss.
- QoS 1 (At least once): Acknowledged, possible duplicates.
- QoS 2 (Exactly once): Highest reliability, no duplicates, uses a four-step handshake.