# Modbus Read

This function block reads data from a Modbus server (coils or registers) using a provided Modbus client connection. Use the on-screen controls to select the target address, the number of values to read, and the Modbus data type.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Enable` A boolean gate to allow or prevent reading. When False the block will not perform a read and returns no data.

`Modbus Client` Provide a Modbus client connection object (usually coming from a `Modbus Connect` block). The block uses this client to communicate with the server.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Data` The read result as a generic list. For register reads this is a list of numeric register values; for coil/discrete reads this is a list of boolean values. If reading fails or is disabled, output is empty/None.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Address` Enter the start address (integer) on the Modbus device to read from.

`Quantity` Enter how many consecutive items (registers or coils) to read.

`Data Type` Choose the Modbus data type to read: Coil, Discrete Input, Input Register, or Holding Register.

## 🎯 Features <a href="#features" id="features"></a>

* Supports reading both bit-based (coils/discrete inputs) and word-based (input/holding registers) data types.
* Uses an external Modbus client connection provided to the `Modbus Client` input, keeping communication separate from the block’s settings.
* Simple numeric and boolean results are returned as a list suitable for logging, plotting, or downstream processing.
* Built-in error reporting surfaces communication failures so you can react (reconnect, retry, alert).

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

When active, the block checks the `Enable` input and requires a valid client on the `Modbus Client` input. It reads the configured address range using the selected `Data Type` and returns the values on the `Data` output. If the read fails or the block is disabled, it returns no data and logs a helpful error message.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Use `Modbus Connect` to create and provide the required `Modbus Client` connection.
* Use `Logic Input` or `Rising Edge` to control when reads happen (manual trigger or single-shot reads).
* To write values back to a device, combine with the `Modbus Write` block.
* Log readings for later review using `CSV Export` or persist them with `Data Write Local` / `Data Write Global`.
* Visualize numeric outputs in real time by feeding numeric results into the `Scope` block.
* Use `Debug Input` to inspect and verify the returned `Data` during setup and troubleshooting.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* No data returned: ensure a valid client is connected to the `Modbus Client` input and `Enable` is True.
* Wrong values or partial reads: check `Address` and `Quantity` are within the device’s address map and within device limits.
* Communication errors: verify network/serial settings via the `Modbus Connect` block and ensure no other application is blocking access.
* Unexpected data format: confirm you selected the correct `Data Type` (coils vs registers) for the values you expect.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/input-output/communication/modbus-read.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
