Build an ESP32 Gas Leak Alarm System
Intermediate
Est. Time: 1.5 hours
Est. Total: $24.76
Create a real-world safety device that detects gas leaks and smoke using the MQ-2 sensor module and an ESP32 microcontroller. The system reads analog gas concentration values and triggers an audible alarm through the NE555 timer when dangerous levels are detected. With built-in WiFi, you can add push notifications to your phone. A practical project that combines analog sensing with digital logic and IoT connectivity.
Bill of Materials — Available in Our Shop
| Part | Qty | Price | Total | Status |
|---|---|---|---|---|
| ESP32-WROOM-32 DevKit (38-Pin, USB-C) Microcontroller — reads sensor data, controls alarm, WiFi alerts |
1 | $8.99 | $8.99 | In Stock |
| MQ-2 Gas Sensor Module Gas detection — senses smoke, LPG, butane, methane |
1 | $5.99 | $5.99 | In Stock |
| NE555 Timer IC (DIP-8) Alarm tone generator — drives the piezo buzzer |
1 | $0.99 | $0.99 | In Stock |
| 830-Point Breadboard + Jumper Wires + Power Supply Kit Prototyping platform with power supply and jumper wires |
1 | $7.99 | $7.99 | In Stock |
| Subtotal (from our shop) | $23.96 | |||
Additional Parts Needed
These common parts are available at most electronics retailers. Estimated prices shown for budgeting.
| Part | Qty | Est. | Total |
|---|---|---|---|
| Piezo Buzzer | 1 | $0.50 | $0.50 |
| Red LED (warning indicator) | 1 | $0.10 | $0.10 |
| 220 ohm Resistor | 1 | $0.05 | $0.05 |
| 1K ohm Resistor | 1 | $0.05 | $0.05 |
| 10K ohm Resistor | 1 | $0.05 | $0.05 |
| 0.1uF Ceramic Capacitor | 1 | $0.05 | $0.05 |
| Est. external subtotal | $0.80 | ||
Parts from our shop$23.96
Est. external parts$0.80
Est. Project Total$24.76
Step-by-Step Instructions
- Connect the MQ-2 sensor module to the breadboard. Wire VCC to ESP32 5V (VIN), GND to ESP32 GND, and the analog output to ESP32 GPIO 34 (ADC input).
- Build a basic NE555 astable circuit on the breadboard to generate an alarm tone. Use a 1K and 10K resistor with a 0.1uF capacitor for an audible ~1kHz frequency.
- Connect the NE555 output (pin 3) to the piezo buzzer. Wire ESP32 GPIO 25 to the NE555 reset pin (pin 4) to control when the alarm sounds.
- Wire the red LED with a 220 ohm resistor to ESP32 GPIO 2 as a visual warning indicator. GPIO 2 also controls the onboard LED.
- Upload the ESP32 sketch via USB-C: read the analog value from GPIO 34, compare against a threshold (typically 400-600 for gas detection), and set GPIO 25 HIGH when gas is detected. Optionally add WiFi code to send push notifications via IFTTT or a simple web server.
- Allow the MQ-2 sensor 2 minutes to warm up on first power-on. Test by holding a lighter (unlit, gas only) near the sensor — the alarm should trigger within seconds.