> 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/serial-write.md).

# Serial Write

This function block sends raw data over a selected serial connection. It is built for simple, non-blocking transmissions and provides convenient UI options to convert common data types, append line endings, and control re-transmission behavior.

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

`Enable` Use to enable or disable sending. When false the block does not send data.

`Data` The payload to send. Accepts numbers, text, lists, booleans or byte-like values depending on selected controls.

`ConnId` Identifier of the serial connection to use. Provide the connection id produced by a connection manager block.

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

This function block does not produce outputs.

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

`Data Type` Choose how the provided `Data` will be converted before sending. Common choices include string, integer, float, boolean, and byte/hex formats.

`Line ending` Select a trailing sequence to append to the payload. Options typically include LF, CRLF, CR or none.

`Send policy` Choose when to transmit:

* `On change` only sends when the final byte payload differs from the last sent payload.
* `Always` sends every time the block is evaluated and enabled.

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

* Data type conversion for common formats, so you can input human-friendly values and the block will send the corresponding byte sequence.
* Optional configurable line ending to match remote device expectations.
* Send policy to avoid repeating identical messages when not needed.
* Non-blocking write behavior so the flow keeps running while data is transmitted.
* Works with external connection manager blocks that provide `ConnId` values.

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

When the block is evaluated:

1. If the `Enable` input is inactive or empty, nothing is sent.
2. If valid `Data` and `ConnId` are present, the block converts `Data` according to the selected `Data Type` and appends the chosen `Line ending`.
3. If `Send policy` is `On change`, the block compares the prepared payload to the previous payload and skips sending if identical.
4. The prepared byte payload is sent to the serial connection referenced by `ConnId` without blocking the rest of the system.

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

1. Create or select a serial connection and note its connection id.
2. Provide that id to the `ConnId` input.
3. Feed the value you want to send into the `Data` input.
4. Set the `Data Type` control to match your data (for example use `HexBytes` for hex strings or `Bytes` for raw byte lists).
5. Choose the desired `Line ending` if the receiving device expects one.
6. Use `Send policy` to avoid unnecessary repeats when streaming constant values.
7. Toggle `Enable` to start or stop sending.

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

* Combine with `Serial Connect` / connection manager blocks (the system's connection manager) to obtain and manage `ConnId` values.
* Use `String Input` or `Number Input` blocks to prepare and validate the `Data` before sending.
* Pre-format complex payloads with `String Merge` or `Data to JSON` when you need structured strings (for example JSON messages).
* If you need to log or export sent data, add `CSV Export` or `Image Logger` (for visual logs) downstream in your flow.
* For conditional sending based on logic, combine with `Logic Input`, `And`, `Or`, or `Greater` blocks to gate transmissions.
* For protocol bridges, pair with `MQTT Publish` or `REST API - Post` to forward serial data to network services.
* Use `Debug Input` to inspect the outgoing payloads during development.

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

* Nothing is sent: verify `Enable` is active, `Data` is not empty, and `ConnId` references an active connection.
* Receiving device ignores messages: check the chosen `Line ending` and try different options (LF, CRLF, CR or none).
* Identical messages not sent when expected: confirm `Send policy` is set to `Always` if you need repeated sends.
* Unexpected bytes on the wire: ensure `Data Type` matches the value format you provide (for example use `HexBytes` for hex strings or `Bytes` for numeric lists).
