Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Sensors & Modules

Methane Gas Sensor MQ4: Build an LNG Pipeline Leak Monitor

Methane Gas Sensor MQ4: Build an LNG Pipeline Leak Monitor

March 11, 2026 /Posted byJayesh Jain / 0

Table of Contents

  • Why Methane Leak Detection Matters for LNG Safety
  • MQ-4 Sensor Overview and Operating Principle
  • Key Specifications and Sensitivity Curve
  • Hardware Requirements
  • Wiring MQ-4 to Arduino
  • Warm-Up and Burn-In Requirements
  • Calibration and PPM Calculation
  • Complete Alarm System Code
  • LNG Pipeline Monitor Build Guide
  • Safety Considerations and Limitations
  • Frequently Asked Questions

Why Methane Leak Detection Matters for LNG Safety

Liquefied Natural Gas (LNG) and piped natural gas (PNG) are predominantly methane (CH₄) — typically 85–99% by volume. Methane is both flammable and, in high concentrations, an asphyxiant. Its explosive range in air is 5–15% by volume (50,000–150,000 PPM). A leak in a domestic gas pipeline, industrial LNG storage facility, or biogas digester poses a serious fire and explosion hazard long before the smell of added odorant becomes noticeable.

Commercial gas detectors certified for safety-critical installations can cost thousands of rupees and require periodic professional calibration. For educational projects, research applications, early warning systems in non-classified areas, and maker-grade monitoring of domestic appliances, the MQ-4 semiconductor gas sensor offers a practical and affordable entry point into methane detection.

This guide builds a complete LNG pipeline segment leak monitor: continuous methane measurement, PPM estimation, multi-level alarm with buzzer and LEDs, and serial data logging for trend analysis. We will also be honest about the limitations of this sensor versus certified industrial gas detectors.

7 Pin Universal Sensor Socket for MQ sensors

7 Pin Universal Sensor Socket for MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, MQ-9

Mount your MQ-4 sensor safely and replace it without soldering. This socket fits the TO-5 can package used by all MQ series gas sensors.

View on Zbotic

MQ-4 Sensor Overview and Operating Principle

The MQ-4 is a chemo-resistive semiconductor gas sensor manufactured by Winsen Electronics. Its sensing element is a tin dioxide (SnO₂) film deposited on an aluminium oxide (Al₂O₃) ceramic substrate. A nichrome heating coil embedded in the element maintains the SnO₂ at approximately 200°C — the temperature at which it is most sensitive to reducing gases like methane.

How Resistance Changes with Gas Concentration

At operating temperature, atmospheric oxygen chemisorbs onto the SnO₂ surface, capturing electrons and increasing the material’s electrical resistance. When methane molecules arrive, they react with the chemisorbed oxygen, releasing electrons back into the SnO₂ and reducing its resistance. The higher the methane concentration, the lower the sensor resistance (Rs) relative to its baseline resistance in clean air (R0).

This is why MQ sensor readings are always expressed as a ratio: Rs/R0. When Rs/R0 is close to 1.0, the air is clean. When it drops significantly below 1.0, gas is present.

Target Gases

The MQ-4 is most sensitive to methane (CH₄) and natural gas. It also responds (with lower sensitivity) to hydrogen, LPG, and alcohol vapour. It does NOT effectively detect carbon monoxide, CO₂, or NOₓ. For LPG detection, the MQ-2 or MQ-5 are better choices. For CO detection, use the MQ-7.

Key Specifications and Sensitivity Curve

Parameter Value
Target Gas Methane (CH₄), Natural Gas
Detection Range 300 – 10,000 PPM CH₄
Heater Voltage 5V ± 0.1V AC/DC
Heater Current ~160 mA
Heater Power ~900 mW
Load Resistance (RL) 20 kΩ (on module board)
Rs range in clean air 2 – 20 kΩ
Rs/R0 at 1000 PPM CH₄ ~0.4
Warm-up time Not less than 3 minutes
Operating Temperature -10°C to +50°C
Operating Humidity ≤95% RH (non-condensing)

Understanding the Sensitivity Curve

The MQ-4 datasheet provides a log-log graph of Rs/R0 versus gas concentration in PPM. This curve follows a power law: Rs/R0 = A × (PPM)^B, where A and B are constants derived by fitting the sensitivity curve. For methane, typical values are approximately A = 4.4 and B = -0.41 (these vary between sensor batches and must be verified with calibration gas for accurate PPM readings).

Rearranging for PPM: PPM = (Rs/R0 / A)^(1/B)

Hardware Requirements

  • MQ-4 gas sensor module (with onboard LM393 comparator and RL resistor)
  • Arduino Uno or compatible board
  • Red LED (high alarm), Yellow LED (low alarm), Green LED (status OK)
  • Active buzzer module
  • Push button (alarm acknowledge / silence)
  • 16×2 I²C LCD display (optional but recommended for standalone monitor)
  • 100µF electrolytic capacitor (sensor power supply decoupling)
  • Enclosure with ventilation slots or gas permeable membrane

Power note: The MQ-4 heater draws ~160mA continuously. Do NOT power it from the Arduino 5V pin — that pin is typically limited to 200mA and shared with all other components. Use a dedicated 5V 1A power supply or a buck converter from a 12V supply.

MQ 135 Air Quality Gas Detector Sensor Module For Arduino

MQ-135 Air Quality / Gas Detector Sensor Module for Arduino

Sensitive to ammonia, benzene, smoke, and CO₂ — deploy alongside MQ-4 for a comprehensive indoor air quality station that catches a wider range of hazardous gases.

View on Zbotic

Wiring MQ-4 to Arduino

MQ-4 Module VCC    →  External 5V supply (NOT Arduino 5V pin)
MQ-4 Module GND    →  Common GND (Arduino + supply)
MQ-4 Module AO     →  Arduino A0  (analog output)
MQ-4 Module DO     →  Arduino D4  (digital threshold output)

Green LED  →  Arduino D8  (via 220Ω resistor to GND)
Yellow LED →  Arduino D9  (via 220Ω resistor to GND)
Red LED    →  Arduino D10 (via 220Ω resistor to GND)
Buzzer     →  Arduino D11
Button     →  Arduino D2  (INPUT_PULLUP, other end to GND)

100µF capacitor across MQ-4 VCC and GND (heater power decoupling)

Warm-Up and Burn-In Requirements

The MQ-4 requires a warm-up time of at least 3 minutes after power-on before readings are meaningful. During this time, the heater brings the SnO₂ element to operating temperature and the surface chemistry stabilises.

Furthermore, brand-new MQ-4 sensors require a 48-hour burn-in period in clean air at operating voltage. This pre-conditions the SnO₂ surface and establishes a stable baseline resistance (R0) for accurate Rs/R0 ratio calculation. Skip the burn-in and your calibration will drift noticeably over the first week of use.

Burn-In Procedure

  1. Power the sensor at 5V in clean outdoor air (away from any gas sources, cooking fumes, or vehicle exhaust).
  2. Leave powered continuously for 48 hours.
  3. After 48 hours, take 100 analog readings over 10 minutes and average them — this is your R0 ADC value.
  4. Record R0 in your sketch constants. You only need to repeat this calibration if the sensor is replaced or if it has been stored unpowered for more than a month.

Calibration and PPM Calculation

Step 1: Measure R0 in Clean Air

// Run this sketch after 48-hour burn-in in clean air
// to determine your sensor's R0 value

const int MQ4_AO = A0;
const float RL = 20.0;  // Load resistance on module in kΩ
const float VREF = 5.0;

void setup() {
  Serial.begin(115200);
  Serial.println("Warming up MQ-4 for 3 minutes...");
  delay(180000); // 3 minute warm-up
  Serial.println("Calibrating R0 in clean air...");
}

void loop() {
  long sum = 0;
  for (int i = 0; i < 100; i++) {
    sum += analogRead(MQ4_AO);
    delay(100);
  }
  float avgADC = sum / 100.0;
  float Vout = (avgADC / 1023.0) * VREF;    // Voltage at AO pin
  float Rs = RL * (VREF - Vout) / Vout;     // Sensor resistance in kΩ

  Serial.print("Average ADC: "); Serial.println(avgADC, 1);
  Serial.print("Rs in clean air (= R0): "); Serial.print(Rs, 3); Serial.println(" kΩ");
  Serial.println("Set this as your R0 constant in the main sketch.");
  while(1); // Stop here
}

Step 2: Calculate PPM from Rs/R0

// Power-law fit to MQ-4 sensitivity curve for CH4:
// Rs/R0 = 4.4 * (PPM)^(-0.41)
// Rearranged: PPM = (Rs/R0 / 4.4)^(1/-0.41)
float calculatePPM(float Rs, float R0) {
  float ratio = Rs / R0;
  // Clamp: ratio > 1 means cleaner than calibration air → 0 PPM
  if (ratio >= 1.0) return 0.0;
  float ppm = pow((ratio / 4.4), (1.0 / -0.41));
  return ppm;
}

Complete Alarm System Code

#include <LiquidCrystal_I2C.h>

// Hardware pins
const int MQ4_AO     = A0;
const int MQ4_DO     = 4;
const int LED_GREEN  = 8;
const int LED_YELLOW = 9;
const int LED_RED    = 10;
const int BUZZER     = 11;
const int BUTTON     = 2;

// Sensor constants (update R0 after your calibration)
const float RL   = 20.0;   // Load resistance kΩ
const float VREF = 5.0;    // ADC reference voltage
const float R0   = 8.5;    // YOUR calibrated R0 in clean air (kΩ)
const float CURVE_A = 4.4;
const float CURVE_B = -0.41;

// Alarm thresholds (PPM)
const float ALARM_LOW  = 500.0;   // Yellow: early warning
const float ALARM_HIGH = 2000.0;  // Red: evacuate now

// Warm-up time
const unsigned long WARMUP_MS = 180000; // 3 minutes

LiquidCrystal_I2C lcd(0x27, 16, 2);
bool alarmSilenced = false;

float readRs() {
  long sum = 0;
  for (int i = 0; i < 10; i++) {
    sum += analogRead(MQ4_AO);
    delay(5);
  }
  float avgADC = sum / 10.0;
  float Vout = (avgADC / 1023.0) * VREF;
  if (Vout = 1.0) return 0.0;
  return pow((ratio / CURVE_A), (1.0 / CURVE_B));
}

void setAlarmState(float ppm) {
  bool button = (digitalRead(BUTTON) == LOW);
  if (button) alarmSilenced = true;

  if (ppm >= ALARM_HIGH) {
    digitalWrite(LED_GREEN, LOW);
    digitalWrite(LED_YELLOW, LOW);
    digitalWrite(LED_RED, HIGH);
    if (!alarmSilenced) tone(BUZZER, 1000); // Continuous high alarm
    alarmSilenced = false; // Can't silence high alarm permanently
  } else if (ppm >= ALARM_LOW) {
    digitalWrite(LED_GREEN, LOW);
    digitalWrite(LED_YELLOW, HIGH);
    digitalWrite(LED_RED, LOW);
    if (!alarmSilenced) {
      tone(BUZZER, 500, 500); // Intermittent low alarm
      delay(1000);
    } else {
      noTone(BUZZER);
    }
  } else {
    digitalWrite(LED_GREEN, HIGH);
    digitalWrite(LED_YELLOW, LOW);
    digitalWrite(LED_RED, LOW);
    noTone(BUZZER);
    alarmSilenced = false; // Reset silence when safe
  }
}

void setup() {
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_YELLOW, OUTPUT);
  pinMode(LED_RED, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  pinMode(BUTTON, INPUT_PULLUP);
  pinMode(MQ4_DO, INPUT);

  Serial.begin(115200);
  lcd.init();
  lcd.backlight();

  // Warm-up phase
  lcd.print("MQ-4 Warming Up");
  Serial.println("Warming up... please wait 3 minutes.");
  unsigned long start = millis();
  while (millis() - start = ALARM_HIGH) lcd.print("!! EVACUATE !!  ");
  else if (ppm >= ALARM_LOW) lcd.print("WARNING: LEAK   ");
  else lcd.print("Status: SAFE    ");

  setAlarmState(ppm);
  delay(2000); // 2-second measurement interval
}

LNG Pipeline Monitor Build Guide

Placement Strategy

Methane is lighter than air (relative density 0.55 vs air = 1.0). Unlike LPG, which sinks to the floor, methane rises and accumulates at the highest point in a room. Place your MQ-4 sensor near the ceiling or at the top of an enclosure around the pipeline fitting you want to monitor.

Enclosure Design

The sensor needs airflow to detect gas but must be protected from rain, dust, and physical damage in an outdoor pipeline environment. Use an IP54-rated enclosure with a small ventilation opening covered by a hydrophobic mesh (Gore-Tex or equivalent). Ensure the mesh pore size is smaller than the sensor element size but allows gas molecules to pass freely.

Multiple Sensor Network

For monitoring a long pipeline, deploy multiple MQ-4 Arduino units connected to a central ESP8266 or ESP32 via RS-485 (using MAX485 modules). Each node reports its PPM reading every 30 seconds. The central unit aggregates readings, identifies which segment has the highest concentration, and alerts via Wi-Fi to a phone notification or dashboard.

Baseline Drift Compensation

Over weeks and months, the sensor’s baseline R0 drifts slightly. Implement automatic baseline correction: if the sensor’s 24-hour minimum reading is stable and below 200 PPM, treat it as clean-air baseline and slowly update R0. Rapid changes override baseline updates to prevent a slow leak from being learned as clean air.

MQ-131 Ozone Gas Detection Sensor

MQ-131 Ozone Gas Detection Sensor

Detect ozone leaks from industrial generators and UV sterilisers. Combines with MQ-4 for a comprehensive multi-gas safety station covering both reducing and oxidising hazards.

View on Zbotic

Safety Considerations and Limitations

Critical disclaimer: The MQ-4 sensor and this Arduino-based system are for educational and research purposes. They are NOT a replacement for certified industrial gas detectors in safety-critical installations. Industrial pipeline monitoring requires ATEX or IECEx-certified instruments with proper failsafe design and professional installation. Do not rely on this system as the sole safeguard against gas leaks in residential or commercial environments.

Cross-Sensitivity

The MQ-4 also responds to hydrogen, LPG, alcohol, and smoke. In environments where these gases are also present, false alarms are possible. If you are monitoring a kitchen where alcohol or cooking fumes are common, expect occasional false positives.

Humidity Effects

High humidity (above 85% RH) increases the sensor’s baseline resistance, making it appear that less gas is present. In outdoor installations in coastal or monsoon conditions, apply a humidity compensation factor or accept reduced sensitivity during humid periods.

Ignition Risk

The MQ-4’s heater element operates at approximately 200°C. In an environment where gas concentration may approach the lower explosive limit (LEL = 5% = 50,000 PPM), the sensor element itself could potentially become an ignition source. Never install this sensor in an area where gas concentrations could reach the LEL — use it only for early warning at concentrations far below that threshold (the sensor’s range tops out at 10,000 PPM = 20% of LEL).

Expected Sensor Lifetime

MQ series sensors have a rated lifetime of approximately 5 years in continuous service. Performance degrades gradually with silicone poisoning (from silicone-containing products near the sensor) and prolonged exposure to high gas concentrations. Replace the sensor every 2–3 years in a production monitoring installation.

Frequently Asked Questions

What is the difference between MQ-4 and MQ-2 for methane detection?

The MQ-4 is specifically optimised for methane and natural gas, with its sensitivity curve peaked for CH₄. The MQ-2 is a broader-spectrum sensor sensitive to LPG, propane, hydrogen, smoke, and methane — but it is less selective and less sensitive to methane specifically. For natural gas or LNG pipeline monitoring, MQ-4 is the correct choice. For a kitchen with both LPG cylinders and natural gas appliances, an MQ-2 or MQ-5 covers LPG better.

How long does the MQ-4 take to warm up?

The minimum warm-up time is 3 minutes (the heater must bring the SnO₂ element to operating temperature). A newly purchased sensor additionally requires 48 hours of burn-in in clean air before it reaches a stable baseline. After the burn-in is complete, subsequent power-on warm-up is only 3 minutes.

Can I run the MQ-4 on battery power?

The heater draws ~160mA continuously, consuming about 3.84Wh per day. A 2000mAh 3.7V LiPo battery provides about 7.4Wh — sufficient for less than 2 days of continuous operation. For battery-powered deployment, consider a pulsed-power approach: power the sensor only for 5 minutes every hour (enough for a reading after warm-up), which extends battery life to roughly 24 days from the same battery. However, you will miss any leak that occurs during the 55-minute off period.

What PPM level is dangerous for methane?

Methane is non-toxic in low concentrations but becomes an asphyxiant above 25% by volume (250,000 PPM) by displacing oxygen. The primary danger is fire and explosion: the Lower Explosive Limit (LEL) is 5% by volume (50,000 PPM) and the Upper Explosive Limit is 15% (150,000 PPM). Alarm thresholds for gas detectors are typically set at 10–25% of LEL (5,000–12,500 PPM) for early warning. The MQ-4’s range of 300–10,000 PPM covers this warning zone well.

How do I prevent false alarms from cooking fumes?

Mount the sensor away from cooking areas and kitchen exhausts. Add a software filter: only trigger an alarm if the reading stays above threshold for 10 or more consecutive readings (20 seconds at a 2-second interval). Brief spikes from cooking fumes typically last only 1–2 readings. True gas leaks create sustained elevated readings. Also implement a rate-of-change filter: cooking fumes cause sharp spikes that resolve quickly, while gas leaks cause gradual, sustained increases.

Does the MQ-4 detect LPG?

Yes, the MQ-4 has some cross-sensitivity to LPG (propane/butane), but its response curve is optimised for methane. For dedicated LPG detection, use the MQ-5 (LPG + natural gas) or MQ-2 (LPG + propane + hydrogen + smoke). If you need to distinguish between a natural gas leak and LPG in the same installation, you would need both MQ-4 and MQ-5 sensors and compare their response ratios.

Build your gas detection project with confidence. Zbotic stocks MQ-series gas sensors, sensor sockets, Arduino boards, and all the components for a complete multi-gas monitoring station. Fast delivery across India. Shop Gas Sensors at Zbotic →

Tags: gas detection system, LNG leak detector, methane sensor Arduino, MQ-4 gas sensor, natural gas sensor
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
SCD41 CO2 Sensor: True CO2 Mea...
blog scd41 co2 sensor true co2 measurement for indoor air quality monitoring 596525
blog digital servo vs analog servo speed accuracy power differences 596527
Digital Servo vs Analog Servo:...

Related posts

Svg%3E
Read more

Encoder Module: Position and Speed Measurement with Arduino

April 1, 2026 0
A rotary encoder converts the angular position and rotation speed of a shaft into electrical signals that Arduino can count... Continue reading
Svg%3E
Read more

Infrared Obstacle Sensor: Line Follower and Object Detection

April 1, 2026 0
Infrared obstacle sensors are the building blocks of line-following robots, edge detection systems, and proximity triggers. These tiny modules emit... Continue reading
Svg%3E
Read more

Rain Sensor and Raindrop Detection Module: Arduino Guide

April 1, 2026 0
A rain sensor module detects the presence of water droplets on its surface, giving Arduino a simple signal to trigger... Continue reading
Svg%3E
Read more

LiDAR Sensor TFmini: Distance Measurement Beyond Ultrasonic

April 1, 2026 0
When ultrasonic sensors hit their limits — range too short, accuracy too coarse, outdoor sunlight causing interference — LiDAR sensors... Continue reading
Svg%3E
Read more

Pressure Sensor BMP280: Weather Station and Altitude Meter

April 1, 2026 0
The BMP280 barometric pressure sensor by Bosch measures atmospheric pressure with ±1 hPa accuracy and temperature with ±1°C precision. These... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now