Ready to build this? Download the MQTTfy Android app to create MQTT, Bluetooth & Rest Client Dashboards and local Visual No-code automations directly from your smartphone.

Smart Building ESG Automation: Route BLE CO2 & Temp Sensors to HVAC REST APIs (Part 1)
Welcome to the definitive guide on revolutionizing commercial facility management. For decades, building automation systems (BMS) and HVAC (Heating, Ventilation, and Air Conditioning) controllers have been locked behind proprietary, million-dollar enterprise contracts. Companies like Honeywell and Siemens dominated the space, forcing facility managers to purchase expensive, hard-wired sensors and proprietary software licenses to monitor environmental data. But a tectonic shift is happening in commercial real estate: ESG (Environmental, Social, and Governance) compliance. Modern facility managers are under immense pressure to drastically reduce carbon footprints, optimize HVAC energy consumption, and prove indoor air quality (CO2 levels) to their tenants. To do this, they need hundreds of sensors per floor. Hard-wiring is impossible. The solution lies in cheap, wireless Bluetooth Low Energy (BLE) environmental sensors. The problem? How do you get the data from 50 wireless BLE sensors into a legacy HVAC control system without spending $100,000 on custom enterprise middleware? The answer is MQTTfy. In this massive, three-part guide, we will demonstrate how to mount a standard, off-the-shelf Android tablet in the ceiling of a commercial office space. By running the MQTTfy application, this tablet becomes an enterprise-grade Edge IoT Gateway. We will show you how MQTTfy can simultaneously scan dozens of BLE environmental sensors, average the data using its internal Visual Automation engine, and fire HTTP REST API commands directly to a smart HVAC controller—all without writing a single line of code. ---Chapter 1: The Commercial Challenge – Bridging BLE to BMS
Before we build the architecture, we must understand the engineering roadblock that facility managers face daily. You can buy highly accurate, battery-powered BLE Temperature, Humidity, and CO2 sensors for under $20 each. You can stick them under desks, in conference rooms, and in server closets. Because they are BLE, the batteries last for years. However, BLE sensors are "dumb." They simply broadcast their raw hexadecimal data into the air. Your building's HVAC controller (often running an internal web server with a REST API or Modbus TCP) is "smart," but it has no Bluetooth antenna. It speaks IP (Internet Protocol).The Flawed Enterprise Solution
If you hire a traditional systems integrator, they will sell you a proprietary "BLE to Wi-Fi Gateway." These boxes cost hundreds of dollars each. Furthermore, you have to route all the data to their cloud servers, pay a monthly SaaS subscription, and then use cloud-based webhooks (like Make.com or enterprise middleware) to send the commands back down to your building's HVAC system. This introduces: 1. Unacceptable Latency: HVAC systems should react locally. 2. Security Vulnerabilities: You are opening firewall ports to let cloud webhooks back into your secure building network. 3. Exorbitant Costs: Monthly recurring revenues for basic data routing.The MQTTfy Edge Solution
By mounting an Android tablet running MQTTfy in the office space, we eliminate the cloud entirely. The Android tablet acts as the ultimate Edge Compute Gateway. Its Bluetooth 5.0 antenna has the range to cover thousands of square feet of open office space. It intercepts the BLE broadcasts locally. Then, using MQTTfy's native Visual Automation Engine, it parses the data, applies logic (e.g., "If average CO2 in the conference room exceeds 1000ppm"), and fires a local, secure REST API POST directly to the HVAC controller on the same internal Wi-Fi network. Simultaneously, MQTTfy acts as an MQTT Client, publishing the aggregated environmental metrics to the facility manager's private Mosquitto broker for beautiful, real-time ESG dashboarding on Grafana. Zero cloud dependencies. Zero monthly fees. Zero code. ---Chapter 2: The Hardware Architecture
Let's visualize the physical deployment of our Smart Building ESG Automation system. 1. The Sensor Layer (BLE):- We will deploy 10 BLE environmental sensors (measuring Temperature, Humidity, and CO2) across a large conference room and open working space. These sensors operate on coin-cell batteries and broadcast their telemetry via GATT (Generic Attribute Profile) advertisements every 30 seconds. 2. The Edge Gateway Layer (Android + MQTTfy):- A standard Android tablet (running Android 9.0 or higher for optimal background Bluetooth scanning) is mounted securely above the drop-ceiling or on a central wall. - It is connected to the building's internal, secure Wi-Fi network (VLAN) and plugged into continuous USB power. - The MQTTfy app runs in Persistent Background Mode, ensuring the Android OS never kills the scanning service. 3. The Control Layer (REST API):- A smart HVAC thermostat or damper controller (such as an Ecobee, a Shelly relay, or a commercial BACnet/IP gateway with a REST interface). This device accepts local HTTP commands to increase fan speed or open fresh air dampers. 4. The Analytics Layer (MQTT):- A local server running a Mosquitto MQTT broker and a visualization tool (like Node-RED Dashboard or Grafana). This allows the facility manager to prove ESG compliance with historical charts. ---Chapter 3: Why Android is the Ultimate Industrial Gateway
It is common for engineers to ask: Why use an Android tablet instead of a Raspberry Pi or an Industrial PC (IPC)?If you have ever tried to deploy 50 Raspberry Pis across a corporate campus, you already know the answer: SD Card corruption and OS maintenance.Raspberry Pis run standard Linux. When building power is abruptly cut, their SD cards frequently corrupt. They require constant apt-get updates, complex networking configuration via terminal, and manual Bluetooth stack resets when BlueZ (the Linux Bluetooth daemon) inevitably crashes. Android, on the other hand, is arguably the most resilient, battle-tested edge operating system on the planet. - Resilience: Android uses immutable system partitions and journaling file systems. If you pull the plug on an Android tablet, it will never corrupt the OS. - Power Backup: Every Android tablet contains a massive lithium-ion battery. If the building loses power, the tablet stays online for days, continuing to log environmental data locally. - The GUI: If an IT technician needs to debug a sensor, they don't need to SSH into a terminal. They pull down the tablet, look at the MQTTfy graphical interface, and can instantly see live BLE packets and MQTT connection statuses. - The Antennas: Commercial tablets have vastly superior, diversity-tuned Wi-Fi and Bluetooth antennas compared to the PCB traces on hobbyist microcontrollers. By running MQTTfy on Android, you get a zero-maintenance, ruggedized gateway (perfect for Industrial IoT SCADA environments) with a built-in UPS and an HD touchscreen for a fraction of the cost of an Industrial PC. ---Chapter 4: The Logic Flow – Aggregation and Hysteresis
In Part 2 and Part 3 of this series, we are going to build a complex logic flow entirely inside MQTTfy's visual canvas. Before we drag and drop the nodes, let's understand the engineering concepts we must implement. When controlling massive, power-hungry HVAC systems, you cannot simply turn the air conditioning on every time a single sensor blips 0.1 degrees above the threshold. If you do, the massive compressors will "short-cycle" (turning on and off rapidly), which destroys the equipment and voids warranties. We must implement two industrial control concepts inside MQTTfy: Aggregation and Hysteresis.Concept 1: Spatial Aggregation
If someone breathes heavily directly onto Sensor #1, it will temporarily report 2,000ppm of CO2. We do not want to blast the HVAC fresh air dampers open for the entire floor based on one anomaly. Instead, MQTTfy must scan Sensor 1, Sensor 2, and Sensor 3, and calculate the Average CO2.Concept 2: Hysteresis (Deadbands)
If our target temperature is 72°F, we don't turn on the AC at 72.1°F and turn it off at 71.9°F. We create a "deadband". We tell MQTTfy: Turn on the AC when the average temp hits 74°F, and do not turn it off until the average temp drops down to 70°F.Traditionally, programming spatial aggregation arrays and hysteresis loops requires hundreds of lines of Python code, careful state management, and memory allocation. In MQTTfy, you will achieve this using a few visual Math Nodes and Condition Nodes. The app handles all the state retention in the background.Next Steps in Part 2
You now understand the architecture, the hardware, and the immense financial value of bridging cheap BLE environmental sensors to legacy HVAC APIs using an Android Edge Gateway. In Part 2: BLE Aggregation & Environmental Filtering, we will boot up the MQTTfy application and get to work. We will configure the GATT Client to scan a fleet of temperature and CO2 sensors simultaneously. We will explore MQTTfy's unique ability to group multiple BLE MAC addresses into a single, unified data stream, and we will begin building the visual mathematical filters necessary to tame raw environmental telemetry. Get your Android tablet ready. We are about to automate a skyscraper.(End of Part 1. Download Part 2 for the Hands-On Configuration.)Smart Building ESG Automation: Route BLE CO2 & Temp Sensors to HVAC REST APIs (Part 2)
In Part 1 of this definitive guide to Smart Building ESG automation, we analyzed the massive financial and architectural benefits of replacing proprietary enterprise gateways with a repurposed Android tablet running the MQTTfy application. We established why Edge Computing is critical for facility management, and introduced the industrial control concepts of Spatial Aggregation and Hysteresis. Now, we roll up our sleeves. In Part 2, we will configure the Android device to act as a wide-area "Fleet Scanner." We will instruct MQTTfy to scan dozens of disparate Bluetooth Low Energy (BLE) sensors simultaneously, group their data streams, and build the visual mathematical logic required to tame raw, noisy environmental data. And as always, we will achieve this enterprise-grade telemetry filtering without writing a single line of code. ---Chapter 1: Configuring the Fleet Scanner
When automating a 2,000-square-foot open office layout, deploying a single sensor is a recipe for disaster. If someone opens a window near the single thermostat, the entire floor's HVAC system will overcompensate, freezing the rest of the employees. To solve this, facility managers deploy "fleets" of cheap, battery-powered BLE environmental sensors (measuring Temperature, Humidity, and CO2). Our first task is to instruct MQTTfy to connect to all of them.Step 1: Discovering the Fleet
1. Mount your Android tablet centrally in the office space (above the drop-ceiling is ideal for radio propagation). 2. Open the MQTTfy app and navigate to the BLE Devices tab. 3. Tap Start Scan. Because commercial tablets feature highly sensitive Bluetooth 5.0 antennas, MQTTfy will instantly populate the screen with dozens of BLE MAC addresses.Step 2: Extracting the GATT Payloads
Just as we did in our previous Home Assistant guide, we must map the raw data inside the sensors. 1. Tap on the first BLE sensor in your list (e.g., `Conf_Room_Sensor_1`). 2. MQTTfy interrogates the GATT table. Locate the specific characteristic for CO2 (often a standard 16-bit UUID or a manufacturer-specific 128-bit UUID). 3. Tap the characteristic and use MQTTfy's visual payload formatter to decode the raw hex bytes into a readable Integer (e.g., `850 ppm`). 4. Save this configuration as a Data Source.Step 3: Cloning the Configuration (The Fleet Rollout)
Normally, repeating this manual GATT extraction process for 50 sensors would take hours. MQTTfy solves this with Profile Cloning. If all your sensors are the same brand/model (e.g., 50 generic BLE CO2 sensors), they all share the exact same GATT UUID structure. 1. In the MQTTfy BLE Devices tab, long-press the `Conf_Room_Sensor_1` profile you just created. 2. Select Clone to MAC Address. 3. A scanner window opens. Simply walk around the office, hold your tablet near the next sensor, and tap its MAC address. MQTTfy instantly applies the exact GATT reading and byte-decoding logic to the new sensor. 4. Repeat this for all sensors in your zone. You now have a fleet of 10-50 sensors actively polling their data into MQTTfy’s memory. ---Chapter 2: The Visual Automation Engine - Aggregation
Right now, MQTTfy is holding 10 separate variables in its memory: `Temp_1`, `Temp_2`, ... `Temp_10`. If we send 10 conflicting REST API commands to the HVAC controller every minute, the controller will lock up. We must build a Spatial Aggregator to calculate the median or average temperature of the entire zone before making an HVAC decision. We will do this entirely within MQTTfy’s Visual Automation Canvas.Building the Array
1. Navigate to the Automations tab and tap Create New Flow. 2. We need this automation to run on a schedule, not just when a single sensor updates. Drag a Time Trigger Node onto the canvas. Set it to run every `5 Minutes`. 3. Drag a Data Fetch Node onto the canvas. Connect the Time Trigger to it. 4. Inside the Data Fetch Node, select all 10 of your BLE sensor Data Sources. MQTTfy automatically bundles their latest values into an internal array.The Math Node: Calculating the Zone Average
1. Drag a Modifier Node onto the canvas and connect it to the Data Fetch node. 2. Tap the Modifier Node and select the Math / Aggregation tool. 3. The visual interface will ask you what operation to perform on your selected inputs. Choose Average (Mean).(Note: For highly volatile environments, selecting Median is mathematically superior as it ignores outliers, such as someone breathing directly on a sensor).4. The output of this node is a single, perfectly smoothed, highly reliable variable representing the true state of your office zone: `{{Zone_Average_Temp}}`. ---Chapter 3: Designing Industrial Hysteresis (Deadbands)
With our `{{Zone_Average_Temp}}` securely calculated, we must now build the logic that decides when to command the HVAC system. As discussed in Part 1, industrial HVAC compressors require "deadbands" (hysteresis) to prevent short-cycling. - We want the AC to turn ON when the average temp hits 74°F. - We want the AC to turn OFF when the average temp drops below 70°F. - If the temp is between 70 and 74, we do nothing (maintain current state).Step 1: The Upper Bound (Turn ON Logic)
1. Drag a Condition Node onto the canvas, placing it below your Math Node. Connect them. 2. Set the condition logic to: `IF {{Zone_Average_Temp}} >= 74`. 3. The Condition Node has two outputs: `True` and `False`. 4. If `True`, we will eventually drag a line to an Action node that sends the "AC ON" REST API command.Step 2: The Lower Bound (Turn OFF Logic)
But what if the temperature is 72°F? The first node evaluates to `False`. We need a second condition to check the lower bound. 1. Drag a second Condition Node onto the canvas. 2. Draw a line from the `False` output of the first Condition Node to the input of this new Condition Node. 3. Set the logic for this second node to: `IF {{Zone_Average_Temp}} <= 70`. 4. If this evaluates to `True`, we will drag a line to an Action node that sends the "AC OFF" REST API command. 5. If this evaluates to `False` (meaning the temp is exactly 71, 72, or 73), the execution flow simply terminates. No REST API calls are sent. The HVAC compressor is protected.The Power of Visual State Machines
Take a moment to realize what you have just built. In a traditional Python script running on a Raspberry Pi, implementing a non-blocking fleet scanner, array averaging, and a hysteresis state machine requires advanced asynchronous programming and exception handling. In MQTTfy, you drew five boxes on a touchscreen. This visual flow runs natively on the Android CPU, compiling down to highly efficient machine code. It is crash-proof, instantaneous, and infinitely adjustable. If a tenant complains they are too hot, the facility manager simply opens the MQTTfy app, taps the first Condition Node, changes `74` to `73`, and hits Save. The ESG policy is instantly updated across the entire floor. ---Next Steps in Part 3
Our Edge Gateway is now incredibly intelligent. It is scanning a fleet of wireless BLE sensors, mathematically smoothing the data to reject anomalies, and executing a flawless industrial hysteresis loop. But right now, the automation flow ends in empty space. The logic knows when to turn on the AC, but it hasn't actually spoken to the HVAC controller yet. In Part 3: REST API Dispatch and MQTT Dashboarding, we will finalize the system. We will attach the final Action Nodes to our canvas, constructing the secure HTTP REST payloads required to command enterprise HVAC systems. Finally, we will configure a simultaneous MQTT publish action, securely streaming our aggregated ESG metrics to a corporate Grafana dashboard to prove our carbon reduction to the stakeholders.(End of Part 2. Download Part 3 for the final REST and MQTT integration.)Smart Building ESG Automation: Route BLE CO2 & Temp Sensors to HVAC REST APIs (Part 3)
Welcome to the thrilling conclusion of our commercial Smart Building ESG Automation guide. In Part 1, we abandoned the expensive, proprietary legacy gateways in favor of a vastly superior Android Edge Architecture. In Part 2, we transformed a single Android tablet into a powerful "Fleet Scanner," aggregating dozens of BLE environmental sensors and deploying a visual, mathematical hysteresis loop to protect our massive HVAC compressors from short-cycling. Now, in Part 3, we must close the loop. Our Android edge gateway—powered entirely by the MQTTfy app—knows exactly when the building needs fresh air. But now it must actually command the building. We will achieve this by chaining our visual logic into a robust REST API Dispatcher capable of controlling enterprise thermostats. Simultaneously, we will branch our logic to an MQTT Publisher, streaming real-time aggregated ESG data to a corporate dashboard. And as always, we will execute this complex, dual-protocol routing without writing a single line of code. ---Chapter 1: The Power of Local REST APIs in Industrial Control
In the consumer smart home world, developers often rely on cloud-based webhooks (like Zapier, Make.com, or IFTTT). In commercial facility management, relying on the cloud to turn on an air conditioner is a catastrophic security risk. Commercial buildings run on highly secure, air-gapped internal networks (VLANs). The HVAC controllers (whether they are simple Shelly Pro relays, smart Ecobee thermostats, or massive BACnet/IP gateways) usually host an internal web server that accepts HTTP REST commands over the Local Area Network (LAN). To control them, the gateway must be physically present on the same internal network. Because our MQTTfy Android tablet is connected to the building’s secure Wi-Fi, it has direct, low-latency access to the HVAC REST API.Preparing the REST Payload
Before we return to the MQTTfy visual canvas, you must know the IP address and the required JSON payload for your specific HVAC controller. For this tutorial, let's assume we are targeting a local smart thermostat at `http://10.0.0.50/api/hvac/state`. To turn the AC on, the thermostat requires a POST request with the following JSON body: `{"mode": "cool", "fan": "auto"}` ---Chapter 2: Dispatching the REST API Command
Let's return to the Visual Automation Canvas inside the MQTTfy app where we left off in Part 2. We currently have a `Condition Node` evaluating if the Zone Average Temperature is `>= 74°F`. If this node evaluates to `True`, it outputs a signal. We will now attach our REST API action to that signal. 1. Drag an Action Node onto the canvas and place it next to the `True` output of the `Condition Node`. 2. Connect them with a line. 3. Tap the Action Node and select REST API Request. The REST Configuration interface will open. This is a full-featured HTTP client built directly into the visual node. 1. Method: Select `POST`. 2. URL: Enter `http://10.0.0.50/api/hvac/state`. 3. Headers: If your enterprise HVAC controller requires a Bearer Token or Basic Authentication, tap Add Header. Enter `Authorization` as the key and your token as the value. 4. Body Type: Select `application/json`. 5. Body Payload: Type `{"mode": "cool", "fan": "auto"}`.The "Turn Off" Branch
We must also complete the lower bound of our hysteresis loop. 1. Drag a second Action Node onto the canvas, next to the `True` output of our second Condition Node (which evaluates if the temperature is `<= 70°F`). 2. Connect them. 3. Configure this node identically to the first, but change the Body Payload to `{"mode": "off", "fan": "auto"}`.Zero-Code Execution
When the Android tablet's BLE scanner detects that the room has reached 74°F, the visual engine instantly triggers the REST node. Within milliseconds, the Android OS fires an HTTP POST request across the local Wi-Fi, hitting the HVAC controller. The massive rooftop compressors spin up. There is no cloud latency. There is no external server. The logic executes flawlessly at the edge. ---Chapter 3: Corporate Dashboarding – The MQTT ESG Stream
While commanding the HVAC system is the primary goal, facility managers must also prove their ESG (Environmental, Social, and Governance) compliance to corporate stakeholders. They need beautiful, historical charts proving that the indoor CO2 levels remained safe and the temperatures were optimized for energy efficiency. To do this, we need to send our aggregated sensor data to a database. We do not want to bombard a database with the raw, noisy data from 50 individual BLE sensors. We only want to send the clean, mathematically smoothed `{{Zone_Average_Temp}}` and `{{Zone_Average_CO2}}` that MQTTfy already calculated in Part 2. We will achieve this by "branching" our visual automation flow to an MQTT Publisher.Branching the Flow
1. Look at your canvas. Locate the Math Node (the one that calculated the `Average (Mean)` of our BLE fleet). 2. Drag a new Action Node onto the canvas, placing it below the Math Node. 3. Draw a line directly from the output of the Math Node to this new Action Node.(Notice how MQTTfy allows the Math Node to split its output: one line goes down to the Hysteresis condition logic to control the HVAC, and the other line goes to our new action node).4. Tap the new Action Node and select MQTT Publish.Formatting the Corporate Payload
Before we publish, we should wrap the data in JSON for easy ingestion by corporate dashboards like Grafana or Node-RED. 1. Insert a Modifier Node (JSON Builder) between the Math Node and the MQTT Publish Node. 2. In the JSON Builder, create two keys: `"zone_temp"` and `"zone_co2"`. 3. Assign them the dynamic variables from the Math Node: `{{Zone_Average_Temp}}` and `{{Zone_Average_CO2}}`.Publishing the Stream
1. Tap the MQTT Publish Action Node. 2. Select your corporate Mosquitto Broker profile (e.g., `Corporate AWS IoT` or `Local Facility Mosquitto`). 3. Set the Topic to: `building/floor3/conference_room/telemetry`. 4. Set the Payload to the output of the JSON builder: `{{JSON_Output}}`. 5. Set QoS to `1` to guarantee delivery. ---Chapter 4: The Ultimate Edge Gateway
Take a moment to step back and review the massive visual automation canvas you have just built inside the MQTTfy app on a single Android tablet.The Workflow:1. Every 5 minutes, the tablet wakes up its Bluetooth 5.0 antenna. 2. It silently sweeps the room, connecting to 10 distinct BLE environmental sensors. 3. It extracts the raw hex GATT payloads and translates them into human-readable integers. 4. It arrays the data and calculates the mathematical spatial average to eliminate noise. 5. It evaluates this clean data against a dual-bound industrial hysteresis loop. 6. If a threshold is breached, it fires a local, secure REST API POST to command the rooftop HVAC compressors. 7. Simultaneously, it wraps the clean data into a pristine JSON object and publishes an encrypted MQTT payload to a corporate ESG database.The True Value of No-Code Android IoT
If a systems integrator were hired to build this architecture from scratch using Python, Raspberry Pis, and proprietary REST middleware, they would charge tens of thousands of dollars in development time, hardware, and ongoing Linux maintenance. You built it in twenty minutes. You used a repurposed Android tablet. And you never wrote a single line of code. Because the MQTTfy app encapsulates the BLE GATT Client, the MQTT Client, the REST HTTP engine, and the visual logical processor into one unified, natively compiled Android application, the barrier to entry for enterprise-grade automation has been shattered. Whether you are managing a single smart home with a local offline AI agent or a 50-story commercial skyscraper, MQTTfy proves that the ultimate Edge IoT Gateway is the screen you are already holding.(End of Part 3. The Smart Building ESG Automation Guide is now complete.)graph TD
A[BLE CO2 Sensor 1] --> C(MQTTfy Edge Gateway)
B[BLE CO2 Sensor 2] --> C
C --> D{Average CO2 > 1000ppm?}
D -- Yes --> E[Fire REST POST to HVAC]
D -- No --> F[Do Nothing]