> For the complete documentation index, see [llms.txt](https://support.powerio.com/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.powerio.com/hub/codesys-hvac/en/hvac-bacnet2-library/beispiele/bacnet-einrichtung-in-codesys.md).

# BACnet setup in CODESYS

In order for the BACnet library to be used, the BACnet IP datalink and the BACnet Server must first be set up in CODESYS.

## BACnet IP datalink

{% stepper %}
{% step %}
**Add Ethernet interface**

In the device tree, the device *Ethernet* is attached. This defines the physical interface for BACnet communication.

<div align="left"><figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-08b36a7446046c77f09decba8918ab0191cbee40%2FScreenshot%202025-11-18%20at%2017.01.59.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Configure Ethernet interface**

Now the device is configured; the IP address of the target device (i.e. your own CPU) must be specified. The IP address of the other BACnet participant is determined communicatively (*Who-Is* – query via broadcast telegram X.255).

<div align="left"><figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-d9e4fd0a204003305402d8107c11777d8de04869%2FScreenshot%202025-11-18%20at%2017.03.17.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Add BACnet IP datalink**

In the device tree, below the device *Ethernet* the device *BACnet IP datalink* is attached.

<div align="left"><figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-98fba4898188ab88f3a9d98fb60de096c9d589f8%2FScreenshot%202025-11-18%20at%2017.05.23.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Configure BACnet IP datalink**

It primarily defines the BACnet network number and the UDP port used (default: 47808).

<div align="left"><figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-825ea0a3f42e07d68505fad44d5b28e66daf44c4%2FScreenshot%202025-11-18%20at%2017.08.02.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}
{% endstepper %}

## BACnet Server

{% stepper %}
{% step %}
**Add BACnet Server**

In the device tree, the device *BACnet Server* is attached. It serves as the BACnet communication center and must always be present. The client-server principle is used. The client reads/writes data that the server provides.

<div align="left"><figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-c932f2fe70358f469800422c5a470b586a85d83b%2FScreenshot%202025-11-18%20at%2017.09.58.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Configure BACnet Server**

The target device (our CPU) can be operated both as a BACnet Server and as a BACnet Client (even simultaneously).\
When operating as a BACnet Server, the objects (e.g. a temperature actual value of the target device) are attached as devices below the BACnet Server. When operating as a BACnet Client, the objects are defined in CFC.\
\
It defines the character set used (UTF8) and the option *AutoStart* (automatic start of BACnet communication) is defined

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-9529df514107b1aff45d490be870723fe8766bd6%2FScreenshot%202025-11-18%20at%2017.12.25.png?alt=media" alt=""><figcaption></figcaption></figure>

Furthermore, the properties of the object *Device* (i.e. of your own BACnet Server) can be set, which can then be read by another BACnet participant.

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-9c492a43f42ee08f27d8dab125d5b45234ef296c%2FScreenshot%202025-11-18%20at%2017.15.23.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-bacnet2-library/beispiele/bacnet-einrichtung-in-codesys.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
