The problem
A gas stove left burning unattended is one of the most ordinary kitchen risks: a pot boils over, a flame blows out, or a cook steps away and forgets the burner. A manual knob cannot help once nobody is watching it, and a standalone gas alarm can only sound — it cannot stop the gas. This project answers that gap: an IoT-based smart kitchen gas stove auto-off system built around an ESP32, an MQ-2 gas sensor, a relay and a 12 V solenoid valve in the gas line. The cook sets a timer on the keypad or dashboard; at zero, the ESP32 de-energises the relay, the valve closes and the burner is cut off. The MQ-2 sensor watches the air; if the gas level crosses the leak threshold, the valve closes at once and the buzzer sounds, whatever the timer says. The LCD shows the timer and gas status. It is a prototype safety aid, not a certified gas-safety device.
| Manual stove monitoring | This project: auto-off + leak alert | |
|---|---|---|
| Forgotten burner | Gas keeps flowing until someone notices | Timer ends the gas supply automatically |
| Gas leak | Noticed only by smell, often too late | MQ-2 sensor detects LPG and closes the valve |
| Away from the kitchen | No visibility or control | Dashboard shows gas level, timer and valve state |
| After an event | No record of what happened | Event log records every auto-off and leak |
Reads LPG and smoke levels near the stove, range 300-10000 ppm.
Follow the working sequence
How it works
The chain runs from sensing to shut-off in four stages. The MQ-2 gas sensor sits near the stove and its heated tin-dioxide element changes resistance as LPG or smoke reaches it; the ESP32 reads that resistance through its 12-bit ADC and converts it to a gas level in ppm. In parallel, the timer counts down from the value entered on the keypad or dashboard, and the ESP32 compares the gas level against two thresholds — 1,000 ppm for a warning and 2,000 ppm for a leak. If the timer reaches zero, the ESP32 switches the relay off, the 12 V solenoid valve closes and the burner is cut off; if the gas level crosses the leak threshold first, the same shut-off happens immediately and the buzzer sounds. The 16x2 LCD mirrors the timer and status locally, while the dashboard shows the live gas level, timer, valve state and event log.
- The MQ-2 sensor warms up after power-on; the firmware shows WARMING UP on the LCD and holds the valve closed for the first 3 minutes (design behaviour) while the heater stabilises.
- The cook sets a cooking timer of 1 to 99 minutes (design range) on the 4x4 keypad or the web dashboard, and the ESP32 starts the countdown.
- The ESP32 reads the MQ-2 sensor continuously and converts the reading to a gas level in ppm, comparing it every second with the 1,000 ppm warning and 2,000 ppm leak thresholds (configurable design values).
- Crossing the warning threshold sounds the buzzer and flags a warning on the LCD and dashboard; falling back below it silences the buzzer.
- Crossing the leak threshold, or the timer reaching zero, makes the ESP32 de-energise the relay, so the normally-closed solenoid valve shuts the gas supply and the buzzer sounds.
- The dashboard and LCD update to show the valve state, and the event is written to the timestamped log with the gas level at the time.
- After the cause is checked, the cook re-opens the valve from the dashboard or keypad and sets a fresh timer for the next use.
Tech stack:
- ESP32 (Wi-Fi microcontroller)
- MQ-2 gas sensor module
- Arduino IDE (ESP32 firmware)
- Relay module · 12 V solenoid valve
- 16x2 LCD · 4x4 membrane keypad
- HTML · CSS · JavaScript dashboard
- 5 V · 12 V power supply
| Parameter | Value |
|---|---|
| Controller | ESP32 dual-core, Wi-Fi 802.11 b/g/n (datasheet value) |
| Gas sensor | MQ-2, LPG / propane / smoke, detection range 300–10,000 ppm (datasheet value) |
| Sensor heater | 5 V supply, heater power less than 800 mW (datasheet value) |
| Warm-up behaviour | Readings drift while the heater warms up; datasheet specifies preheat over 24 hours for full stability, firmware ignores readings for the first 3 minutes after power-on (design behaviour) |
| Warning threshold | 1,000 ppm (configurable design value) |
| Leak threshold | 2,000 ppm (configurable design value) |
| Shut-off valve | 12 V DC normally-closed solenoid valve, closes when de-energised (design choice) |
| Timer range | 1–99 minutes, set from keypad or dashboard (design range) |
| Valve response | Approximately 2 seconds from threshold crossing to valve closure (design target) |
| Display | 16x2 LCD showing timer, gas status and valve state |
| Buzzer | 5 V active buzzer for warning and leak alerts |
| Power supply | 5 V 2 A for logic and sensors, 12 V 1 A for the valve coil (design target) |
| Dashboard | ESP32 web dashboard over Wi-Fi: live ppm, timer, valve state, event log |
Project features
The build combines four capabilities that matter most in a kitchen safety prototype: a cooking timer that ends the gas supply by itself, continuous MQ-2 leak sensing that closes the valve on a leak, a local keypad and LCD so the stove works without a phone, and a web dashboard that shows gas level, timer, valve state and a full event log. Together they cover the two failure modes students are asked about most — a forgotten burner and an unnoticed leak — with a manual override that always lets the cook close or re-open the valve from the dashboard. Every feature below is implemented in the base build, and the safety limits of the prototype are stated in the same list as its capabilities, so the page never oversells what the hardware can do.
- [Cooking timer auto-off] The cook sets a timer of 1 to 99 minutes (design range) from the 4x4 keypad or the web dashboard. When the timer reaches zero, the ESP32 de-energises the relay and the normally-closed solenoid valve shuts the gas supply to the burner.
- [MQ-2 leak detection with automatic shut-off] The MQ-2 sensor reads the air continuously for LPG, propane and smoke. Crossing the 2,000 ppm leak threshold (configurable design value) closes the valve immediately and sounds the buzzer, regardless of the timer.
- [Two-stage gas warning] Crossing the 1,000 ppm warning threshold (configurable design value) sounds the buzzer and flags a warning on the dashboard and LCD, giving an early alert before the leak threshold is reached.
- [Keypad and LCD local control] A 4x4 keypad and 16x2 LCD set the timer, show the countdown and display the gas status, so the stove can be operated entirely without Wi-Fi or a phone.
- [Web dashboard with live status and event log] The ESP32 serves a dashboard over Wi-Fi showing live gas level in ppm, leak status, timer countdown, valve state and a timestamped log of every timer, warning, leak and valve event.
- [Manual valve override] A dashboard button closes the valve at any moment, and a re-open button restores the gas supply after the cause has been checked, so the cook always stays in control.
- [Fail-safe normally-closed valve] The solenoid valve is normally closed, so it needs power to stay open: a power cut de-energises the coil and the gas path closes instead of staying open.
What is included
- Working hardware prototype: ESP32 board, MQ-2 sensor, relay module, 12 V solenoid valve, 16x2 LCD, 4x4 keypad, buzzer and model burner on a base board
- Complete ESP32 firmware (Arduino IDE) with timer, two-stage thresholds, warm-up hold and event logging
- Web dashboard (single-file HTML, CSS and JavaScript) with live gas level, timer, valve control and event log
- Circuit and wiring documentation with component list
- Project report PDF (background, methodology, architecture, results, limitations)
- PPT presentation for final review
- Viva Q&A preparation document (MQ-2 sensing, thresholds, relay and valve action, fail-safe behaviour)
Limitations & prerequisites
- This is a prototype safety aid, not a certified gas-safety device: it does not replace a certified gas detector, correct installation by a qualified technician, or supervision of a live burner.
- The MQ-2 sensor is a broad-response gas sensor, not a calibrated LPG meter: readings in ppm are indicative, vary with temperature, humidity and sensor age, and need clean-air calibration before use.
- The MQ-2 heater needs warm-up time and the datasheet specifies preheat over 24 hours for full stability, so readings taken immediately after power-on are unreliable and the firmware holds the valve closed for the first 3 minutes.
- The system cannot prevent all accidents: it cannot detect a leak downstream of the valve, a damaged pipe, or a burner left on with the timer set longer than the cooking time.
- The solenoid valve is rated for the prototype's low-pressure demonstration gas line only; connecting it to a household LPG supply needs a qualified technician and a valve rated for that line.
- Wi-Fi dashboard functions need a local Wi-Fi network; timer, keypad, LCD, sensing and shut-off all work without Wi-Fi.
- The 12 V solenoid valve draws holding current while open, so the 12 V supply must stay connected during cooking; a power cut closes the valve by design.
Frequently Asked Questions
Is this project suitable for a final-year project?
Yes — it fits Electronics, Electrical and IoT & Embedded programmes, because one build demonstrates sensor interfacing, threshold logic, relay and actuator control, timer design, Wi-Fi dashboards and a real safety application with honest limits. The report explains the MQ-2 sensing principle, the two-stage thresholds and the fail-safe valve choice, which gives the guide concrete technical questions to ask and the student concrete answers.
Which controller and sensor are used, and why?
An ESP32 and an MQ-2 gas sensor. The ESP32 provides Wi-Fi for the dashboard, enough ADC and GPIO pins for the sensor, keypad, LCD, relay and buzzer, and runs the timer and threshold logic in firmware. The MQ-2 is the standard low-cost sensor for LPG, propane and smoke, with a datasheet detection range of 300–10,000 ppm, which matches a kitchen demonstration.
Does it work without Wi-Fi?
Yes — the core safety functions work fully offline. The timer, keypad, LCD, MQ-2 sensing, buzzer and automatic valve shut-off all run in the ESP32 firmware with no network. Wi-Fi only adds the dashboard: live gas level, timer display, valve control and the event log. If the network drops, the stove keeps its timer and leak protection.
What power supply does it need?
Two supplies: 5 V at 2 A for the ESP32, MQ-2 sensor, LCD and buzzer, and 12 V at 1 A for the solenoid valve coil (design target). The valve is normally closed, so it draws its holding current only while open, and a power cut de-energises the coil and closes the gas path by design.
Can the timer and thresholds be changed?
Yes — both are configurable in the firmware. The timer range is 1 to 99 minutes (design range), set from the keypad or dashboard without reprogramming, while the 1,000 ppm warning and 2,000 ppm leak thresholds are constants in the code that can be adjusted after clean-air calibration in the actual kitchen.
Can GSM or mobile alerts be added?
Yes, as an optional customisation. A GSM module can be added so the ESP32 sends an SMS on a leak or auto-off event, and the dashboard can be extended to a mobile app. Neither is part of the base build, which uses the on-board buzzer, LCD and Wi-Fi dashboard for alerts.
Related Projectech builds: https://projectech.in/projects/smart-gas-leakage-detector-with-automatic-valve-shutoff/ · https://projectech.in/projects/esp32-smart-fire-gas-alarm-smoke-sensing-telegram-alerts/ · https://projectech.in/projects/smart-lpg-cylinder-monitor-weight-booking-leak-detection-esp32/
Components & software requirements
- ESP32 (Wi-Fi microcontroller)
- MQ-2 gas sensor module
- Arduino IDE (ESP32 firmware)
- Relay module · 12 V solenoid valve
- 16x2 LCD · 4x4 membrane keypad
- HTML · CSS · JavaScript dashboard
- 5 V · 12 V power supply
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.