House fires claim thousands of lives in India every year, and most casualties occur because residents are not alerted in time. A smoke and fire alarm system with MQ-2 sensor and GSM alert built using Arduino provides dual protection: a loud local alarm for immediate evacuation plus an SMS notification to your phone when you are away from home. This guide walks you through building a complete smart fire alarm with Arduino that costs under ₹1,500.
Table of Contents
- How the System Works
- Components Required
- Understanding the MQ-2 Gas Sensor
- Circuit Design and Wiring
- Complete Arduino Code
- GSM SMS Alert Integration
- Sensor Calibration and Testing
- Frequently Asked Questions
- Conclusion
How the System Works
The system uses three detection methods for reliable fire detection:
- Smoke detection (MQ-2): Detects smoke particles, combustible gases (LPG, methane, hydrogen), and CO
- Temperature monitoring (DHT11/DS18B20): Rapid temperature rise indicates fire
- Flame detection (IR flame sensor): Detects infrared radiation from open flames
When any sensor crosses its threshold, the system activates a local buzzer alarm and sends an SMS to predefined phone numbers via the SIM800L GSM module. Using multiple sensor types reduces false alarms — for example, cooking smoke alone may trigger MQ-2 but not the flame sensor.
Components Required
- Arduino Uno R3: Main controller. ₹350-500.
- MQ-2 gas/smoke sensor module: Analogue + digital output. ₹80-150.
- DHT11 temperature/humidity sensor: For temperature monitoring. ₹60-100.
- IR flame sensor module: Detects flames up to 1 metre away. ₹50-100.
- SIM800L GSM module: For SMS alerts. ₹300-500. Requires SIM card with SMS plan.
- Buzzer (active): Loud piezo buzzer for local alarm. ₹20-40.
- Red LED: Visual alarm indicator. ₹5.
- 10K resistor: Pull-up for DHT11. ₹2.
- Jumper wires and breadboard: ₹100.
- 9V power adapter or battery: ₹100-200.
Total cost: approximately ₹1,000-1,500
Understanding the MQ-2 Gas Sensor
The MQ-2 is a semiconductor gas sensor that detects combustible gases and smoke. Key characteristics:
- Detection range: LPG, methane, propane, hydrogen, smoke, alcohol
- Concentration range: 300-10,000 ppm
- Warm-up time: 20 seconds (sensor heater must stabilise)
- Output: Analogue (0-5V proportional to gas concentration) + Digital (threshold-triggered)
- Heater voltage: 5V DC, draws approximately 150 mA (heater is always on)
The module has a potentiometer for adjusting the digital output threshold. The analogue output provides more precise readings and is preferred for smart systems.
Circuit Design and Wiring
Wiring Diagram:
MQ-2 Sensor:
VCC -> Arduino 5V
GND -> Arduino GND
A0 -> Arduino A0 (analogue reading)
D0 -> Arduino Pin 2 (digital threshold)
DHT11 Sensor:
VCC -> Arduino 5V
GND -> Arduino GND
DATA -> Arduino Pin 4 (with 10K pull-up to VCC)
IR Flame Sensor:
VCC -> Arduino 5V
GND -> Arduino GND
D0 -> Arduino Pin 3
SIM800L GSM Module:
VCC -> 3.7-4.2V (NOT 5V! Use LiPo or buck converter)
GND -> Arduino GND
TX -> Arduino Pin 7 (SoftwareSerial RX)
RX -> Arduino Pin 8 (SoftwareSerial TX via voltage divider)
Buzzer:
(+) -> Arduino Pin 9
(-) -> Arduino GND
Red LED:
Anode -> Arduino Pin 13 (through 220 ohm resistor)
Cathode -> GND
Complete Arduino Code
// Smart Smoke and Fire Alarm with GSM Alert
#include
#include
// Pin definitions
#define MQ2_ANALOG A0
#define MQ2_DIGITAL 2
#define FLAME_PIN 3
#define DHT_PIN 4
#define SIM800_RX 7
#define SIM800_TX 8
#define BUZZER 9
#define LED 13
// Thresholds
#define SMOKE_THRESHOLD 400 // Analogue value (0-1023)
#define TEMP_THRESHOLD 50.0 // Degrees Celsius
#define ALERT_COOLDOWN 60000 // Minimum 60s between SMS alerts
DHT dht(DHT_PIN, DHT11);
SoftwareSerial gsm(SIM800_RX, SIM800_TX);
unsigned long lastAlertTime = 0;
bool alarmActive = false;
// Phone numbers to alert (with country code)
const char* phoneNumbers[] = {"+919876543210", "+919012345678"};
const int numPhones = 2;
void setup() {
Serial.begin(9600);
gsm.begin(9600);
dht.begin();
pinMode(MQ2_DIGITAL, INPUT);
pinMode(FLAME_PIN, INPUT);
pinMode(BUZZER, OUTPUT);
pinMode(LED, OUTPUT);
// Wait for MQ-2 warm-up (20 seconds)
Serial.println("Warming up MQ-2 sensor...");
for (int i = 20; i > 0; i--) {
Serial.print(i);
Serial.print("s ");
delay(1000);
}
Serial.println("nFire Alarm System ACTIVE");
// Test GSM connection
gsm.println("AT");
delay(1000);
}
void loop() {
// Read all sensors
int smokeLevel = analogRead(MQ2_ANALOG);
bool smokeDigital = digitalRead(MQ2_DIGITAL) == LOW; // Active LOW
bool flameDetected = digitalRead(FLAME_PIN) == LOW; // Active LOW
float temperature = dht.readTemperature();
// Display readings
Serial.print("Smoke: ");
Serial.print(smokeLevel);
Serial.print(" | Temp: ");
Serial.print(temperature);
Serial.print("C | Flame: ");
Serial.println(flameDetected ? "YES" : "No");
// Check alarm conditions
bool smokeAlarm = (smokeLevel > SMOKE_THRESHOLD) || smokeDigital;
bool tempAlarm = (temperature > TEMP_THRESHOLD);
bool flameAlarm = flameDetected;
if (smokeAlarm || tempAlarm || flameAlarm) {
activateAlarm();
// Build alert message
String message = "FIRE ALERT! ";
if (smokeAlarm) message += "Smoke:" + String(smokeLevel) + " ";
if (tempAlarm) message += "Temp:" + String(temperature) + "C ";
if (flameAlarm) message += "Flame detected! ";
// Send SMS if cooldown has passed
if (millis() - lastAlertTime > ALERT_COOLDOWN) {
sendSMSAlert(message);
lastAlertTime = millis();
}
} else {
deactivateAlarm();
}
delay(1000);
}
void activateAlarm() {
if (!alarmActive) {
Serial.println("*** ALARM ACTIVATED ***");
alarmActive = true;
}
// Alternating buzzer pattern
tone(BUZZER, 3000, 500);
digitalWrite(LED, HIGH);
delay(500);
tone(BUZZER, 2000, 500);
digitalWrite(LED, LOW);
}
void deactivateAlarm() {
if (alarmActive) {
Serial.println("Alarm cleared");
alarmActive = false;
noTone(BUZZER);
digitalWrite(LED, LOW);
}
}
void sendSMSAlert(String message) {
for (int i = 0; i < numPhones; i++) {
Serial.print("Sending SMS to ");
Serial.println(phoneNumbers[i]);
gsm.println("AT+CMGF=1"); // Text mode
delay(500);
gsm.print("AT+CMGS="");
gsm.print(phoneNumbers[i]);
gsm.println(""");
delay(500);
gsm.print(message);
gsm.write(26); // Ctrl+Z to send
delay(3000);
Serial.println("SMS sent!");
}
}
GSM SMS Alert Integration
The SIM800L module requires special attention:
- Power supply: SIM800L needs 3.4-4.4V at up to 2A during transmission. Do NOT power from Arduino 5V or 3.3V pins. Use a dedicated LiPo battery (3.7V) or a 5V-to-4V buck converter.
- SIM card: Any 2G-compatible SIM with active SMS pack. In India, Airtel and BSNL 2G networks still work. Jio is 4G-only and will NOT work with SIM800L. Use SIM7600 for 4G.
- Voltage divider: SIM800L TX is 2.8V (fine for Arduino RX). Arduino TX is 5V — use a voltage divider (10K + 20K) or level shifter before connecting to SIM800L RX.
- Antenna: Always attach the antenna. Without it, the module draws excessive current trying to maintain signal.
WiFi Alternative: ESP32 with Telegram
For homes with WiFi, replace the GSM module with ESP32 and send alerts via Telegram bot. This eliminates the need for a SIM card and monthly recharge:
// ESP32 Telegram fire alert (simplified)
#include
#include
void sendFireAlert(String message) {
bot.sendMessage(CHAT_ID, "🔥 " + message, "");
}
Sensor Calibration and Testing
MQ-2 Calibration
- Power on the sensor and wait 24-48 hours for initial burn-in (first use only)
- Wait 20 seconds for warm-up on each subsequent power-on
- Read the baseline analogue value in clean air (typically 100-200)
- Set your alarm threshold at 2-3x the baseline value
- Test with a lit match (smoke) held 30cm from the sensor
Reducing False Alarms
- Use multiple sensor fusion: alarm only when 2 out of 3 sensors trigger
- Implement a confirmation delay: sensor must read above threshold for 5-10 seconds continuously
- Avoid placing MQ-2 near kitchens, bathrooms (steam), or windows (wind changes baseline)
- Use running average instead of raw readings to smooth sensor noise
Frequently Asked Questions
Can this replace a commercial fire alarm?
For personal/hobby use at home, yes, it provides effective detection and alerting. For commercial premises, you need BIS-certified fire alarm systems that comply with NBC (National Building Code) and fire safety regulations. This DIY system can supplement but should not replace certified equipment in commercial settings.
How far can the MQ-2 detect smoke?
The MQ-2 detects smoke effectively within 1-3 metres in an enclosed room. For larger areas, use multiple sensors placed according to fire code guidelines (one per 40-60 square metres, and within 3 metres of each bedroom door).
Will the SIM800L work with Jio SIM?
No. Jio operates only on 4G/VoLTE networks. The SIM800L is a 2G module. Use Airtel, Vodafone-Idea, or BSNL SIM cards. Alternatively, switch to SIM7600 module (₹1,500-2,500) for 4G compatibility, or use ESP32 with WiFi and Telegram instead of GSM.
How long does the system last on battery power?
The MQ-2 sensor heater alone draws ~150 mA continuously. Combined with Arduino and GSM module, the system draws 200-500 mA. On a 2,000 mAh battery, expect 4-10 hours. For long-term battery operation, use mains power with a UPS battery backup.
Can I add a sprinkler system?
Yes. Add a solenoid valve controlled by a relay module to activate a water sprinkler when the alarm triggers. Ensure the solenoid valve is rated for your water pressure and pipe size. This is a common engineering project extension for hackathons and final year projects.
Conclusion
A DIY smoke and fire alarm system with MQ-2 sensor and GSM alerts provides an effective safety net for your home at minimal cost. The combination of smoke detection, temperature monitoring, and flame detection reduces false alarms while ensuring rapid detection of real fires. SMS alerts ensure you are notified even when away from home.
This project is also an excellent choice for engineering students — it covers analog sensors, digital interfaces, GSM communication, and safety-critical system design. Build it, test it, and consider it your contribution to family safety.
Get all the sensors, modules, and components at Zbotic’s online store and build your fire safety system this weekend.
Add comment