# Modbus TCP

## **Data Source Endpoint**

* Format: `plcIP:plcPort`
* Default port: `502`
* Example: `192.168.2.2:502`

## **Data Tag Address**

* Use the **register** location in the holding register.
* Examples: `"452"` or `"12"`

## **Modbus Options** (provided in JSON format)

Modbus also accepts the following fields as options

<figure><img src="https://352909507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNT40XJFAFlAhUX8CcQS%2Fuploads%2Fgit-blob-8c6593973c5e7a4960cb0c3fa6211a6dde3c25cf%2FScreenshot%202024-06-12%20at%202.45.18%E2%80%AFPM.png?alt=media" alt=""><figcaption></figcaption></figure>

* **scale**: Multiplies the read value for scaling. Example: `"scale": 0.0001`
* **functionCode**: Specifies the register type:
  * `3`: Input Registers
  * `4`: Holding Registers\
    Example: `"functionCode": 3`
* **bytesToRead**: Defines the number of bytes to read. Example: `"bytesToRead": 2`
* **dataType**: Converts the read data to the specified type (default is `UInt16`). Accepted types:\
  `['int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64', 'float', 'double', 'utf8', 'ascii']`\
  Example: `"dataType": "int32"`
* **endianness**: Sets byte order (default is Big Endian `BE`). Options: `"BE"` or `"LE"`\
  Example: `"endianness": "BE"`
* **decimals**: Rounds floating-point values to limit decimal places (useful for precision errors).

**Example JSON Configuration**

```json
{
  "scale": 0.0001,
  "functionCode": 3,
  "bytesToRead": 2,
  "dataType": "int32",
  "endianness": "BE"
}
```
