> For the complete documentation index, see [llms.txt](https://docs.yudash.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yudash.com/pf/si/modbus.md).

# Modbus/RS485

Modbus RTU is a widely used serial communication protocol for connecting industrial sensors, instruments, meters and PLCs.

YuDash dataloggers and IoT gateways can operate as a **Modbus RTU Master**, periodically reading data registers from one or more Modbus slave devices over RS485.

In this guide, a **FELYX datalogger** and an **XY-MD02 temperature and humidity transmitter** are used as the working example.

### Information required from the Modbus device

Before configuring a Modbus instrument, identify the following information from its datasheet or communication manual:

1. **Baud rate**
2. **Data bits, parity and stop bit**
3. **Modbus Slave ID**
4. **Register information**
   * register number or address
   * register/function type
   * data type and size
   * byte/word order, where applicable
   * scaling or factor, where applicable
5. **Addressing convention** — base-0 or base-1

These settings must match between the Modbus slave device and the YuDash datalogger.

### Modbus Register Mapping in YuDash Devices <a href="#h.jt0n9eorg4hg_l" id="h.jt0n9eorg4hg_l"></a>

For each value to be read from a Modbus slave, YuDash requires four main settings:

1. **Variable Name**
2. **Register Number**
3. **Type**
4. **Factor**

Together, these settings define **where the value is read from, how the register data is interpreted, and how the final value is represented in YuDash**.

#### 1. Variable Name

Each Modbus register value read by the device is stored as a named YuDash variable.

The variable name is used throughout the system for functions such as:

* Live Dashboard
* Data Logging
* Cloud Telemetry
* Data Scaling
* AXON Edge processing

Use short, descriptive variable names without spaces.

Examples:

`Temperature`\
`Humidity`\
`volt1`\
`machine_status`

In the FELYX example used later on this page, the XY-MD02 registers are mapped to the variables **Temperature** and **Humidity**.

#### 2. Register Number

The **Register Number** identifies the Modbus data location to be read.

Different Modbus register ranges correspond to different Modbus function codes.

| Function Code | Registers             | Range       |
| ------------- | --------------------- | ----------- |
| **1**         | **COIL STATUS**       | 0-9990      |
| **2**         | **INPUT STATUS**      | 10000-19999 |
| **4**         | **INPUT REGISTERS**   | 30000-39999 |
| **3**         | **HOLDING REGISTERS** | 40000-49999 |

**Register addressing: Base 0 and Base 1**

Modbus register addresses may be represented differently by instrument manuals and Modbus software.

YuDash configuration uses **base-0 / protocol addressing**. Some Modbus software displays registers using **base-1 / PLC addressing**, where the displayed register number is one higher.

For example:

`40000` in base-0 addressing corresponds to `40001` in base-1 addressing.

The same difference applies to other register ranges.

This becomes important when copying register numbers from software such as ModScan into YuDash configuration. Always check which addressing convention is being used.

> **Important:** Do not change a register number simply because it “looks different” from the instrument manual. First determine whether the manual or software is using base-0 or base-1 addressing.

We will demonstrate this later using the same XY-MD02 registers in **FELYX, Modbus Poll and ModScan**.

#### 3. Type

The **Type** setting tells YuDash how the data contained in the Modbus register should be interpreted.

It defines information such as:

* signed integer or floating-point data
* 16-bit, 32-bit or 64-bit values
* number of Modbus registers used by the value
* byte and word ordering
* byte-swapped representations

<table><thead><tr><th width="130">Type</th><th width="300.3333333333333">Description</th><th>No. of Registers read</th><th>Byte Sequence</th></tr></thead><tbody><tr><td>1</td><td>SIGNED INTEGER</td><td>1</td><td></td></tr><tr><td>2 or 20</td><td>Floating Point (LSB first)</td><td>2</td><td>CDAB</td></tr><tr><td>21</td><td>Floating Point (MSB first) </td><td>2</td><td>ABCD</td></tr><tr><td>22</td><td>32bit Integer (LSB first)</td><td>2</td><td>CDAB</td></tr><tr><td>23</td><td>32bit Integer (MSB first)</td><td>2</td><td>ABCD</td></tr><tr><td>24</td><td>32bit Unsigned Integer (LSB first)</td><td>2</td><td>CDAB</td></tr><tr><td>25</td><td>32bit Unsigned Integer (MSB first)</td><td>2</td><td>ABCD</td></tr><tr><td>11</td><td>Bit pattern Extraction</td><td>1</td><td></td></tr></tbody></table>

{% hint style="info" %}
YuDash also supports byte swapping for 32 bit registers. For these special case, we have to use 3 digit Type (by adding a suffix 1 to original type). It will enable byte swapping with same data type as corresponding 2 digit code: \
**201, 221, 241**: **DCBA** \
**211, 231, 251**: **BADC**

*Note: Support of code 24, 25 and 3 digit types is available in firmware V3.6 onwards.*
{% endhint %}

YuDash devices also support 64-bit IEEE-754 floating-point and signed integer values. A 64-bit value occupies four consecutive Modbus registers. Because different manufacturers use different terminology for byte and word order, YuDash represents the four 16-bit register words as **P, Q, R and S**.

Following are possible combinations:&#x20;

<table><thead><tr><th width="122">Type</th><th>Sequence</th><th>Type</th><th>Sequence</th><th>Data Type</th></tr></thead><tbody><tr><td><strong>4 or 40</strong></td><td>RSPQ</td><td><strong>401</strong></td><td>SRQP</td><td>Float 64</td></tr><tr><td><strong>41</strong></td><td>PQRS</td><td><strong>411</strong></td><td>QPSR</td><td>Float 64</td></tr><tr><td><strong>42</strong></td><td>RSPQ</td><td><strong>421</strong></td><td>SRQP</td><td>Int 64</td></tr><tr><td><strong>43</strong></td><td>PQRS</td><td><strong>431</strong></td><td>QPSR</td><td>Int 64</td></tr></tbody></table>

{% hint style="info" %}
YuDash internally converts acquired values to 32-bit floating-point values for further processing. Very large 32-bit integer or 64-bit values may therefore be subject to precision loss or overflow. Where appropriate, the **Factor** setting can be used to reduce the magnitude of the processed value.
{% endhint %}

#### 4. Factor

The **Factor** setting provides simple post-processing of the value after it is read from the Modbus register.

The acquired register value is:

**divided by the configured Factor**

A Factor of **1** leaves the value unchanged.

Factors such as **10** or **100** are commonly used when an instrument stores a decimal measurement as an integer.

For example, if an instrument represents:

**234.6 V as the integer `2346`**

then:

**Factor = 10**

gives:

`2346 ÷ 10 = 234.6`

This allows the YuDash variable to directly represent the engineering value shown by the instrument.

In the XY-MD02 example later on this page, the Temperature and Humidity registers use a **Factor of 100**.

{% hint style="info" %}
In most of industrial applications, MODSCAN (or similar) software is used to validate the Modbus settings. In case of any troubleshooting, we strongly suggest to validate the communication through MODSCAN. Our tutorial explains the mapping in reference of MODSCAN to LYNX settings.
{% endhint %}

### Example: Reading XY-MD02 over Modbus RTU

The **XY-MD02** is a temperature and humidity transmitter with **Modbus RTU / RS485** communication.

In this example, we use the same transmitter in three contexts:

* **ModScan** — to verify the device and inspect its Modbus registers
* **Modbus Poll** — to view the same registers using another Modbus test utility
* **FELYX** — to configure the transmitter as a Modbus slave and acquire its Temperature and Humidity values

This allows the register information seen on a PC to be directly related to the configuration used in FELYX.

### Verify XY-MD02 with ModScan

Before connecting the XY-MD02 to FELYX, the transmitter can be tested directly from a laptop using an **RS485-to-USB converter** and Modbus software.

This is useful for confirming the wiring, communication settings and register values independently of the datalogger. The test arrangement is:

**XY-MD02 → RS485-to-USB Converter → Laptop**

#### Wiring

Connect the XY-MD02 RS485 **A and B** terminals to the corresponding terminals of the RS485-to-USB converter. Power the XY-MD02 from a suitable DC supply and connect the USB converter to the laptop.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2Fgy8yOeUztaSxzUtffUHF%2F01_XYMD02_RS485_USB_Laptop_Wiring_AI.png?alt=media&amp;token=5b879483-5872-4f0d-87ca-68e24311204a" alt=""><figcaption></figcaption></figure>

ModScan can be used to communicate directly with the XY-MD02 and view its Modbus registers.

#### Select the Modbus data to read

Set Device ID `1`, select `04: INPUT REGISTER`, use Address `0002` and Length `2`.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FzCido2QK1qETbvLxiwDh%2F02_ModScan_Initial_Interface.png?alt=media&amp;token=9b508871-9dda-4f93-9f3e-d5aa4cd76fad" alt=""><figcaption></figcaption></figure>

#### Configure the serial connection

Select the COM port connected to the RS485-to-USB converter and use **9600 baud, 8N1**.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2F0CpsCZOJaJUqoAnXZpoE%2FConnection%20Details%20Configuration%20Highlight.png?alt=media&amp;token=02412559-fcab-4f73-81c9-2ff4bd9ef1a2" alt=""><figcaption></figcaption></figure>

These parameters must match the communication settings of the Modbus slave.

#### Read the Temperature and Humidity registers

Configure ModScan for:

| Setting           | Value              |
| ----------------- | ------------------ |
| Device ID         | 1                  |
| Modbus Point Type | 04: INPUT REGISTER |
| Address           | 0002               |
| Length            | 2                  |

ModScan then displays the two register values:

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FxOvSANasJO5D1N7H25XZ%2F04_ModScan_Input_Register_Read.png?alt=media&amp;token=5d7864fb-e5bf-4a7e-a017-b756e5f60e27" alt=""><figcaption></figcaption></figure>

With a Factor of 100, the displayed values `3048` and `6515` correspond to **30.48 °C** and **65.15 %RH**.

#### Display formats in ModScan

ModScan can display register contents in several formats:

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FNRuh3raFu42G5ybGtpx1%2F05_ModScan_Display_Types.png?alt=media&amp;token=21d118b5-c248-42c1-ac16-4474c8cc16f0" alt=""><figcaption></figcaption></figure>

The selected display format should match the data representation specified by the instrument manufacturer.

For the XY-MD02, the Temperature and Humidity values in this example are read as integer values and subsequently divided by 100.

### View XY-MD02 Registers in Modbus Poll

The same XY-MD02 can also be read using **Modbus Poll**. This provides another view of the communication settings, register definition and addressing convention.

#### Serial Connection Settings

Configure the serial port for **Modbus RTU, 9600 baud, 8 data bits, no parity and 1 stop bit**.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2F3VKSdHGdCBPuK6vwSYKF%2F06_ModbusPoll_Serial_Settings.png?alt=media&amp;token=a88f854c-cd89-44d6-b521-49bd50d50f2d" alt=""><figcaption></figcaption></figure>

#### Read Definition

Set the **Slave ID**, select **Function 04 — Read Input Registers**, and define the starting address and number of registers to read.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2F23MEh0J9OdFNKSTsrYFq%2F07_ModbusPoll_Read_Definition.png?alt=media&amp;token=31344130-5bba-4909-b54b-f2113eacfbcc" alt=""><figcaption></figcaption></figure>

#### Addressing and Data Format

Modbus Poll can display addresses using either **PLC Addresses (Base 1)** or **Protocol Addresses (Base 0)**.

For this example, use **Protocol Addresses (Base 0)**.

The same menu also provides different display formats such as Signed, Unsigned, Hex, Long, Float and Double.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FMs5lctYYGe6OmPTw4VPU%2F08_ModbusPoll_DataTypes_Base0.png?alt=media&amp;token=cb741ff6-ae6b-4e1a-a614-091549a17b7b" alt=""><figcaption></figcaption></figure>

#### Register Values

The two XY-MD02 input registers are then visible directly in Modbus Poll.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FbhEumcIjttBUyGyVQio9%2F09_ModbusPoll_Register_Values.png?alt=media&amp;token=786cc09c-df0b-46dd-a1b2-393d59db6451" alt=""><figcaption></figcaption></figure>

### Configure XY-MD02 with FELYX

After verifying the XY-MD02 registers using ModScan or Modbus Poll, the transmitter can be connected directly to FELYX and configured as a Modbus RTU slave device.

{% stepper %}
{% step %}

#### Connect XY-MD02 to FELYX

Connect the XY-MD02 to FELYX over RS485. In this demonstration, the XY-MD02 is also powered from FELYX using the loopback connection shown below.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2F81amUz5XJAS4ktGlyfQv%2F01_FELYX_XYMD02_RS485_Setup.png?alt=media&amp;token=1a387ff1-2091-4308-b529-da433a34acb9" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Open the Modbus Wizard

Open **Device Configuration** and select **Open Modbus #1 Wizard**.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FLUu7rCp8RMCaIv1JKvZJ%2F09_FELYX_Open_Modbus_Wizard.png?alt=media&amp;token=e18b14de-d693-451e-b8f3-13efb92e9de4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Configure the RS485 communication

Set the channel to **9600 baud, 8N1, Modbus RTU**, with **Read Try Count = 3**.

These settings must match the communication parameters configured in the Modbus slave.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FMS2jn8UHZwferl1ACNFr%2F10_FELYX_RS485_Settings.png?alt=media&amp;token=295651b9-f548-49ee-9214-ca5876e48258" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Add the XY-MD02 and map its registers

Add **Slave ID 1** and map **Temperature → 30001** and **Humidity → 30002**, both with **Type 1** and **Factor 100**.

`MD02` is used as the Sensor Name for identification.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FbvY1Lrf1NaDAIOTT1A9M%2F11_FELYX_Slave_Register_Mapping.png?alt=media&amp;token=83e82664-11d1-4225-819a-4ef3203423ff" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Enable Modbus

Under **Device Settings → Feature Settings**, enable **Modbus #1**.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2Fp6vRFSxsIA96XkQJaEBt%2F12_FELYX_Enable_Modbus.png?alt=media&amp;token=cc1e04ad-a522-4d13-9460-36c7111e9cae" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Apply the configuration and reboot

After enabling Modbus:

1. Select **Update and Preview**.
2. Review the updated configuration.
3. Select **Write Device Config**.
4. Select **Reboot Device**.

The device restarts with the new Modbus configuration.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FWLtsEQ9FgeRtZqn4lIPj%2F13_FELYX_Apply_Config_and_Reboot.png?alt=media&amp;token=5bb13995-2610-4ac9-b8b1-1ab20c19c4d0" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Verify the values on the Live Dashboard

After FELYX restarts, open the **Live Dashboard**.

The two configured variables should now appear under Sensor Data.

In the example shown:

* **Temperature:** `28.69`
* **Humidity:** `70.49`

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FJhZ67Wu1As10w9R5WsRP%2F14_FELYX_Live_Dashboard.png?alt=media&amp;token=7527a531-6901-48d6-8b87-2dc507411921" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

The complete acquisition path is:

```mermaid
flowchart LR
    A["XY-MD02"] --> B["RS485 / Modbus RTU"]
    B --> C["FELYX"]
    C --> D["Temperature & Humidity Variables"]
    D --> E["Live Dashboard"]
```

Once the variables are available in FELYX, they can also be used by other features such as **Data Logging, Cloud Telemetry, Data Scaling and AXON Edge processing**.
