ArrowtronElectronics Store
Free shipping over ₹999
100% genuine components
Dispatch in 1–2 days
Secure payments · UPI, Cards

Gas Leak Detector with MQ-2 Sensor and Alarm

Protect your kitchen or workshop: this MQ-2 based detector sounds a loud alarm and lights a red LED the moment it sniffs LPG, smoke or other combustible gases.

Beginner~1 hour7 components

What you’ll build

The MQ-2 sensor outputs a voltage that rises with gas concentration. The Arduino Nano compares it against a calibrated threshold and, when exceeded, drives an active buzzer and red LED. A green LED shows the air is clean.

Components you’ll need

ComponentQtyPrice
Arduino Nano ATmega328P Compatible Board1₹149
Gas Sensor MQ-21₹99
Active Buzzer1₹299
5mm Red LED1₹149
5mm Green LED1₹19
220 Ohm 1/4W2₹98
400 Point Breadboard1₹299
Total₹1,112

Step-by-step guide

  1. Wire the MQ-2: VCC to 5V, GND to GND, A0 to the Nano’s A0. Let it pre-heat for 2–3 minutes before trusting readings.
  2. Connect the buzzer to D8 and GND.
  3. Wire the red LED to D9 and the green LED to D10, each through a 220Ω resistor to GND.
  4. Upload the sketch and open the Serial Monitor to watch the baseline reading in clean air.
  5. Briefly press an unlit lighter near the sensor — the reading should spike and the alarm fire.
  6. Set THRESHOLD roughly 100–150 points above your clean-air baseline and re-upload.

The code

Clean-air baselines differ between sensors, so calibrate THRESHOLD using the Serial Monitor before relying on the alarm.

const int mq2=A0, buzzer=8, redLed=9, greenLed=10;
const int THRESHOLD = 400;   // calibrate in clean air first!
void setup(){
  pinMode(buzzer,OUTPUT); pinMode(redLed,OUTPUT); pinMode(greenLed,OUTPUT);
  Serial.begin(9600);
}
void loop(){
  int gas = analogRead(mq2);
  Serial.println(gas);
  bool danger = gas > THRESHOLD;
  digitalWrite(redLed,   danger);
  digitalWrite(greenLed, !danger);
  digitalWrite(buzzer,   danger);
  delay(300);
}

Build this project

Add all 7 required components to your cart in one click — total ₹1,112.

Add all components to cart
Scroll to Top