🔥 IoT Gas Leakage Detection System using ESP32
Overview
Gas leakage is one of the major safety concerns in homes and industries. This project uses an ESP32 microcontroller and MQ-2 gas sensor to detect harmful gas leaks such as LPG, methane, and smoke. The system can alert users instantly and can be extended with IoT features for remote monitoring.
Project Details
Controller
ESP32
ESP32
Sensor
MQ-2 Gas Sensor
MQ-2 Gas Sensor
Output
Buzzer / LED
Buzzer / LED
Level
Beginner to Intermediate
Beginner to Intermediate
Components Required
- ESP32 Development Board
- MQ-2 Gas Sensor
- Buzzer
- LED Indicator
- Jumper Wires
Working Principle
The MQ-2 sensor detects gas concentration in the air. When the gas level exceeds a threshold, the ESP32 reads the signal and activates a buzzer or LED alert. This system can be enhanced with IoT notifications using Wi-Fi.
Connections
MQ-2 Sensor
VCC → 5V
GND → GND
OUT → GPIO 34
VCC → 5V
GND → GND
OUT → GPIO 34
Buzzer
Positive → GPIO 25
Negative → GND
Positive → GPIO 25
Negative → GND
ESP32 Code
Arduino Code
#define GAS_SENSOR 34
#define BUZZER 25
void setup(){
pinMode(GAS_SENSOR, INPUT);
pinMode(BUZZER, OUTPUT);
Serial.begin(9600);
}
void loop(){
int gasValue = analogRead(GAS_SENSOR);
Serial.println(gasValue);
if(gasValue > 300){
digitalWrite(BUZZER, HIGH);
} else {
digitalWrite(BUZZER, LOW);
}
delay(500);
}
Applications
- Home gas leakage safety system
- Industrial gas monitoring
- Smart IoT safety solutions
- Fire hazard detection
Conclusion
This project demonstrates a simple yet powerful safety system using ESP32. It can be extended to send alerts via mobile apps or integrated into smart home ecosystems.
