Arduino GSM Gas Leakage Alert System

 
Model Picture

1. Introduction

Gas leakage detection becomes much more powerful when combined with real-time alerts. In this project, we enhance the basic MQ-2 gas detector by integrating a GSM module (SIM800L) to send an SMS alert when gas leakage is detected.

This system is highly useful for:

  • Homes and kitchens
  • Laboratories
  • Industrial safety systems

It ensures that even if you are not nearby, you will still receive a warning message instantly.


2. Components

  • Arduino UNO
  • MQ-2 Gas Sensor Module
  • SIM800L GSM Module
  • Buzzer
  • LED
  • 220Ω Resistor
  • Resistors (10kΩ & 20kΩ for voltage divider)
  • Breadboard
  • Jumper Wires
  • 3.7V Li-ion Battery (for SIM800L)

3. Circuit and Connections

Arduino Uno Pinout Diagram
Arduino Uno Pinout Diagram

Pinout Diagram of MQ-2 Sensor
Pinout Diagram of MQ-2 Sensor


Pinout Diagram SIM800L GSM Module
Pinout Diagram SIM800L GSM Module

Pin Connection to SIM800L GSM Module
Arduino Pin interfacing to SIM800L GSM Module

Pinout Diagram of Buzzer
Pinout Diagram of Buzzer

🔌 Connections:

MQ-2 Sensor → Arduino

  • VCC → 5V
  • GND → GND
  • A0 → A0

SIM800L → Arduino

  • VCC → 3.7V Battery ⚠️ (DO NOT connect to 5V)
  • GND → GND (common ground with Arduino)
  • GSM TX → Pin 10 (Arduino RX)
  • GSM RX → Pin 11 (Arduino TX) (voltage divider required since GSM is 3.3V and Arduino in 5V)

🔽 Voltage Divider (IMPORTANT)

  • Arduino TX (Pin 11) → 1kΩ → SIM800L RX
  • SIM800L RX → 5.6kΩ → GND

(This reduces 5V to ~3.3V safe for SIM800L)


Buzzer → Arduino

  • Positive → Pin 8
  • Negative → GND

LED → Arduino

  • Anode → Pin 7 (via 220Ω resistor)
  • Cathode → GND

4. Detailed Step-by-Step Circuit Working

  1. MQ-2 sensor continuously monitors gas levels.
  2. Arduino reads analog values from the sensor.
  3. When gas exceeds threshold:
    • Buzzer turns ON
    • LED glows
  4. Arduino sends AT commands to SIM800L module.
  5. GSM module sends SMS alert to predefined number.
  6. User receives warning message instantly 📩

5. Code

#include <SoftwareSerial.h>

SoftwareSerial gsm(10, 11); // RX, TX

int gasSensor = A0;
int buzzer = 8;
int led = 7;

int threshold = 300;

void setup() {
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);

Serial.begin(9600);
gsm.begin(9600);

delay(2000);
gsm.println("AT");
delay(1000);
gsm.println("AT+CMGF=1"); // SMS mode
delay(1000);
}

void loop() {
int gasValue = analogRead(gasSensor);
Serial.println(gasValue);

if (gasValue > threshold) {
digitalWrite(buzzer, HIGH);
digitalWrite(led, HIGH);

sendSMS();
delay(10000); // avoid repeated SMS
} else {
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
}

delay(500);
}

void sendSMS() {
gsm.println("AT+CMGS=\"+91XXXXXXXXXX\""); // Replace with your number
delay(1000);
gsm.println("⚠️ Gas Leakage Detected!");
delay(100);
gsm.write(26); // CTRL+Z
delay(5000);
}

6. Detailed Step-by-Step Code Working

  • SoftwareSerial creates communication with GSM module
  • analogRead() reads MQ-2 values
  • Threshold defines danger level
  • When exceeded:
    • Alarm activates
    • sendSMS() function is called
  • AT commands used:
    • AT → check module
    • AT+CMGF=1 → text mode
    • AT+CMGS → send SMS

7. Tips

  • SIM800L requires stable 3.7V (high current) ⚠️
  • Use Li-ion battery (recommended)
  • Ensure proper network signal
  • Add capacitor (1000µF) across power for stability
  • Avoid continuous SMS sending (use delay)
  • Test GSM separately before integrating

8. Uses

  • Smart kitchen safety system
  • Industrial gas monitoring
  • LPG leakage alert system
  • Remote safety monitoring

9. Conclusion

This project demonstrates a real-world IoT-ready safety system using Arduino. By combining gas sensing with GSM communication, you can monitor hazardous situations remotely. It is a powerful upgrade from basic detection systems.

Note: Follow the below given link for detailed GSM Interface and Commands

https://simplebasicelectronics.blogspot.com/2026/04/arduino-gsm-sim800l-interfacing.html

Note: Follow the below given link for detailed MQ-2 Interface

https://simplebasicelectronics.blogspot.com/2026/03/arduino-gas-leak-detector-using-mq-2.html

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.