Skip to content

Repository files navigation

GasLeakShield 🛡️

Low-Cost Smart Gas Leak Detector with ESP32 + Flutter Mobile App

A real-time, affordable LPG/gas leak monitoring system that detects leaks using MQ-2/MQ-5 sensors, compensates for humidity & temperature false alarms (via DHT11/22), triggers local buzzer/LED, and sends live data + alerts to your phone via MQTT.

Built for kitchens, homes, garages — prevents disasters with smart logic instead of simple threshold triggering.

image image

✨ Features

  • Smart Detection Logic (3-layer):

    • Rate of change (sudden spikes)
    • Duration (sustained high reading)
    • Stability + humidity compensation (avoids false alarms from steam/shower)
  • Local Alarm — Buzzer + LED on device

  • Mobile App (Flutter) — Real-time gas level, humidity, temperature, leak status

  • MQTT — Reliable, low-latency data sync (works over Wi-Fi)

  • Low-Cost — Uses common components (~$10–15 total excluding ESP32)

  • Responsive, trendy dark UI with animations on alert

  • Easy to tune thresholds for your environment

🛠️ Hardware Required

Component Recommended Model Approx. Price
Microcontroller ESP32 DevKit / NodeMCU-32S $5–8
Gas Sensor MQ-2 or MQ-5 $2–4
Temp/Humidity DHT11 or DHT22 $1–3
Buzzer Active/Passive $0.5
LED + resistor Red 5mm $0.2
Breadboard + wires $2–5

Total estimated cost: $12–25

🔌 Wiring

Sensor/Pin ESP32 Pin Note
MQ analog out GPIO 34 ADC pin
DHT data GPIO 4 4.7–10k pull-up resistor
Buzzer GPIO 2
LED (anode) GPIO 5 220Ω resistor to GND
VCC all sensors 3.3V or 5V MQ usually 5V
GND GND

🚀 Getting Started

1. ESP32 Firmware

  1. Install Arduino IDE or PlatformIO
  2. Add these libraries:
    • DHT sensor library
    • PubSubClient
    • WiFi (built-in)
  3. Copy code from /firmware/ folder
  4. Update WiFi credentials & MQTT broker (default: broker.emqx.io)
  5. Upload to ESP32

2. Flutter Mobile App

  1. Install Flutter SDK (3.24+ recommended)
  2. Go to /app/ folder
  3. Run:
    flutter pub get
    flutter run
  4. App connects automatically to the same public MQTT broker

3. Testing

  • In clean air → app should show low gas level (~100–200)
  • Use lighter gas from ~30–50 cm → after 5–10 seconds → alert triggers
  • Boil water nearby → should not false-trigger if humidity compensation tuned

📂 Project Structure

LeakSentry/
├── firmware/               # ESP32 Arduino sketch
│   └── LeakSentry.ino
├── app/                    # Flutter mobile application
│   ├── lib/
│   └── pubspec.yaml
├── docs/                   # Schematics, photos, tuning guide
├── images/                 # Screenshots & wiring diagrams
└── README.md

⚙️ Configuration & Tuning

Edit these in firmware/LeakSentry.ino:

#define ALERT_THRESHOLD  320     // Adjust after seeing clean-air avg
#define HIGH_HUMIDITY    82      // Raise threshold above this %
#define RATE_JUMP        60      // Sudden increase that counts as "fast"
#define MIN_DURATION     5       // Seconds to confirm leak

🔮 Future Improvements

  • Add push notifications (Firebase + MQTT trigger)
  • Historical charts in app (fl_chart)
  • Private MQTT broker support (TLS + credentials)
  • Over-the-air (OTA) updates
  • Multi-sensor / multi-room support
  • Battery-powered version

📜 License

MIT License — feel free to use, modify, and share!

🙌 Acknowledgments

  • Inspired by low-cost IoT safety projects
  • Thanks to: PubSubClient, flutter_mqtt_client, DHT library authors
  • Built with ❤️ by Khalid

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages