Summary
- There is no single best protocol. Each was designed for a particular level of the building. A good architecture connects them instead of replacing them.
- KNX and DALI control the room, BACnet controls the building services, Modbus and M-Bus read meters, and MQTT and LoRaWAN carry sensor data to platforms.
- Occupancy data is an input signal for ventilation, lighting, cleaning and space utilisation. A head count gives more than a simple "motion / no motion" detector.
- Core functions stay local. The building must work without the internet. The cloud optimises, but it does not keep the lights on.
- Security is designed in from the start: a separate network for building systems, encrypted connections and device updates.
1. The three levels of building automation
| Level | What is there | Typical protocols |
|---|---|---|
| Field | Sensors, push buttons, actuators, luminaires, meters | KNX, DALI, Modbus RTU, M-Bus, LoRaWAN, EnOcean |
| Automation | Room and plant controllers, gateways | KNX, BACnet, Modbus TCP |
| Management | Building management system (BMS), analytics platforms, dashboards | BACnet/IP, MQTT, REST API, OPC UA |
The classic building protocols grew up on the two lower levels and are optimised for reliable local control. IoT protocols come from the top level and are optimised for moving data over IP networks. A smart building needs both.
2. The protocols in brief
KNX
An open standard for home and building automation (EN 50090, ISO/IEC 14543-3). Devices sit on a shared bus and communicate directly with each other through group addresses, without a central controller. If one device fails, the others keep working. The transmission media are twisted pair (TP), IP and radio (RF). It is configured with one common tool (ETS) for devices from all manufacturers. KNX Secure adds encryption and authentication, and KNX IoT gives external applications access to the data over IP.
Strengths: reliability, vendor independence, long installation life. Limitations: low bus speed, needs a certified integrator, not designed for large volumes of data.
BACnet
A building automation standard (ASHRAE 135, ISO 16484-5), widely used for heating, ventilation and air conditioning and as the common language of BMS systems. Data is represented as objects with properties, such as an analogue input or a schedule. It runs over IP (BACnet/IP) and over RS-485 (MS/TP) for older installations. BACnet/SC adds a secure connection over TLS.
Strengths: a rich data model, with schedules, alarms and trends in the standard itself. Limitations: more complex, and classic BACnet/IP relies on broadcast and has no built-in security.
Modbus
The simplest and most widespread industrial protocol. A master device reads and writes registers in the slaves, over RS-485 (RTU) or Ethernet (TCP). It is found in electricity meters, heat pumps, chillers and inverters.
Strengths: simple, cheap, supported everywhere. Limitations: no description of the data (you need the manufacturer's register map), no security, polling only.
DALI and DALI-2
A lighting control standard (IEC 62386). Each luminaire has an address, can be dimmed individually and can report its status. DALI-2 adds standardised input devices such as presence and light sensors. DALI lines are usually connected to KNX or BACnet through a gateway.
M-Bus and wireless M-Bus
A standard for remote reading of water, heat and electricity meters (EN 13757). It is used when the goal is allocating consumption costs, not real-time control.
MQTT
A lightweight messaging protocol based on publish and subscribe (an OASIS standard, ISO/IEC 20922). Devices publish messages on topics to a broker, and each application subscribes to the topics it is interested in. Sender and receiver do not know each other, which makes adding new consumers of the data easy.
- Delivery levels (QoS): 0 (at most once), 1 (at least once), 2 (exactly once).
- Retained messages: a new subscriber immediately receives the last value.
- Last will: the broker announces when a device drops off the network.
- Security: TLS and client authentication.
Strengths: small overhead, the connection is opened by the device (convenient behind a firewall), easy to scale. Limitations: the standard does not define message content, so topics and format have to be agreed. The broker is a critical point.
LoRaWAN
A wireless network with long range and very low power consumption. Sensors send small packets to a gateway, which forwards them to a network server. One gateway can cover a whole building, and sensors run for years on a battery. Messages are encrypted with AES-128.
Strengths: no cables, low cost per point, suitable for existing buildings. Limitations: small packets and infrequent transmission (in Europe there is a duty-cycle limit on airtime), so it is not suitable for real-time control.
REST API and webhooks
REST is how applications exchange data over HTTPS: one side asks, the other answers. A webhook is the opposite direction: the system sends a message by itself when an event occurs. They are used to connect platforms, for example an occupancy platform and a booking system.
3. Comparison
| Protocol | Main use | Model | Medium | Real time | Built-in security |
|---|---|---|---|---|---|
| KNX | Lighting, blinds, room climate | Decentralised, event-based | TP bus, IP, RF | Yes | KNX Secure |
| BACnet | HVAC plant, BMS | Objects, client and server | IP, RS-485 | Yes | BACnet/SC |
| Modbus | Meters and units | Register polling | RS-485, Ethernet | Yes | None |
| DALI-2 | Lighting | Addressable devices | Two-wire line | Yes | None |
| M-Bus | Consumption metering | Polling | Two-wire line, radio | No | Wireless variant |
| MQTT | Moving data to platforms | Publish and subscribe | IP | Near real time | TLS |
| LoRaWAN | Battery sensors | Star via gateway | Sub-1 GHz radio | No | AES-128 |
| REST | Connecting applications | Request and response | IP | No | TLS |
4. KNX or MQTT?
The question comes up often, but the two protocols are not alternatives. They solve different problems.
| If the task is | The right fit is | Why |
|---|---|---|
| A push button switches a lamp, a sensor controls blinds | KNX | Works locally and without a server, with guaranteed response |
| Data from hundreds of sensors reaches an analytics platform | MQTT | Lightweight, scalable, each application subscribes to what it needs |
| A new building with an automation design | KNX, with MQTT for data upstream | Control is in the bus, analysis is in the platform |
| An existing building without a bus | LoRaWAN and MQTT | No cabling, sensors are added step by step |
| A head count controls ventilation | Both | The count arrives via MQTT or API, the command is executed via KNX or BACnet |
The link between the two worlds is the gateway: a device or piece of software that translates KNX group addresses or BACnet objects into MQTT topics and back.
5. Occupancy data in the building
A simple presence detector only says whether there is movement in a room. A counter says how many people there are. The difference matters for the systems whose load depends on the number of people.
| Application | What is needed | Acceptable delay | Where the decision is made |
|---|---|---|---|
| Lighting in a room | Whether people are present | Under a second | Locally (KNX, DALI) |
| Ventilation by head count | Number of people in the zone | Minutes | Locally or via the platform |
| Heating and cooling by zone | Occupancy by hour, forecast | Tens of minutes | BMS with data from the platform |
| Cleaning by usage | Number of visits per day | Hours | Platform |
| Office space utilisation | Occupancy by day and week | Days | Platform |
| Capacity limits | Current number of people | Seconds | Platform with an alert |
The rule is: the shorter the acceptable delay, the closer to the device the decision has to be.
6. Three architecture patterns
Pattern A: local loop
The sensor is connected directly to the building bus and controls lighting or ventilation without an external system. The most reliable and fastest, but the data stays in the building and is not analysed. Suitable for core functions.
Pattern B: gateway to a platform
Sensors and building systems send data through a gateway to a platform over MQTT or HTTPS. The platform stores, compares and displays, but does not control. Suitable for monitoring, reporting and existing buildings.
Pattern C: the platform sends commands back
The platform calculates setpoints, for example ventilation volume by head count, and passes them to the BMS through an API or gateway. It gives the greatest optimisation, but depends on the connection. So if the connection is lost, the building must fall back to safe local settings.
In practice a combination is used: pattern A for lighting and safety, pattern B for all data, and pattern C for selected functions where the benefit justifies the dependency.
7. How to organise data in MQTT
The standard does not define topics and content, so agree them before the first device. An example structure:
building/floor/zone/device-type/identifier/reading office-sofia/floor-3/meeting-a/counter/c-0142/occupancy
An example message:
{
"ts": "2026-06-05T09:15:00Z",
"occupancy": 7,
"in": 12,
"out": 5
}
The example is illustrative and is not the specification of a particular product. Recommendations:
- Timestamps in UTC and in ISO 8601 format.
- One reading per topic, or one object with clearly described fields, but not both at once.
- A retained message for state, so that every new subscriber receives it.
- A separate topic for device status, and a "last will" to detect sensors that drop out.
- QoS 1 for readings that must not be lost. QoS 0 is enough for frequent values.
- Permissions per topic: a device may publish only to its own topic.
8. Security and regulation
- Separate the building systems network from the office network, with a controlled crossing between them.
- Encrypt everything over IP: TLS for MQTT and REST, BACnet/SC, KNX Secure in new installations.
- Change factory passwords and give each device its own credentials.
- Connections go from the building outwards. Do not open ports to the internet for access to building controllers.
- Plan updates. A device that cannot be updated is a risk for its whole life.
- Keep an inventory of devices, their versions and who is responsible for them.
Three European acts affect IoT in buildings. The Data Act, applicable since September 2025, gives the user a right of access to data from connected devices. The Cyber Resilience Act (CRA) introduces security requirements for products with digital elements, with the main obligations applying from December 2027. NIS2 sets risk management requirements for organisations within its scope. For occupancy sensors, also check the data protection requirements in the article Visitor counting and GDPR.
9. Recommendations for roll-out
- Start from the goal. Define which decisions will be made from the data, and with what delay. The protocol follows from that.
- Describe what is there. Which systems the building has, which protocol they use and who maintains them.
- Keep core functions local. Lighting and safety must not depend on the internet.
- Choose open standards and require access to the data through an API or MQTT from every supplier.
- Agree the data model before installation: zone names, topics, units, time.
- Start with one floor or one zone. Check sensor accuracy and the benefit before you expand.
- Plan the behaviour on failure of a sensor, gateway and connection, and test it.
- Measure the result against a period before the change, under similar external conditions.
10. Where Count2Know fits
The Count2Know platform sits at the management level. It receives data from visitor counters and building sensors, stores it and shows it in one dashboard, and the data is available to other systems through an API.
- Visitor counters send their data to the platform over the network.
- Wireless LoRaWAN sensors for climate, air quality, consumption and status connect through a gateway. See the case study Building Monitoring with LoRaWAN Sensors.
- Meters supply consumption, which is also used to allocate costs between tenants.
- Output to other systems: REST API and event notifications.
The list of supported systems is on the Integrations page.
Glossary
| BMS | Building management system |
| HVAC | Heating, ventilation and air conditioning |
| Gateway | A device or piece of software that translates between two protocols |
| Broker | The MQTT server that receives messages and distributes them to subscribers |
| QoS | The level of delivery guarantee for a message in MQTT |
| Group address | A KNX address that links the senders and receivers of one function |
| TLS | A protocol for encrypted connections over IP |
This paper is for general information. The choice of protocols and architecture for a specific building is made by a designer and a system integrator according to the project and the applicable standards.