Skip to main content

Connect BACnet to the Cloud with bacnet-mqtt-gateway

The bacnet-mqtt-gateway project is an open source protocol bridge that translates BACnet building automation traffic into MQTT messages for cloud and IoT systems. It provides discovery, polling, bidirectional writes, APIs, security, and easy deployment via Docker. Many enterprises struggle to unify BACnet with modern data pipelines and cloud platforms because BACnet is local-network only and not cloud ready. This gateway provides a scalable, secure, production-ready adapter for MQTT ecosystems and smart building integrations.

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.

Most read articles

Why Is Customer Obsession Disappearing?

Many companies trade real customer-obsession for automated, low-empathy support. Through examples from Coinbase, PayPal, GO Telecommunications and AT&T, this article shows how reliance on AI chatbots, outsourced call centers, and KPI-driven workflows erodes trust, NPS and customer retention. It argues that human-centric support—treating support as strategic investment instead of cost—is still a core growth engine in competitive markets. It's wild that even with all the cool tech we've got these days, like AI solving complex equations and doing business across time zones in a flash, so many companies are still struggling with the basics: taking care of their customers. The drama around Coinbase's customer support is a prime example of even tech giants messing up. And it's not just Coinbase — it's a big-picture issue for the whole industry. At some point, the idea of "customer obsession" got replaced with "customer automation," and no...

How to scale MySQL perfectly

When MySQL reaches its limits, scaling cannot rely on hardware alone. This article explains how strategic techniques such as caching, sharding and operational optimisation can drastically reduce load and improve application responsiveness. It outlines how in-memory systems like Redis or Memcached offload repeated reads, how horizontal sharding mechanisms distribute data for massive scale, and how tools such as Vitess, ProxySQL and HAProxy support routing, failover and cluster management. The summary also highlights essential practices including query tuning, indexing, replication and connection management. Together these approaches form a modern DevOps strategy that transforms MySQL from a single bottleneck into a resilient, scalable data layer able to grow with your application. When your MySQL database reaches its performance limits, vertical scaling through hardware upgrades provides a temporary solution. Long-term growth, though, requires a more comprehensive approach. This invo...

What the Heck is Superposition and Entanglement?

This post is about superposition and interference in simple, intuitive terms. It describes how quantum states combine, how probability amplitudes add, and why interference patterns appear in systems such as electrons, photons and waves. The goal is to give a clear, non mathematical understanding of how quantum behavior emerges from the rules of wave functions and measurement. If you’ve ever heard the words superposition or entanglement thrown around in conversations about quantum physics, you may have nodded politely while your brain quietly filed them away in the "too confusing to deal with" folder.  These aren't just theoretical quirks; they're the foundation of mind-bending tech like Google's latest quantum chip, the Willow with its 105 qubits. Superposition challenges our understanding of reality, suggesting that particles don't have definite states until observed. This principle is crucial in quantum technologies, enabling phenomena like quantum comp...