Skip to content

Real-time methane detection (MQ-4/MQ-135) in Python with calibration, smoothing, thresholding, logging, and optional PPM estimation. Includes serial & simulator modes.

License

Notifications You must be signed in to change notification settings

SoheilGtex/methane-gas-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧪 Methane Gas Detection (Python)

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.


Table of Contents


Overview

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.


Features

  • 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)

Tech Stack

Category Technologies
Language Python
I/O pyserial (Serial), simulator source
Data numpy, pandas
Viz matplotlib
Config pyyaml

Repository Structure

About

Real-time methane detection (MQ-4/MQ-135) in Python with calibration, smoothing, thresholding, logging, and optional PPM estimation. Includes serial & simulator modes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages