Unik Systems Logo
Unik Systems
Back to knowledge base
guides

Home Safety Alert: MQ-2 Gas & Smoke Detector with Buzzer & Arduino

Build a critical life-safety detector that sounds a high-decibel audible alarm and warning LED when LPG, methane, propane, or smoke is detected.

Kunal (Founder & Owner) 1 min read8 Oct 2026
Home Safety Alert: MQ-2 Gas & Smoke Detector with Buzzer & Arduino

Home Safety Alert: MQ-2 Gas & Smoke Detector with Buzzer & Arduino

Liquefied petroleum gas (LPG) and combustible gas leaks in home kitchens or 3D printer enclosures pose severe safety hazards. The MQ-2 electrochemical gas sensor utilizes a tin-dioxide (SnO2) sensitive layer whose electrical conductivity increases in the presence of combustible hydrocarbons and smoke particles.


1. Pin Connections

  • MQ-2 VCC → Arduino 5V
  • MQ-2 GND → Arduino GND
  • MQ-2 AOUT → Arduino Analog A0
  • Buzzer (+) → Arduino Digital Pin 8
  • LED Anode → Arduino Digital Pin 9 (via 220Ω resistor)

2. Arduino Code

cpp
const int GAS_PIN = A0; const int BUZZER_PIN = 8; const int LED_PIN = 9; const int ALARM_THRESHOLD = 300; void setup() { Serial.begin(9600); pinMode(BUZZER_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT); Serial.println("MQ-2 Preheating (approx 20 seconds)..."); } void loop() { int gasLevel = analogRead(GAS_PIN); Serial.print("Current Gas Level: "); Serial.println(gasLevel); if (gasLevel > ALARM_THRESHOLD) { digitalWrite(LED_PIN, HIGH); tone(BUZZER_PIN, 1000); // 1KHz alarm tone } else { digitalWrite(LED_PIN, LOW); noTone(BUZZER_PIN); } delay(300); }

Parts used in this tutorial

Buy them in one click — ships from Pune across India.

3 ITEMS
Approx. total ₹400.65 (before GST)Add all to cart
#safety#gas-sensor#arduino#diy
Found this useful? Tell us what you'd like to read next via our RFQ form.