Intermediate Project
Gas Alert System
Using Arduino
Detect LPG, methane & smoke with an MQ-2 sensor. Triggers buzzer + LED on gas leak. Includes circuit diagram, code, and Tinkercad simulation.
🔥 Why this project?
Gas leaks from LPG cylinders cause thousands of home fires every year. This simple Arduino circuit gives you an instant audible + visual alarm — easy to build, cheap, and potentially life-saving.
01
Objectives
- ✓ Detect harmful gases — LPG, methane, and smoke
- ✓ Trigger dual alert: buzzer (audible) + LED (visual)
- ✓ Build a low-cost, real-world safety system
- ✓ Learn MQ-2 sensor interfacing with Arduino
02
Components Required
Arduino UNO
MQ-2 Gas Sensor
Red LED
Buzzer
220Ω Resistor
Breadboard
Jumper Wires
03
Circuit Diagram
gas_alert_circuit.json
5V Power
GND
Analog A0
Digital D7 (LED)
Digital D8 (Buzzer)
04
Step-by-Step Wiring
STEP 1
Connect MQ-2 Gas Sensor
VCC → 5V (Arduino)
GND → GND (Arduino)
A0 → Analog Pin A0
STEP 2
Connect Red LED
Long leg (+) → D7 via 220Ω resistor
Short leg (−) → GND
STEP 3
Connect Buzzer
Positive (+) → Digital Pin D8
Negative (−) → GND
💡 Pro Tip
Always connect the 220Ω resistor in series with the LED to prevent burning it out. Without the resistor, excess current will destroy the LED.
05
Working Principle
06
Arduino Code
// ── Gas Alert System | MakeMindz.com ────────────── // Detects LPG, methane, smoke via MQ-2 sensor // Triggers buzzer + LED when gas exceeds threshold // ── Pin Definitions ────────────────────────────── int gasSensor = A0; // MQ-2 analog output → A0 int led = 7; // Red LED → Digital Pin 7 int buzzer = 8; // Buzzer → Digital Pin 8 int threshold = 300; // Adjust based on sensor sensitivity // ── Setup ──────────────────────────────────────── void setup() { pinMode(led, OUTPUT); pinMode(buzzer, OUTPUT); Serial.begin(9600); // Open Serial Monitor for live readings Serial.println("Gas Alert System Ready!"); } // ── Main Loop ──────────────────────────────────── void loop() { int gasValue = analogRead(gasSensor); // 0–1023 Serial.print("Gas Level: "); Serial.println(gasValue); if (gasValue > threshold) { // ⚠ Gas detected — activate alerts digitalWrite(led, HIGH); digitalWrite(buzzer, HIGH); Serial.println("⚠ WARNING: Gas Detected!"); } else { // ✓ Air is clean — keep quiet digitalWrite(led, LOW); digitalWrite(buzzer, LOW); } delay(500); // Check every 500 milliseconds }
⚙️ Calibration Tip
The default threshold is 300. Open the Serial Monitor (9600 baud) and check the readings in clean air vs. near a gas source. Set your threshold 20–30% above the clean-air reading for reliable detection.
07
Tinkercad Simulation
🧪 Try it in Tinkercad
No hardware? Run the complete circuit simulation online — drag the MQ-2 sensor slider to trigger the alert.
Open SimulationHow to run the simulation:
1
Open Tinkercad
Click the simulation button above to open the pre-built circuit
2
Click "Start Simulation"
The green Start button at the top right of the Tinkercad editor
3
Open Serial Monitor
Click "Serial Monitor" (bottom panel) to see live gas readings
4
Adjust Sensor Slider
Click on the MQ-2 sensor and drag the gas concentration slider above 300 — the LED lights up and buzzer activates
5
Test & Modify
Change the threshold value in the code and re-simulate to see the difference
08
Real-World Applications
🍳
Home Kitchen Monitoring🏭
Industrial Safety🧪
Laboratory Safety🏠
Smart Home Systems📡
IoT Gas Monitoring🚗
Parking Garages
🚀 Level Up This Project
Add a GSM module (SIM800L) to send SMS alerts when gas is detected. Connect an LCD display to show real-time gas readings. Or integrate with a relay to automatically cut off gas supply.
⚡
More Arduino Projects
BEGINNER
📏 Ultrasonic DistanceBeginner
🚦 Traffic Light SimBeginner
🔢 7-Segment CounterBeginner
🌡️ Temperature SensorBeginner
INTERMEDIATE
ADVANCED
Comments
Post a Comment