
An Arduino Uno watching an MQ-2 (LPG and smoke) and an MQ-3 (alcohol and vapour). On a confirmed leak it sounds the buzzer, starts the exhaust fan, closes the gas valve with a servo, and sends an SMS through a SIM900 module.
| File | What it is |
|---|---|
firmware/gas_detector/gas_detector.ino | v2 firmware |
firmware/build/gas_detector.hex | Real-time build, SMS disabled until you add a number |
firmware/build/gas_detector_sim_x10.hex | 10x faster timers and a dummy number (+9779800000000) for Proteus demos |
proteus/gas-smoke-detector.pdsprj | Arduino, MQ-2, MQ-3, SIM900D, relay + fan, servo, buzzer |
proteus/library/ | The Engineering Projects gas sensor library used by the schematic |
test/sim_test.c | Automatic bench test (simavr) |
v1 (smoke.ino, 2023) checked one sensor once a second and beeped. That's a fair start, but in real use it gives false alarms at power-on, chatters when the reading sits near the threshold, and does nothing about the gas. The Proteus file was also pointing at another person's HEX in their temp folder (C:\Users\zain\...), so it never ran this project's code.
v2 changes:
| Pin | Use |
|---|---|
| A0 / A1 | MQ-2 / MQ-3 analog outputs |
| D3 | RESET / MUTE button to GND |
| D6 | Servo signal (gas valve) |
| D8 | Relay driver (2N5551 + flyback diode), relay switches the fan |
| D9 | Buzzer |
| D10 / D11 | SoftwareSerial RX / TX to SIM900 TX / RX |
| D12 / D13 | Green OK LED / red alarm LED |
Edit the top of the sketch:
#define ALERT_PHONE_1 "+97798XXXXXXXX"
#define ALERT_PHONE_2 "" // optional
#define SITE_NAME "Kitchen"To calibrate, power it in clean air for a day and watch the serial log (9600 baud). Set the WARN level to about 1.5 times the clean-air reading and ALARM to about 2 times. MQ sensors also need a 24 to 48 hour burn-in when they're brand new.
proteus/library/GasSensorsTEP.LIB and .IDX into Proteus's LIBRARY folder and restart Proteus.proteus/gas-smoke-detector.pdsprj.proteus/library/GasSensorTEP.HEX.firmware/build/gas_detector_sim_x10.hex.tools/test_all.sh # runs this test with all the othersThe test runs the compiled firmware in simavr. It covers warm-up, warning, spike rejection, alarm confirmation, fan and valve, SMS queueing, mute, purge, manual reset and an unplugged sensor. Writing it caught a real timing bug in my first draft: confirmation could fire instantly on even milliseconds. That's fixed.
This is a learning and demo project. For a real kitchen or LPG store, use a certified gas detector as the primary device. This board makes a useful second layer (SMS, fan, valve), but it isn't a replacement.