Siddhant Kumar
Project 066 · Industrial

Compressed Air Leak Monitor.

Finds the compressed-air leaks that silently waste a huge share of a factory's energy — by watching pressure decay when nothing should be running, and listening for the ultrasonic hiss of escaping air.

Intermediate 12–18 hours 29 min read EnergySensorsIndustry
Jump to source Bill of materials
Compressed Air Leak Monitor — reference build illustration MCU VCC · GND · SIG · NC
Difficulty
Intermediate
Build time
12–18 hours
Indicative cost
₹3,500 – ₹6,000
Platform
ESP32 DevKit V1 (ESP-WROOM-32)
Category
Industrial
Last updated
28 July 2026
Contents — 26 sections

Project Overview

Finds the compressed-air leaks that silently waste a huge share of a factory's energy — by watching pressure decay when nothing should be running, and listening for the ultrasonic hiss of escaping air.

Compressed air is often called the "fourth utility", and it is one of the most expensive forms of energy in a factory — most of the electricity a compressor consumes ends up as heat, so every cubic metre of compressed air is dear. The dirty secret is that a large fraction of it — commonly 20-30% — leaks away through worn fittings, cracked hoses and stuck drains, wasting money continuously, day and night, for years, because a leak makes no obvious sign on the production floor. This project builds a monitor that finds that waste: it detects when the system is leaking, quantifies how much, and helps locate leaks so they can be fixed — turning an invisible, permanent energy drain into a fixable, measurable problem.

It attacks the problem two complementary ways. The system-level method watches the receiver pressure during no-demand periods — nights, weekends, breaks — when, with all tools off, a sealed system should hold pressure. If it does not, the rate of pressure decay reveals the total leakage, and the frequency with which the compressor kicks in to top up an idle system (the "load/unload" cycling with no demand) directly quantifies the leak load and its energy cost. This needs only a pressure sensor on the receiver and knowledge of the demand schedule, and it gives the headline number: how much air, and money, is leaking.

The local method helps find where: escaping compressed air generates a characteristic ultrasonic hiss (turbulent flow radiates strongly above human hearing), so an ultrasonic microphone can detect a leak by ear that is silent to a person, pointing a technician to the exact fitting. Combined, the system-level monitor says "you are leaking X and it is costing Y", and the ultrasonic aid helps hunt the leaks down. The monitor logs and trends the leakage so a growing leak load is caught and the savings from repairs are verified. It is honest that quantification depends on the compressor/system specifics and that ultrasonic hunting is an aid, not magic — but as a leak monitor that makes an invisible, expensive waste visible and actionable, it typically pays for itself many times over in the energy it recovers.

Automated machinery on a factory production line
Compressed-air leaks waste a large, invisible share of a factory's energy — the monitor makes it visible. Photograph sourced from Wikimedia Commons — Factory automation.jpg. Reused under the licence stated on that page; please check it before republishing.

What this project does

  • Detects compressed-air leaks at the system level via pressure decay in no-demand periods
  • Quantifies leakage from pressure-decay rate and no-demand compressor cycling
  • Estimates the energy and money cost of the leak load
  • Detects/locates leaks acoustically via ultrasonic hiss
  • Logs and trends leakage so a growing leak load is caught
  • Verifies the savings from leak repairs
  • Turns invisible, permanent air waste into a measurable, fixable problem

Real-World Applications

SettingHow it is used
Factory compressed-air systemsQuantifying and finding leaks that waste a large share of compressor energy.
Energy / sustainability programmesMeasuring and recovering compressed-air waste as a high-ROI efficiency win.
Maintenance leak surveysUltrasonic-assisted leak hunting and repair verification.
Multi-site compressed airComparing leak load across plants and prioritising fixes.

Deployment contexts where a build of this kind earns its keep.

Features & Capabilities

  • No-demand pressure-decay leak detection (system level)
  • Leakage and cost quantification from decay/cycling
  • Ultrasonic leak location (hear the silent hiss)
  • Trending to catch a worsening leak load
  • Repair savings verification
  • Compressor-cycling energy insight
  • Honest quantification tied to system specifics

Difficulty, Time & Required Skills

AttributeValue
Difficulty levelIntermediate
Estimated completion time12–18 hours
Indicative build cost₹3,500 – ₹6,000
Primary disciplineIndustrial
Reference platformESP32 DevKit V1 (ESP-WROOM-32)

Skills you should have (or will pick up)

  • Pressure sensing on a compressed-air receiver
  • No-demand pressure-decay analysis and leakage quantification
  • Ultrasonic acoustic leak detection
  • Compressor-cycling and energy-cost estimation
  • Trending and repair verification

Bill of Materials

Every part below is commonly available from Indian and international hobby-electronics suppliers. Prices are indicative 2026 retail figures in Indian rupees and will drift — treat them as a budgeting guide, not a quotation.

ComponentKey specificationQtyApprox. cost
ESP32 DevKit V1 (ESP-WROOM-32)
Wi-Fi transmit bursts peak near 500 mA — size the regulator accordingly.
Dual-core Xtensa LX6 @ 240 MHz, 520 KB SRAM, 4 MB flash, Wi-Fi 802.11 b/g/n + BLE 4.2, 34 GPIO, 18× 12-bit ADC, 2× 8-bit DAC1₹450
INMP441 I²S MEMS microphone
Digital output means no analogue noise pickup — far better than an MAX9814 for keyword spotting.
61 dB SNR, −26 dBFS sensitivity, 60 Hz–15 kHz, 24-bit I²S output1₹220
DS18B20 waterproof temperature probe
Dozens can share one GPIO — you address them by ROM code.
−55 to +125 °C, ±0.5 °C from −10 to +85 °C, 9–12-bit resolution, unique 64-bit ROM ID1₹160
0.96″ SSD1306 OLED display
Static images burn in — invert or scroll the screen periodically.
128 × 64 monochrome, 1.3–3.3 V logic, 100 kHz–400 kHz I²C1₹250
microSD card 32 GB A1 class
For 24/7 loggers buy a high-endurance card — normal cards die in months.
A1 rated, 10 MB/s random write, UHS-I, endurance-grade recommended1₹450
5 V 3 A regulated SMPS adapter
Measure the real output — many "3 A" adapters sag below 4.7 V at 2 A.
100–240 VAC in, 5 V ±5 % out, 3 A, short-circuit and over-voltage protection1₹350
Pressure sensor on the receiver
The core system-level sensor
Pressure transducer (e.g. 0-16 bar, 4-20 mA/analogue) on the air receiver/main1₹1,200
Ultrasonic leak detector mic
INMP441 has limited ultrasonic range; a dedicated ultrasonic sensor is better
Ultrasonic microphone/parabola (~40 kHz) for acoustic leak location1₹1,500
Compressor state inputSignal/CT to detect compressor load/unload cycles1₹400
EnclosureIndustrial housing near the receiver1₹350

Estimated total: ₹5,330, excluding tools, shipping and consumables.

Tools and consumables

  • Soldering iron (temperature controlled, 350 °C) with 0.8 mm 60/40 or lead-free solder
  • Digital multimeter — continuity, DC volts and current ranges
  • Wire strippers, flush cutters and a small set of precision screwdrivers
  • Heat-shrink tubing and a heat gun (or a lighter, carefully)
  • A laptop with a USB port and the toolchain listed above

Hardware Specifications

PartSpecificationSupplyInterfaceReference
ESP32 DevKit V1 (ESP-WROOM-32)Dual-core Xtensa LX6 @ 240 MHz, 520 KB SRAM, 4 MB flash, Wi-Fi 802.11 b/g/n + BLE 4.2, 34 GPIO, 18× 12-bit ADC, 2× 8-bit DAC3.3 V logic / 5 V USBUART, SPI, I²C, I²S, CAN, PWMDatasheet
INMP441 I²S MEMS microphone61 dB SNR, −26 dBFS sensitivity, 60 Hz–15 kHz, 24-bit I²S output1.8–3.3 VI²SDatasheet
DS18B20 waterproof temperature probe−55 to +125 °C, ±0.5 °C from −10 to +85 °C, 9–12-bit resolution, unique 64-bit ROM ID3.0–5.5 V1-Wire (multi-drop)Datasheet
0.96″ SSD1306 OLED display128 × 64 monochrome, 1.3–3.3 V logic, 100 kHz–400 kHz I²C3.3–5 VI²C (0x3C)Datasheet
microSD card 32 GB A1 classA1 rated, 10 MB/s random write, UHS-I, endurance-grade recommended3.3 VSDIO / SPIDatasheet
5 V 3 A regulated SMPS adapter100–240 VAC in, 5 V ±5 % out, 3 A, short-circuit and over-voltage protection5 VDC barrel / USBDatasheet

Consolidated electrical and interface specifications for every active part in the build.

Power Budget & Supply Sizing

Add up the typical active current of every part, then size the supply with at least 50 % headroom so transmit bursts and motor inrush never brown out the controller.

LoadSupply railTypical current (mA)Notes
ESP32 DevKit V1 (ESP-WROOM-32)3.3 V logic / 5 V USB160Wi-Fi transmit bursts peak near 500 mA — size the regulator accordingly.
INMP441 I²S MEMS microphone1.8–3.3 V1.4Digital output means no analogue noise pickup — far better than an MAX9814 for keyword spotting.
DS18B20 waterproof temperature probe3.0–5.5 V1.5Dozens can share one GPIO — you address them by ROM code.
0.96″ SSD1306 OLED display3.3–5 V20Static images burn in — invert or scroll the screen periodically.
microSD card 32 GB A1 class3.3 V100For 24/7 loggers buy a high-endurance card — normal cards die in months.
5 V 3 A regulated SMPS adapter5 V3000Measure the real output — many "3 A" adapters sag below 4.7 V at 2 A.

Summed typical draw is 3282.9 mA. With a 1.5× design margin the supply should deliver at least 5000 mA continuously at the stated rail voltage.

Software Requirements & Development Environment

Reference toolchain: Arduino IDE 2.3.x with the ESP32 board package 3.x (or PlatformIO on VS Code). Anything newer normally works; anything older may lack the board definitions used here.

  • Install the Arduino IDE 2.3.x (or PlatformIO if you prefer a real editor and dependency locking).
  • Add https://espressif.github.io/arduino-esp32/package_esp32_index.json under File → Preferences → Additional Board Manager URLs, then install esp32 from the Boards Manager.
  • Set the correct port under Tools → Port. On Linux add yourself to the dialout group: sudo usermod -aG dialout $USER and log out and back in.
  • Open the Serial Monitor at 115200 baud — every sketch here logs its state there.
  • Keep File → Preferences → Show verbose output during: compilation switched on while you are debugging build errors.

Required libraries

LibraryWhy it is neededInstall
WiFi (ESP32 core) bundledStation/AP connection management for the ESP32.Bundled with the ESP32 Arduino core
PubSubClient 2.8Lightweight MQTT 3.1.1 client for constrained devices.Library Manager → "PubSubClient" by Nick O'Leary
Adafruit SSD1306 + GFX 2.5.xFramebuffer and text/graphics primitives for the OLED.Library Manager → "Adafruit SSD1306"
InfluxDB 2.x + Telegraf 2.7Time-series storage with retention policies and downsampling.docker run -p 8086:8086 influxdb:2.7
ArduinoJson 7.xZero-allocation JSON serialisation and parsing.Library Manager → "ArduinoJson" by Benoit Blanchon
Preferences (NVS) bundledWear-levelled key/value storage in ESP32 flash for settings.Bundled with the ESP32 core

Block Diagram

The block diagram shows the functional decomposition of the system — what senses, what decides, what acts, and where the data ends up.

Compressed Air Leak Monitor — system block diagramFunctional block diagram of the Compressed Air Leak Monitor system. SensePressurereceiver decayCompressor stateload/unloadUltrasonicleak hissAnalyseESP32decay + cyclingQuantifyair + costLocateUltrasonic aidfind the leakActDashboardleak trendSavingsverify repairsrightrightnone
Compressed Air Leak Monitor — system block diagram

Circuit Diagram & Wiring

Every signal line in the build is shown below, followed by a pin-by-pin connection table you can work through with a multimeter in hand.

Compressed Air Leak Monitor — wiring schematicConnection schematic showing which controller pin drives each peripheral. Sensors / InputsControllerActuators / OutputsESP32 DevKit V1(ESP-WROOM-32)3.3 V logic / 5 V USBPressure transducerGPIO 34 (ADC)Receiver pressureUltrasonic micGPIO 35 / I²SLeak hiss(ultrasonic)Compressor stateGPIO 27Load/unload cyclesOLEDGPIO 21/22Pressure/leakreadoutWi-FiDashboardmicroSDshared + CSLog/trend5V supply3V3 regPower
Compressed Air Leak Monitor — wiring schematic
PeripheralPeripheral pinController pinSignal
Pressure transducer4-20mA/AOUTGPIO 34 (ADC)Receiver pressure
Ultrasonic micAOUT/I²SGPIO 35 / I²SLeak hiss (ultrasonic)
Compressor statein/CTGPIO 27Load/unload cycles
OLEDSDA/SCLGPIO 21/22Pressure/leak readout
Wi-Fion-chipDashboard
microSDSPIshared + CSLog/trend
5V supply+/–3V3 regPower

Wire one row at a time and tick it off — most "it does not work" reports trace back to a single swapped pair.

Wiring explanation

  • Fit the pressure transducer on the receiver/main to read system pressure; this is the core system-level sensor.
  • Add a compressor-state input (or CT) to count load/unload cycles, which quantify no-demand leakage.
  • For acoustic location, use a dedicated ultrasonic sensor (~40 kHz) — an audio MEMS mic has limited ultrasonic range.
  • Know the plant's demand schedule so the monitor can analyse pressure decay during genuine no-demand periods.
  • Work safely around pressurised lines; do not create injury hazards during leak hunting.
An ESP32 development board with the ESP-WROOM-32 module and USB connector
ESP32 module quantifying leakage from no-demand pressure decay and compressor cycling. Photograph sourced from Wikimedia Commons — ESP32 Espressif ESP-WROOM-32 Dev Board.jpg. Reused under the licence stated on that page; please check it before republishing.

System Architecture

Read the stack from the bottom up: physical hardware, the firmware that drives it, the transport that moves data off the device, and the software a human actually looks at.

Compressed Air Leak Monitor — architecture stackLayered architecture from hardware to user interface. Hardware layerESP32 DevKit V1 (ESP-WROOM-32) · DS18B20 waterproof temperature probeDriver layerwifi · pubsub · ssd1306 · influxApplication logicsampling loop · filtering · thresholds · state machineTransport layerWi-Fi → energy/maintenance dashboard · TLS · retry and backoffPresentation layerdashboard · mobile notifications · historical charts
Compressed Air Leak Monitor — architecture stack

Working Principle

Compressed air deserves special attention because it is expensive energy that leaks invisibly. A compressor is an inefficient converter — most of the electrical energy it draws becomes waste heat, so the usable compressed air is costly per unit — and leaks bleed that costly air away continuously, unseen and unheard, through fittings and hoses across a plant. Because a leak produces no visible effect on production and often no audible sound to human ears, it can waste energy for years unnoticed. The monitor's job is to make this waste visible and quantified, because a leak you can measure and cost is a leak that gets fixed, while an invisible one is tolerated forever.

The most reliable system-level signal is what happens during no demand. When every tool and machine is off — overnight, at weekends, during a break — a leak-free system, once charged, should hold its pressure indefinitely; the compressor should not need to run at all. A real system does not: its pressure decays, and the compressor periodically cycles (loads and unloads) just to keep the idle system topped up. Both are pure leakage. The rate of pressure decay in a known system volume gives the leak flow directly, and the fraction of no-demand time the compressor spends loaded (or the number of load cycles per hour with no demand) quantifies the leak load as a share of compressor capacity — which converts straight into wasted energy and money using the compressor's power. This is the headline the monitor delivers: not "there are leaks" but "you are leaking X m³/h, costing ₹Y per year".

Finding where the leaks are is the complementary local problem, and physics helps: air escaping through a small orifice becomes turbulent and radiates strongly in the ultrasonic range, well above human hearing. An ultrasonic detector "hears" this hiss and, especially with a directional/parabolic pickup, points a technician straight to a leak that is completely silent to the ear. This turns leak hunting from a hopeless walk-around into a directed search. The monitor can use ultrasonic sensing to flag and help localise leaks, though it is honest that ultrasonic hunting is a skilled aid — reflections and background ultrasonic noise exist — rather than an automatic map.

What ties it together is trending and verification. Logging the quantified leak load over time catches a worsening system (leaks grow, new ones appear) before the bill balloons, and — crucially — lets you verify repairs: fix a batch of leaks and the no-demand decay slows, the no-demand cycling drops, and the monitor shows the recovered air and money, proving the maintenance paid off and justifying the next round. The design is candid about its dependencies: quantification needs the compressor and system specifics (capacity, power, volume) to convert decay/cycling into real energy, and precise leak location is a technician-assisted process. But within that, it does something with unusually high ROI — it exposes and measures one of the largest, most ignored energy wastes in a factory, and turns it into a prioritised, verifiable repair list. Compressed-air leak repair is famously one of the cheapest energy savings available; this monitor is what makes a plant actually go and get it.

The maths behind it

Leakage from no-demand pressure decay

plainLeakage from no-demand pressure decay
Sealed system volume V, pressure falls p1→p2 in time t
with no demand (isothermal approx):

  leaked_free_air ≈ V·(p1 − p2)/p_atm
  leak_flow ≈ leaked_free_air / t   (free air / time)

A faster decay = a larger leak. Needs the system volume.

Leakage from no-demand compressor cycling

plainLeakage from no-demand compressor cycling
With no demand, all compressor output serves leaks:

  leak_fraction = loaded_time / total_time (no-demand)
  leak_flow ≈ leak_fraction · compressor_capacity

  wasted_power ≈ leak_fraction · compressor_power
  annual_cost ≈ wasted_power · hours · tariff

Ultrasonic leak signature

plainUltrasonic leak signature
Turbulent flow through a leak radiates ultrasound (~20–50 kHz):

  ultrasonic level rises sharply near a leak
  directional pickup → localise the leak

Silent to the ear, loud in ultrasound → detectable/locatable.

Program Flowchart

The firmware is a single cooperative loop. Nothing blocks for long, so networking, sensing and the user interface all stay responsive.

Compressed Air Leak Monitor — firmware flowchartControl flow through the main program loop. Monitor pressure + compressorNo-demand period?Measure decay / no-demand cyclingLog; continueMeasure decay / no-demandcyclingLeakage above target?Quantify cost; alert; assist locationTrendQuantify cost; alert; assistlocationLog; continueTrendReport; verify repairs
Compressed Air Leak Monitor — firmware flowchart

Assembly Instructions

Build on a breadboard first and only commit to solder once the whole system has run for an hour without a fault.

  1. Fit the pressure and compressor sensing

    Install the pressure transducer on the receiver/main and a compressor-state input (or CT). Establish the system volume and the compressor's capacity/power for quantification.

  2. Add ultrasonic leak detection

    Add a dedicated ultrasonic sensor (directional if possible) for acoustic leak location, and learn the background ultrasonic level so a real leak stands out.

  3. Set up analysis and reporting

    Configure the no-demand schedule, decay/cycling analysis, cost model, and dashboard/logging for trending and repair verification.

Step-by-Step Implementation Guide

Work through these in order. Each step ends in something you can observe, so a failure is always localised to the step you just finished.

  1. Quantify leakage in no-demand periods

    During genuine no-demand periods, measure the pressure decay rate (and/or no-demand compressor cycling), convert to leak flow, and estimate the energy and money cost.

    cppleak-quantify.ino
    // System-level leak quantification during a no-demand period.
    struct System { float volume_m3; float compCapacity_m3min; float compPower_kW; };
    
    // From pressure decay p1->p2 over t seconds (no demand).
    float leakFlowFromDecay(float p1_bar, float p2_bar, float t_s,
                            const System &s) {
      float freeAirLost = s.volume_m3 * (p1_bar - p2_bar);   // ~ m3 free air
      return (freeAirLost / (t_s/60.0f));                    // m3/min
    }
    
    // From no-demand compressor loaded fraction.
    float leakFlowFromCycling(float loadedFraction, const System &s) {
      return loadedFraction * s.compCapacity_m3min;          // m3/min
    }
    
    float annualLeakCost(float loadedFraction, const System &s,
                         float hoursPerYear, float tariff) {
      float wastedKW = loadedFraction * s.compPower_kW;
      return wastedKW * hoursPerYear * tariff;               // currency/year
    }
    float freeAirLost = s.volume_m3 * (p1_bar - p2_bar)The pressure drop in the known system volume during no demand gives the free air lost, and dividing by time gives the leak flow.
    return loadedFraction * s.compCapacity_m3minDuring no demand, the fraction of time the compressor runs loaded times its capacity is the leak flow — a second, independent quantification.
    float wastedKW = loadedFraction * s.compPower_kWThat same loaded fraction times the compressor power is the wasted electrical power feeding the leaks.
    return wastedKW * hoursPerYear * tariffMultiplying by run hours and tariff turns the leak into an annual cost — the number that justifies the repair.
  2. Detect/locate acoustically and trend

    Use ultrasonic level to flag leaks and assist location, trend the quantified leak load over time, and verify repairs by the drop in decay/cycling.

Complete Source Code

The listing below is complete and compiles as written — there are no elided sections. Read the annotations under each block before you upload it.

cppcompressed-air-leak-monitor.ino
/* ═══════════════════════════════════════════════════════════════
   Compressed Air Leak Monitor — ESP32

   Quantifies compressed-air leakage from no-demand pressure decay and
   compressor cycling, estimates energy cost, flags/locates leaks
   ultrasonically, and trends leakage to verify repairs.
   ══════════════════════════════════════════════════════════════════ */

#include <WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Preferences.h>

#define PIN_PRESSURE 34
#define PIN_ULTRA    35
#define PIN_COMP     27       // compressor loaded (HIGH)
#define PMAX_BAR     16.0f
#define VOLUME_M3    2.0f
#define COMP_CAP_M3MIN 5.0f
#define COMP_KW      37.0f
#define TARIFF       8.0f     // currency per kWh
#define HOURS_YEAR   8000.0f

Adafruit_SSD1306 oled(128,64,&Wire);
Preferences prefs; WiFiClient net; PubSubClient mqtt(net);

float readPressure(){ return analogRead(PIN_PRESSURE)/4095.0f * PMAX_BAR; }
float ultrasonicLevel(){ return analogRead(PIN_ULTRA)/4095.0f; }

// Track compressor loaded fraction during a no-demand window.
uint32_t noDemandStart=0, loadedMs=0; float p1=0; bool inNoDemand=false;

void startNoDemand(){ inNoDemand=true; noDemandStart=millis(); loadedMs=0; p1=readPressure(); }

void endNoDemand(){
  inNoDemand=false;
  uint32_t total = millis()-noDemandStart;
  float loadedFrac = total? (float)loadedMs/total : 0;
  float p2 = readPressure();
  float decayFlow = VOLUME_M3*(p1-p2) / ((total/1000.0f)/60.0f);  // m3/min
  float cycleFlow = loadedFrac * COMP_CAP_M3MIN;                   // m3/min
  float wastedKW  = loadedFrac * COMP_KW;
  float annualCost= wastedKW * HOURS_YEAR * TARIFF;

  char m[240];
  snprintf(m,sizeof m,
    "{\"leak_decay_m3min\":%.2f,\"leak_cycle_m3min\":%.2f,"
    "\"wasted_kW\":%.1f,\"annual_cost\":%.0f}",
    decayFlow, cycleFlow, wastedKW, annualCost);
  mqtt.publish("air/leak/summary", m);       // trend + verify repairs
}

void setup(){
  Serial.begin(115200);
  pinMode(PIN_COMP, INPUT);
  Wire.begin(21,22); oled.begin(SSD1306_SWITCHCAPVCC,0x3C);
  WiFi.begin(WIFI_SSID,WIFI_PASS); mqtt.setServer(MQTT_HOST,1883);
}

void loop(){
  if(!mqtt.connected()&&WiFi.status()==WL_CONNECTED) mqtt.connect("air-1");
  mqtt.loop();

  bool noDemand = isNoDemandPeriod();          // from schedule
  if (noDemand && !inNoDemand) startNoDemand();
  if (!noDemand && inNoDemand) endNoDemand();

  if (inNoDemand && digitalRead(PIN_COMP)==HIGH) loadedMs += 200;  // loaded time

  float ultra = ultrasonicLevel();
  if (ultra > ULTRA_LEAK_THRESH)                // near a leak
    mqtt.publish("air/leak/acoustic", "ultrasonic leak nearby");

  float p = readPressure();
  oled.clearDisplay(); oled.setCursor(0,0);
  oled.printf("P: %.1f bar\nUltra: %.2f\n%s", p, ultra,
              inNoDemand?"NO-DEMAND":"running");
  oled.display();

  delay(200);
}
void startNoDemand()When a no-demand period begins, the monitor records the starting pressure and begins timing how long the compressor runs loaded — the two independent leakage measures.
float decayFlow = VOLUME_M3*(p1-p2) / ((total/1000.0f)/60.0f)The pressure decay over the no-demand window gives the leak flow directly from the system volume.
float cycleFlow = loadedFrac * COMP_CAP_M3MINIndependently, the fraction of no-demand time the compressor ran loaded times its capacity gives the leak flow — cross-checking the decay figure.
float annualCost= wastedKW * HOURS_YEAR * TARIFFThe wasted power is turned into an annual cost, the number that turns "there are leaks" into a justified repair budget.
if (ultra > ULTRA_LEAK_THRESH)A high ultrasonic level flags a nearby leak — the acoustic aid that helps a technician find the exact fitting silent to the ear.

Configuration & Calibration

Configuration steps

  • Set the system volume, compressor capacity/power, tariff and run hours for quantification.
  • Configure the no-demand schedule and the pressure/compressor/ultrasonic inputs.
  • Set leak targets and the ultrasonic threshold.
  • Configure trending/logging and repair-verification reporting.

Calibration procedure

An uncalibrated sensor produces confident, precise, wrong numbers. Do this once per physical unit and record the constants.

  1. Pressure

    Verify the pressure reading against a reference gauge; confirm the transducer range/scaling.

  2. Quantification

    Confirm the system volume and compressor figures so decay/cycling convert to realistic leak flow and cost; cross-check the two methods.

  3. Ultrasonic

    Learn the background ultrasonic level and set the threshold so a real leak stands out; test on a known small leak.

Network Architecture & Connectivity

Compressed Air Leak Monitor — network topologyPath taken by telemetry from field node to end user. Edge nodesGatewayCloudClientsAir monitorESP32Other systemsper-compressorWi-Fi 2.4 GHzRouterto serverMQTT/HTTPDashboard/CMMSleak load + costEnergyleak trend/costMaintenancefind/fix
Compressed Air Leak Monitor — network topology

Communication protocol

No-demand leak summaries (flow, wasted power, cost) publish per period; acoustic leak flags publish on detection. Trends drive repair prioritisation and verification.

Topic / endpointDirectionPayload
air/leak/summarynode → dashboardleak flow (decay+cycle), wasted kW, cost
air/leak/acousticnode → maintenanceultrasonic leak nearby
air/system/statusnode → opspressure, compressor cycling

Message contract between the device and the broker.

Cloud platform configuration

A dashboard/CMMS trends the leak load and cost, prioritises repairs, and verifies savings after maintenance; acoustic flags aid leak hunting.

Dashboard setup

Pressure and no-demand leak-load trend with cost, an ultrasonic leak indicator, and repair-verification comparisons.

Mobile app integration

Alerts on a rising leak load and acoustic leak detections; savings summaries after repairs.

Security considerations

  • Authenticate nodes; secure the energy data.
  • Keep quantification inputs (system/compressor specs) accurate for trustworthy cost figures.
  • Alert on monitor silence.

Testing Procedure & Expected Output

Test from the bottom up. Confirm power, then each sensor in isolation, then the integrated loop — the first failing step tells you exactly where to look.

TestWhat you should see
Run a no-demand period on a sealed systemSlow decay / minimal cycling — low leakage
Introduce a known leakFaster decay / more cycling; leak flow and cost quantified
Bring an ultrasonic source near the sensorUltrasonic level rises; leak-nearby flag
Trend over nightsA worsening leak load shows as a rising trend
Repair leaks and re-measureDecay/cycling drop; recovered air/cost quantified
Cross-check decay vs cyclingThe two leak-flow estimates broadly agree

Bench-test checklist. If a row fails, stop and fix it before moving on.

Expected output

The dashboard shows current pressure, the quantified no-demand leak flow and its annual cost, an ultrasonic leak indicator, and a leak-load trend with repair markers.

jsonair-leak.json
{
  "leak_decay_m3min": 0.9,
  "leak_cycle_m3min": 0.95,
  "wasted_kW": 7.0,
  "annual_cost": 448000
}

The two methods agree on ~0.9 m³/min of leakage, ~7 kW of wasted power costing ~₹4.5 lakh/year — an invisible waste made visible and costed; after repairs these numbers drop, proving the saving.

A Grafana time-series dashboard
A dashboard costs the leak load and verifies the savings once leaks are repaired. Photograph sourced from Wikimedia Commons — Grafana dashboard.png. Reused under the licence stated on that page; please check it before republishing.

Troubleshooting: Common Errors & Fixes

Leak flow numbers unrealistic

Likely cause. Wrong system volume/compressor figures

Fix. Verify V, capacity and power; cross-check decay vs cycling

No clear no-demand signal

Likely cause. Demand schedule wrong / genuine demand overnight

Fix. Confirm real no-demand periods; use compressor cycling if pressure is held by demand

Ultrasonic false/no detection

Likely cause. Wrong sensor range or background noise

Fix. Use a dedicated ultrasonic sensor; learn background; use directional pickup

Can't verify repairs

Likely cause. No trend/baseline

Fix. Log the no-demand leak metric before and after; compare

Safety concern

Likely cause. Unsafe leak hunting near pressurised lines

Fix. Follow pressurised-system safety; avoid air-jet injury

The sketch will not upload — "Failed to connect" or "avrdude: stk500_recv()"

Likely cause. The bootloader is not being reached: wrong port, wrong board, a serial monitor holding the port open, or a USB cable that only carries power.

Fix. Close every serial monitor, confirm Tools → Board and Port, and swap to a known data-capable USB cable. On an ESP32 hold BOOT while the IDE prints "Connecting…", then release. If a peripheral is wired to the UART pins (GPIO 1/3 on ESP32, D0/D1 on Uno) unplug it — it fights the programmer.

The board resets in a loop, or the serial monitor prints "Brownout detector was triggered"

Likely cause. The supply cannot deliver peak current. Wi-Fi transmit bursts, relay coils and servos all pull far more than their average draw.

Fix. Power peripherals from a separate regulated supply with a common ground rather than from the board 5 V pin. Add a 470–1000 µF electrolytic capacitor across the supply near the load, and use a real power adapter rather than a laptop USB port.

Serial monitor shows garbage characters

Likely cause. Baud rate mismatch between Serial.begin() and the monitor, or a floating/shared UART line.

Fix. Set the monitor to 115200 to match the sketch. If it still garbles, the crystal or the USB bridge is being confused by noise — shorten the cable and keep motor wiring away from the USB lead.

An I²C device is not detected

Likely cause. Wrong address, missing pull-ups, swapped SDA/SCL, or a bus too long for the pull-up value.

Fix. Run an I²C scanner sketch first — it should print the device address. Most breakout boards include 4.7 kΩ pull-ups, but if you have chained four of them the parallel resistance is too low; remove the pull-ups from all but one board. Keep the bus under 30 cm at 100 kHz.

Wi-Fi connects but MQTT never does (state -2)

Likely cause. Wrong broker address or port, a firewall in the way, or the broker requiring credentials the sketch is not sending.

Fix. Test from a laptop on the same network first: mosquitto_sub -h <broker> -t "#" -v. If that works, the problem is on the device — check the IP literal, port 1883 (or 8883 for TLS), and that client.setServer() runs before connect(). PubSubClient state codes are documented in its header.

Readings arrive for a while and then stop

Likely cause. The Wi-Fi or MQTT session dropped and the sketch never reconnects, or the broker dropped the client on keep-alive timeout.

Fix. Never assume the link stays up. Check WiFi.status() and client.connected() at the top of every loop and reconnect with exponential backoff. Add a watchdog so a wedged network stack reboots the device instead of going silent.

Performance Optimisation

  • Sample pressure/compressor at a modest rate; analyse over no-demand windows.
  • Cross-check decay and cycling estimates for confidence.
  • Trend the nightly leak metric to catch worsening leaks and verify repairs.
  • Handle ultrasonic detection separately as a location aid.
  • Replace every delay() with a millis() comparison — blocking delays are the single most common cause of dropped readings.
  • Sample sensors on a fixed cadence and publish on a slower one; you almost never need to transmit at the sampling rate.
  • Move networking into its own FreeRTOS task so a slow DNS lookup cannot stall the control loop.
  • Use uint8_t / uint16_t where the range allows; on an 8-bit AVR a 32-bit add costs four times as much.
  • Batch several samples into one MQTT publish. Radio time, not CPU time, dominates the energy budget.
  • Set the MQTT keep-alive to a value that matches your reporting interval so the broker does not churn reconnections.
  • For battery builds use deep sleep between samples: an ESP32 drops from ~160 mA awake to about 10 µA asleep, which is the difference between days and months of runtime.

Safety Precautions

  • Work safely around pressurised systems — a compressed-air jet can cause serious injury; keep leak hunting safe.
  • Quantification depends on correct compressor/system specifics; label figures as estimates where inputs are uncertain.
  • Ultrasonic leak location is a skilled aid, not an automatic map.
  • Coordinate with maintenance/energy teams; do not interfere with compressor control.
  • Wear eye protection when soldering or cutting, and solder in a ventilated space — rosin flux fumes are a respiratory irritant.
  • Power the circuit through a bench supply with a current limit while you are testing. A 300 mA limit turns a wiring mistake into a beep instead of a dead board.
  • Disconnect power before changing any wiring. Hot-plugging a sensor onto a live bus is the fastest way to lose a controller.

Maintenance

  • Verify pressure calibration and quantification inputs periodically.
  • Re-learn the ultrasonic background as the environment changes.
  • Repair flagged leaks and log the verified savings.
  • Trend the leak load and act before it grows.
  • Re-check every screw terminal and header after the first week — thermal cycling loosens connections that felt tight on day one.
  • Rotate the microSD card annually and keep an image of the working system. Cards used as loggers wear out silently.
  • Keep the broker and dashboard containers patched, and rotate device credentials at least once a year.
  • Recalibrate at the interval given in the calibration section, and keep the constants in a text file next to the firmware — not only in flash.
  • Keep a short logbook of firmware versions and what changed. Six months later you will not remember why that constant is 1.083.

Future Improvements & Upgrades

A working v1 is a platform, not a finish line. These are the upgrades that add the most capability for the least rework.

  • Add flow metering for direct leak measurement.
  • Add multiple ultrasonic sensors / a scanning aid for faster location.
  • Model demand to separate leaks from process use during production.
  • Integrate with the CMMS to raise and track leak-repair work orders.
  • Design a proper PCB. Once the breadboard version has run for a month, moving to a two-layer board removes the intermittent-contact failures that dominate prototype faults.
  • Add over-the-air firmware updates so you never have to physically reach a deployed node again.
  • Add persistent local storage (microSD or the on-chip flash) so a network outage does not create a hole in your data.
  • Move configuration out of the source: a captive-portal setup page or a JSON config file makes the build reusable without a recompile.
  • Add a battery and solar option so the unit survives a power cut and can be sited away from a socket.
  • Write a small test harness that feeds synthetic sensor values through the decision logic, so you can validate thresholds without physically triggering the event.

Frequently Asked Questions

Why care about compressed-air leaks?

Compressed air is expensive energy, and leaks commonly waste 20-30% of it continuously and invisibly. Finding and fixing them is one of the highest-ROI energy savings a factory can make.

How does it quantify the leak without a flow meter?

During no-demand periods a leak-free system should hold pressure with the compressor off. The rate of pressure decay in the known system volume, and the no-demand compressor cycling, both give the leak flow — and thus the wasted power and cost.

How does it help find the leaks?

Escaping air hisses ultrasonically, above human hearing. An ultrasonic detector, especially a directional one, points a technician to a leak that is completely silent to the ear.

How do I prove a repair worked?

Re-measure the no-demand leak metric after fixing leaks. The decay slows and cycling drops, and the monitor quantifies the recovered air and money — verifying and justifying the maintenance.

What do I need for accurate cost figures?

The system volume and the compressor's capacity and power (plus tariff and run hours). These convert the measured leakage into real energy and money; get them right for trustworthy numbers.

References & Learning Resources

These are the primary sources worth reading in full. Manufacturer datasheets always outrank forum posts when the two disagree.

  1. Compressed air energy efficiency and leaksUS DOE
  2. Ultrasonic leak detectionReference
  3. Compressed air systems — overviewReference
  4. Compressor load/unload controlReference
  5. Pressure decay leak testingReference