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
| 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
- MQ-2 sensor continuously monitors gas levels.
- Arduino reads analog values from the sensor.
- When gas exceeds threshold:
- Buzzer turns ON
- LED glows
- Arduino sends AT commands to SIM800L module.
- GSM module sends SMS alert to predefined number.
- 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
SoftwareSerialcreates communication with GSM moduleanalogRead()reads MQ-2 values- Threshold defines danger level
- When exceeded:
- Alarm activates
sendSMS()function is called
- AT commands used:
AT→ check moduleAT+CMGF=1→ text modeAT+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