> For the complete documentation index, see [llms.txt](https://docs.heisenware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heisenware.com/~/changes/eYCCpn9cCBKOYnZA6a8f/building-apps/data-integration/protocol-connectors/siemens-s7-wip.md).

# Siemens S7 (WIP)

## Introduction to Siemens S7 Protocol

The Siemens S7 protocol, also known as the S7comm protocol, is a communication protocol designed for Siemens PLCs (Programmable Logic Controllers). It allows for data exchange between PLCs and other devices within the same network, facilitating industrial automation processes. By utilising the S7 protocol, users can efficiently monitor, control, and retrieve data from their automation systems.

## Siemens S7 instance management

### Creating an S7 instance

Simply drag the `create` function onto the board, name your instance and trigger.

<figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2F3IbT7HxpuJYgouRu310f%2Fimage.png?alt=media&amp;token=536c0a49-bceb-43df-bce8-32c53279db26" alt="" width="563"><figcaption><p>Create an S7 instance</p></figcaption></figure>

### Deleting an S7 instance

Drag the `delete` function onto the board, insert the name of the instance to be deleted and trigger it.

<figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FNZyqtYA66PZ07NfuOoAV%2Fimage.png?alt=media&amp;token=515a6651-94bc-49b1-aaa3-d744948223b8" alt="" width="563"><figcaption><p>Delete an S7 instance</p></figcaption></figure>

## Siemens S7 functions

### Get connection status

With the `getStatus` function, you can read out the current connection status of the S7 connector.

### Initiate a connection

To establish a connection to a PLC use the `initiateConnection` function. There are a few parameters available for the connection.

<table><thead><tr><th width="128">Parameter</th><th width="111">Default</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td>host</td><td></td><td>String</td><td>The host to be contacted for the S7 connection.</td></tr><tr><td>port</td><td>102</td><td>number</td><td>The connection port. Change this if your endpoint is not using the standard port.</td></tr><tr><td>rack</td><td>0</td><td>number</td><td></td></tr><tr><td>slot</td><td>2</td><td>number</td><td></td></tr><tr><td>timeout</td><td>5000</td><td>number</td><td>Connection timeout in ms.</td></tr></tbody></table>

### Disconnect from the PLC

To drop the connection to the PLC, drag the `dropConnection` function onto the board and trigger it. This function simply terminates the TLC connection.

### setAddressDictionary

### Add items to internal read polling

The `addItems` function adds items to the internal read polling list. If items includes the value `_COMMERR` it will return the current communication status. Items can be a string or an array of strings.

### Remove items from internal read polling

The `removeItems` function removes items from the internal read polling list. Items can be a string or an array of strings.

{% hint style="warning" %}
If the items box is left empty, all items will be removed
{% endhint %}

### Write item-value pairs

Write items to the PLC with the `writeItems` function. If items is a single string, values should then be a single item. If items is an array of strings, values must also be an array of values of the same length.

The function returns true if the write was successful and false if it wasn't.

### Read out all item values

With the `readAllItems` function, you can read out all items on the read polling list. They will be returned as key value pairs.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.heisenware.com/~/changes/eYCCpn9cCBKOYnZA6a8f/building-apps/data-integration/protocol-connectors/siemens-s7-wip.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
