SENI
KECANTIKAN & KESEJAHTERAAN
KRAFTANGAN
BUDAYA & SEJARAH
HIBURAN
ALAM SEKITAR
MAKANAN & MINUMAN
KEJURUTERAAN TERBALIK
SAINS
SUKAN
TEKNOLOGI
BOLEH PAKAI
Building a Methane Gas Leak Detector
Ed

Dicipta oleh

Ed

13. Julai 2026FI
38
0
0
0
0

Building a Methane Gas Leak Detector

Build a circuit that sniffs out methane — the main component of natural gas — and alarms when it rises. An MQ-4 sensor's reading climbs when combustible gas is present; the Arduino compares it to clean air and triggers a buzzer and red LED. A great combustible-gas sensing project — with two honest notes: methane is flammable, and this is a demonstration, NOT a certified gas-leak detector.

Pertengahan
1-2 hours

Arahan

1

Wire the sensor, buzzer and LED

On the breadboard: MQ-4 VCC to Arduino 5V, GND to GND, and its analog output (AOUT) to A0. Active buzzer + to pin 8, - to GND. Red LED anode to pin 7 through a 330 Ω resistor, cathode to GND.

Bahan untuk langkah ini:

Arduino Uno R3Arduino Uno R31 keping
Methane CNG Gas Sensor - MQ-4Methane CNG Gas Sensor - MQ-41 keping
Modul pembaz aktifModul pembaz aktif1 keping
LED 5 mmLED 5 mm1 keping
Perintang 330 ohmPerintang 330 ohm1 bungkus
Papan RotiPapan Roti1 keping
Wayar PelompatWayar Pelompat1 bungkus
2

Connect and open the IDE

Plug the Arduino into your computer with the USB cable, open the Arduino IDE, and select Arduino Uno and its serial port.

Alatan diperlukan:

Komputer dengan Arduino IDEKomputer dengan Arduino IDE
Kabel USB-BKabel USB-B
3

Upload the detector sketch

Paste this sketch and upload. It warms the sensor, records a clean-air baseline, then sounds the buzzer and lights the LED whenever the reading rises above that baseline.

methane_detector.inoarduino
// Methane / natural-gas leak INDICATOR using an MQ-4 sensor.
// NOT a certified gas-leak detector - see the safety note. Methane is flammable.
// MQ-4 analog output on A0; buzzer on pin 8; red warning LED on pin 7.

const int MQ4_PIN = A0;
const int BUZZER_PIN = 8;
const int LED_PIN = 7;

int cleanAirValue = 0;          // baseline, measured at startup
const int ALARM_MARGIN = 150;   // how far above baseline triggers the alarm

void setup() {
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);

  Serial.println("Warming up the MQ-4 (2 min) in clean air...");
  delay(120000);
  cleanAirValue = analogRead(MQ4_PIN);
  Serial.print("Clean-air baseline: ");
  Serial.println(cleanAirValue);
}

void loop() {
  int reading = analogRead(MQ4_PIN);
  Serial.println(reading);

  if (reading > cleanAirValue + ALARM_MARGIN) {
    digitalWrite(LED_PIN, HIGH);      // combustible gas above baseline -> alarm
    digitalWrite(BUZZER_PIN, HIGH);
  } else {
    digitalWrite(LED_PIN, LOW);
    digitalWrite(BUZZER_PIN, LOW);
  }
  delay(500);
}
4

Warm up, baseline and test SAFELY

Power it in fresh air and let the 2-minute warm-up set the baseline (a new MQ-4 also needs a 24–48 h burn-in). Test with only a TINY controlled source in a well-ventilated room — a brief puff of gas from an UNLIT lighter held near the sensor. NEVER test with a real gas leak, a large amount of gas, or anywhere near a flame or spark. Adjust ALARM_MARGIN for sensitivity.

5

Safety limits

Methane is highly flammable and, in enough concentration, explosive. This circuit is a LEARNING project and at best a supplementary indicator — it is NOT a certified gas-leak detector: the hobby MQ-4 gives a relative reading, not calibrated ppm, drifts, and needs re-baselining. For real protection use a certified natural-gas detector, and if you ever smell gas, do not switch anything on or off — leave and call your gas utility.

Bahan

7
  • 1 keping
    1 vendor sell this, none ship to you yet
    Pemegang Tempat
  • $5.00
  • Pemegang Tempat
  • 1 keping
    1 vendor sell this, none ship to you yet
    Pemegang Tempat
  • Pemegang Tempat
  • 1 keping
    1 vendor sell this, none ship to you yet
    Pemegang Tempat
  • 1 bungkus
    3 vendors sell this, none ship to you yet
    Pemegang Tempat

Alatan Diperlukan

3
  • Pemegang Tempat
  • 1 vendor sell this, none ship to you yet
    Pemegang Tempat
  • 1 vendor sell this, none ship to you yet
    Pemegang Tempat
Jumlah anggaran
Apa yang dibeli oleh pembuatnya. Bahan tanpa harga diperoleh di tempat anda membelinya.
$5.00

Blueprint berkaitan

Blueprint ini berkongsi pengetahuan — teknik, bahan atau prinsip

CC0 Domain Awam

Blueprint ini dikeluarkan di bawah CC0. Anda bebas menyalin, mengubah, mengedar, dan menggunakan karya ini untuk sebarang tujuan, tanpa meminta kebenaran.

Sokong Pembuat dengan membeli produk melalui Blueprint mereka di mana mereka memperoleh Komisen Pembuat ditetapkan oleh Penjual, atau cipta iterasi baru Blueprint ini dan sertakan ia sebagai sambungan dalam Blueprint anda sendiri untuk berkongsi hasil.

Perbincangan

(0)

Log masuk untuk menyertai perbincangan

Memuatkan komen...