BACnet in ten minutes
BACnet is the open protocol building automation systems use to talk to each other: controllers, thermostats, meters, lighting panels and the operator workstations that monitor them. This page explains the ideas the rest of the manual assumes, using the device the Quick Start builds as the example. If you already know BACnet, skip to the Quick Start; the Glossary defines every term used in the manual.
Devices, objects and properties
Section titled “Devices, objects and properties”Everything a BACnet product exposes is described by one model:
- A device is one BACnet product on the network: a controller, a sensor, a gateway. Each has a device instance, a number from 0 to 4194302 that must be unique on the whole site. The Quick Start device is instance 389001.
- A device contains objects. Each object models one thing: a temperature input, a fan output, a schedule, the device itself. An object has a type (Analog Input, Binary Output, Schedule, Device and so on) and an instance number that is unique among the objects of that type in the device. Type and instance together are the object identifier, written as “Analog Input 1”.
- An object has properties: named values such as Object_Name, Present_Value and Units. Every BACnet value a client can read or write is a property of an object.
The Quick Start device has three objects:
| Object | What it models | Properties a client reads |
|---|---|---|
| Device 389001 | The product itself | Object_Name, Vendor_Name, Vendor_Identifier, Model_Name, the list of objects |
| Network Port 1 | Its BACnet/IP connection | IP_Address, IP_Subnet_Mask, BACnet_IP_UDP_Port |
| Analog Input 1 | A temperature reading | Object_Name, Present_Value, Units (degrees Celsius) |
In code, object types and properties are numbers. Analog Input is object type 0 and Present_Value is property 85, for example. The Enumerations reference lists every value, and Objects and properties has a page for each object type.
Some objects can be commanded: several clients may write an output at different priorities, from 1 (highest) to 16, and the highest-priority value wins. Serving property values explains how the stack handles it.
Services
Section titled “Services”Devices act on each other through services, the requests and replies BACnet defines. The ones every device meets first:
| Service | What it does |
|---|---|
| Who-Is and I-Am | A client broadcasts Who-Is to find devices; each device answers with I-Am, giving its device instance. |
| Who-Has and I-Have | A client asks which device has an object with a given name or identifier. |
| ReadProperty, ReadPropertyMultiple | Read one property, or many in one request. |
| WriteProperty, WritePropertyMultiple | Write one property, or many. |
| SubscribeCOV | Ask to be told when a value changes (change of value, COV), instead of polling. |
A confirmed service expects a reply, and the sender retries if none arrives. An unconfirmed service,
such as Who-Is, does not. Your device lists the services it supports in its Protocol_Services_Supported
property; with the stack you choose them with BACnetStack_SetServiceEnabled().
Networks and data links
Section titled “Networks and data links”A data link carries BACnet messages between devices. The stack supports four:
- BACnet/IP sends messages in UDP datagrams, normally on port 47808, on an ordinary IP network.
- MS/TP runs on an RS-485 serial bus. Devices take turns by passing a token, and each has a one-byte MAC address.
- BACnet/IPv6 sends the same messages in UDP datagrams over IPv6, using multicast where BACnet/IP uses broadcast. The Data links overview covers its connection string.
- BACnet/SC (Secure Connect) carries messages over TLS-secured WebSockets, through a hub.
Each data link a device uses is described by a Network Port object. A building usually has several BACnet networks, each with its own network number, joined by routers. A broadcast such as Who-Is does not cross an IP router by itself; a BBMD forwards it between IP subnets. The Data links overview covers all of this from your application’s side.
What the stack does, and what your application does
Section titled “What the stack does, and what your application does”The CAS BACnet Stack implements the protocol: it decodes requests, applies the rules for every object and service, keeps the state BACnet requires (COV subscriptions, alarm states, trend logs, pending changes) and encodes the replies. Your application keeps doing what it already does, and connects it to BACnet:
- It owns the data. When a client reads Analog Input 1’s Present_Value, the stack calls your callback and you return the temperature. When the value changes, you tell the stack, so it can notify subscribers.
- It owns the transport. The stack opens no sockets or serial ports. It hands you each message to send, and you hand it each message you receive.
- It drives the stack. You call
BACnetStack_Tick()in your main loop; incoming messages, timers and retries are processed there.
Stack lifecycle describes that loop in full.
Before you ship a product
Section titled “Before you ship a product”A few BACnet decisions belong to your product, not to the stack:
- A vendor identifier. Every BACnet vendor has a number, assigned by ASHRAE, that its devices report in Vendor_Identifier. Chipkin’s examples use Chipkin’s; your product needs your own.
- Device instances. Make the device instance configurable on site, because it must be unique across the whole building.
- What to expose. Choose the objects, properties and services your product needs. BACnet groups them into device profiles such as B-ASC (application specific controller) and B-SS (smart sensor), each a set of BIBBs (BACnet interoperability building blocks) that the device must support. Configuration presets shows how to build the stack for one.
- Certification. If you plan to certify the product, the BACnet Testing Laboratories (BTL) test it against the profile you claim, and you describe its capabilities in a PICS (protocol implementation conformance statement).
Next: Quick Start.