The Problem with BACnet
Building automation runs on BACnet. HVAC controllers, lighting systems, metering equipment: they all speak ASHRAE 135. The protocol handles local control loops well. It fails at cloud ingress.
BACnet relies on UDP broadcasts. These do not route over the internet or into VPCs. Your chiller controller cannot talk to AWS IoT Core. Your VAV box cannot publish to an MQTT broker. The air gap between operational technology and modern cloud infrastructure remains the core bottleneck in building digitization.
The bacnet-mqtt-gateway closes that gap. It is a protocol translator that sits at the edge, polls local BACnet/IP devices, and serializes data into structured JSON payloads over MQTT.
What This Gateway Does
The gateway terminates BACnet traffic on the LAN and pushes clean, state-change data upstream via TCP-based MQTT. Your cloud platform does not need to understand the BACnet stack. It subscribes to a topic and receives normalized JSON.
Core capabilities:
- Dynamic Discovery: Who-Is broadcasts identify devices on the network without manual IP configuration.
- Structured Polling: JSON configuration files define which objects to read and at what intervals. No network saturation from aggressive polling.
- Bidirectional Control: Write values to Analog Value, Binary Output, and Multi-state objects via MQTT topics or REST API.
- Priority Array Support: Configurable write priorities prevent cloud commands from overriding life-safety interlocks programmed at higher priority levels.
- JWT Authentication: API endpoints secured with token-based auth.
- TLS MQTT: Encrypted connections to the broker.
- Prometheus Metrics: Health endpoints for Prometheus and Grafana dashboards. Graph BACnet network connectivity alongside server stats.
- Home Assistant Autodiscovery: MQTT topics structured for instant integration with Home Assistant.
The Engineering Problems This Solves
Protocol Normalization. BACnet is verbose. UDP broadcasts work inside a building but do not cross network boundaries cleanly. The gateway acts as a localized proxy. Noisy BACnet traffic stays on the LAN. Only meaningful state changes flow upstream.
Safe Write Operations. Reading data is straightforward. Writing data safely is not. BACnet uses a 16-level priority array to determine which command controls a device. A setpoint change from the cloud should not override a fire alarm interlock. This gateway enforces configurable write priorities.
Observability. Legacy OT networks do not expose health endpoints. A sensor goes offline and you find out when a tenant complains. The gateway wraps the BACnet stack in a modern application layer with Prometheus metrics and health checks. You know when connectivity degrades before anyone files a ticket.
Configuration as Code. Mapping thousands of BACnet points manually produces errors. The gateway uses structured JSON configuration files for device lists and polling schedules. Version control with Git. Review through pull requests. Automate via CI/CD. DevOps practices applied to building automation.
Deployment
The gateway ships as a Docker image with docker-compose support.
1. Clone and configure environment:
git clone https://github.com/novatechflow/bacnet-mqtt-gateway.git
cd bacnet-mqtt-gateway
cp .env.example .env
2. Set broker credentials in .env:
MQTT_BROKER_URL=mqtt://broker.hivemq.com
MQTT_USERNAME=admin
MQTT_PASSWORD=secure_password
GATEWAY_ID=building-01
3. Define devices:
Map BACnet devices in the devices/ directory using JSON. Specify which Object IDs (e.g., analog-input:1) the gateway should poll.
4. Launch:
docker-compose up -d
5. Verify:
Access the Web UI to view active polls. Connect MQTT Explorer to verify data flow on the broker.
Who This Is For
Building Automation Engineers who need to pump BACnet data into data lakes or analytics platforms without custom integration scripts.
IoT Developers who want to interact with legacy building systems without learning the full ASHRAE 135 specification.
System Integrators looking for an open-source alternative to proprietary hardware gateways. Reusable, auditable, no vendor lock-in.
Source Code
The project is available on GitHub: github.com/novatechflow/bacnet-mqtt-gateway
MIT licensed. Contributions welcome.
If you need help with distributed systems, backend engineering, or data platforms, check my Services.