> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/input-output/communication/siemens-s7-read.md).

# Siemens S7 Read

This function block reads data from a Siemens S7 PLC database (DB) and outputs the value for use elsewhere in your scenario. It supports common PLC data types and offers a simple UI to define the DB number, byte address and data type. Use the `Enable` input to trigger reads and provide a connected `S7 Client` from a connection block.

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

`Enable` — Input socket used to turn reading on or off. Provide a boolean signal (for example from a `Logic Input` block) to control when reads happen.

`S7 Client` — Input socket that accepts a client/connection object (typically provided by a `Siemens S7 Connect` block). This tells the block which PLC/server to talk to.

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

`Data` — Output socket that provides the read value from the PLC. The value type depends on the selected data type (number, string, boolean list, etc.).

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

`DB Number` — Enter the DB (data block) number to read from.

`DB Byte Address` — Enter the byte offset inside the DB where the requested value starts.

`DB Data Type` — Dropdown to select the data type to read (examples: Boolean, Int, DInt, Real, String, Word, DWord, Time, ...).

`Connection Type` — Dropdown to choose connection mode (examples: Sync or Async). Use this to control how the block shares/uses a PLC connection with other blocks.

## ⚙️ How it runs <a href="#running-mechanism" id="running-mechanism"></a>

* When the `Enable` input is active, the block reads the value at the configured `DB Number` and `DB Byte Address` using the selected `DB Data Type` and immediately outputs it on the `Data` socket.
* The block expects a connected `S7 Client` provided to its input. If the client is not connected the block reports a connection error and will not output data.
* The `Connection Type` setting controls whether this block uses a shared (synchronous) connection or a dedicated/asynchronous connection when interacting with the PLC. Choose the mode that fits your setup (see Tips and Tricks).

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

* Supports many common PLC types: Boolean arrays, integers (SInt/Int/DInt), unsigned types, floating values (Real/LReal), strings, word/dword, and time types.
* Simple UI controls for DB number / byte address and data type selection.
* Connection mode selection to fit scenarios where multiple blocks access the same PLC.
* Returns data in a desktop-friendly format for immediate use by other blocks.

## 📝 Usage instructions <a href="#usage" id="usage"></a>

1. Add a `Siemens S7 Connect` block and configure the PLC address and connection parameters there.
2. Provide the output of the `Siemens S7 Connect` block to the `S7 Client` input of this block.
3. Set the target `DB Number` and `DB Byte Address` using the controls.
4. Choose the correct `DB Data Type` that matches the PLC variable you want to read.
5. Use a `Logic Input` or other boolean signal to the `Enable` input to control when reads occur.
6. Consume the `Data` output with visualization, logging or decision blocks.

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

* Combine with `Siemens S7 Connect` to manage the PLC connection centrally — it supplies the client object this block expects on the `S7 Client` input.
* Use `Logic Input` to enable/disable periodic reads or to implement on-demand reading.
* If you want to visualize numeric trends, feed the numeric `Data` output into a `Scope` block for live plotting.
* To save readings for later analysis, send the `Data` output into `Data to JSON` and `CSV Export` blocks.
* Send telemetry downstream by connecting `Data` to `MQTT Publish` for cloud monitoring or to `Send Mail` (via a structured message) for alerts.
* Share read results across a scenario using `Data Write Global` / `Data Read Global` or local memory blocks so other parts of your system can react without re-reading the PLC.
* For debugging, use `Debug Input` to log the output value and verify addresses and data types.
* If multiple blocks read/write the same DB area, try switching the `Connection Type` to `Sync` to avoid concurrency issues.
* When reading text fields, be mindful of string length and encoding on the PLC. Verify the expected length in the PLC DB to avoid truncated results.

(hint: Useful blocks to combine: `Siemens S7 Connect`, `Logic Input`, `Number Input`, `Data to JSON`, `CSV Export`, `MQTT Publish`, `Scope`, `Debug Input`, `Data Write Global`)

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

* No data or connection error: Verify the PLC is reachable and that the `Siemens S7 Connect` block shows a successful connection. Check network addresses, firewalls and PLC status.
* Wrong value returned: Confirm the correct `DB Number`, `DB Byte Address` and `DB Data Type` match the variable layout in the PLC DB. Off-by-one byte offsets or incorrect data type selection cause invalid results.
* Partial or truncated string: Ensure the PLC string length matches expectations. If a string appears cut, check the configured length on the PLC side.
* Intermittent reads or busy server warnings: If the PLC is servicing many requests, try using `Sync` connection mode for coordinated access or slow down read frequency.
* Unexpected boolean result: Some boolean reads return groups of bits — treat them as collections of boolean values when appropriate.

If problems persist, add a `Debug Input` block to view raw returned values and feed the results into logging or export blocks to capture failing cases for analysis.
