Table of Contents
- MQ2 Sensor Overview
- Circuit Wiring
- Arduino Code with Calibration
- Placement in Indian Homes
- Indian Fire Safety
- FAQ
MQ2 Sensor Overview
The MQ2 sensor detects smoke, LPG, propane, methane, alcohol, hydrogen, and carbon monoxide. The most popular gas/smoke sensor in Indian maker projects (Rs 40-100) due to wide sensitivity range and low cost. It has two outputs: digital D0 (triggers at threshold set by onboard potentiometer) and analog A0 (continuous voltage proportional to gas concentration). Critical: preheat for 20-48 hours before calibration in clean air. Fresh sensors show inaccurate readings until the heating element stabilises the sensing film. The sensor body becomes hot to the touch during operation – this is normal.
Circuit Wiring
- MQ2 VCC to 5V (from Arduino 5V pin, not USB-limited 5V), GND to GND
- MQ2 A0 to Arduino A0 (analog reading)
- MQ2 D0 to Arduino D2 (digital interrupt for instant alert)
- Piezo buzzer + 100 ohm resistor to Arduino D8
- Red LED (220 ohm) to Arduino D9
- Optional: SIM800L to D3/D4 (SoftwareSerial) for SMS alerts
Arduino Code with Calibration
#define MQ2_AO A0
#define BUZZER 8
int baseline=0, threshold=0;
void setup(){
Serial.begin(9600);
Serial.println("Warming up 20s...");
delay(20000);
long sum=0;
for(int i=0;i<100;i++){ sum+=analogRead(MQ2_AO); delay(10); }
baseline=sum/100;
threshold=baseline*1.5; // 50% above clean air
Serial.print("Baseline: "); Serial.print(baseline);
Serial.print(" Threshold: "); Serial.println(threshold);
}
void loop(){
int reading=analogRead(MQ2_AO);
if(reading > threshold){
tone(BUZZER,2200);
Serial.print("ALARM: "); Serial.println(reading);
} else { noTone(BUZZER); }
delay(100);
}
Placement in Indian Homes
- Kitchen: Ceiling 30-60cm from cooking area. Not directly above stove (steam causes false alarms). For LPG leak detection, mount at 30cm above floor near the cylinder connection (LPG is heavier than air).
- Bedroom: Ceiling centre. Smoke rises and collects at ceiling first.
- Living room: Near the electrical distribution board for electrical fire detection.
- False alarm reduction: Add 15-second sustained-reading filter – alarm only if threshold exceeded continuously for 15+ seconds. This rejects brief cooking smoke while maintaining sensitivity to real fires.
Indian Fire Safety
Bureau of Indian Standards IS 2189 governs fire alarm systems. Commercial premises require certified detection per National Building Code (NBC) 2016. DIY MQ2 systems are suitable for personal awareness but not a substitute for IS 11360 certified smoke detectors required for commercial compliance. Certified photoelectric detectors (better at distinguishing cooking aerosol from fire smoke): Rs 500-800 from Ravel, Honeywell, and Siemens at Indian electrical wholesalers.
Frequently Asked Questions
Does MQ2 detect cooking smoke vs real fire?
MQ2 detects both but cannot distinguish them. Indian high-heat cooking (tadka, deep frying) frequently triggers basic threshold alarms. Add a 15-second sustained-reading filter and use a higher threshold (2x clean air baseline instead of 1.5x) for kitchen installations. A photoelectric smoke detector is better at distinguishing cooking aerosol from real fire smoke.
Can MQ2 replace a certified smoke detector for building compliance?
For personal awareness – yes. For building compliance, insurance, or safety-critical applications – no. IS 11360 certified detectors use ionisation or photoelectric methods calibrated specifically to fire particle sizes.
MQ2 reads high values in clean air – is it defective?
New MQ2 sensors read 400-800 analog in clean air for the first few hours. Leave powered for 24-48 hours and re-measure baseline. If still high after 48h, test outdoors to rule out background gas levels. Kitchen vapour exposure over extended periods degrades the sensing film.
How do I send SMS alarm with SIM800L?
Connect to Arduino SoftwareSerial. In alarm code: send AT+CMGF=1, AT+CMGS=”+91XXXXXXXXXX”, message text, then 0x1A (chr 26). Use Jio or Airtel prepaid SIM. Note: SIM800L requires 4.1V supply – use AMS1117-4.0 regulator or dedicated LiPo, not Arduino 5V directly.
Add comment