Real-time methane detection using MQ-4/MQ-135 in Python. Includes Serial & Simulator modes, calibration, smoothing, hysteresis-based alerting, CSV logging, and optional PPM estimation.
- Overview
- Features
- Tech Stack
- Repository Structure
- Quickstart
- Hardware (Optional)
- Configuration
- Detection Logic
- CLI Usage
- Outputs
- Troubleshooting
- Roadmap
- License
- Author
This project provides a clean, reproducible template for real-time methane detection using low-cost gas sensors (MQ-4 / MQ-135). It supports both Serial (Arduino/ESP32) and Simulator modes, enabling quick experimentation without hardware. A simple detection pipeline uses auto-calibration, smoothing (EMA/MA), and hysteresis to reduce noise and flicker.
⚠️ Disclaimer: PPM estimation here is approximate and not suitable for industrial safety. For safety-critical use, employ certified equipment.
- Serial & Simulator modes (switchable)
- Auto-calibration (mean/σ) over a warm-up window
- Smoothing: Exponential Moving Average (EMA) or Moving Average (MA)
- Hysteresis-based alerting to avoid flapping
- CSV logging (timestamp, raw, smooth, alert, ppm)
- Static plot generation (PNG) for quick analysis
- Configurable via
config.yaml - Optional PPM estimation from Rs/R0 curve (very rough)
| Category | Technologies |
|---|---|
| Language | Python |
| I/O | pyserial (Serial), simulator source |
| Data | numpy, pandas |
| Viz | matplotlib |
| Config | pyyaml |