In this tutorial we will see how to build a gas leak detector alarm system with Arduino Nano. We will see a list of the electronic components to be used, the assembly of the circuit, the source code, and finally we will test the operation of the system. This project is ideal for use in sources close to our home, where there is gas, such as a kitchen, stove or water heater.
While industrial factories use massive ESP32 Modbus setups, the **Nano Gas Leak Alarm** focuses on extreme portability. By compressing the entire sensing logic into an autonomous, 9V battery-driven Arduino Nano chassis, makers can build an inexpensive, highly critical safety tool capable of spotting LPG tank leaks under kitchen cabinets.
Electronic components
mq2 gas sensor

Pin-Out gas sensor Mq-2

Datasheet sensor MQ-2
Download–> MQ-2
Gas sensor (MQ2) is useful for gas leak detection (in home and industry). It can detect LPG, i-butane, methane, alcohol, hydrogen, smoke, etc. Based on its fast response time, measures can be taken as soon as possible. In addition, the sensitivity can be adjusted by a potentiometer (digital pin).
TECHNICAL SPECIFICATIONS
Operating Voltage: 5V DCFast response and high sensitivityDetection range: 300 to 10000 ppmCharacteristic gas: 1000ppm, IsobutaneSensing resistance: 1KΩ 50ppm Toluene 20KΩ inResponse time: ≤ 10sRecovery time: ≤ 30sWorking temperature: -20 ℃ ~ +55 ℃Humidity: ≤ 95% RHAmbient oxygen content: 21%Consumes less than 150mA at 5V.
APPLICATIONS
Gas LeakDetector Industrial Gas Detector
The Semiconductor Burn-in Cycle
The **MQ-Series Sensors (MQ-4 for Methane, MQ-6 for LPG)** operate via an internal heating element interacting with a tin dioxide layer.
- The largest beginner mistake is attempting to read the sensor instantly upon turning it on. The cold tin dioxide acts erratically.
- The sensor requires a "Pre-Heat" cycle of at least 3 minutes, or ideally 24-hours for first-time burn-in!
- **The Software Lockout**: The Arduino code must deliberately ignore the sensor during startup.
void setup() {
Serial.print("Warming up MQ Sensor...");
for(int i=0; i<60; i++) {
delay(1000); // Wait 1 full minute
}
Serial.print("Sensor Active.");
}
Creating a Variable Threshold Alarm
The danger is not binary (Yes/No); it is a rising scale of concentration.
- The `analogRead(A0)` retrieves the raw voltage drop inside the hot tube.
- The Arduino acts as the intelligent interpreter.
- `if (gasValue > 300 && gasValue < 600)`: Phase 1 Alarm. A yellow LED flashes, and the buzzer quietly beeps once every 5 seconds.
- `if (gasValue >= 600)`: Phase 2 Critical. The air is explosive. A red LED locks on tight, and the piezo buzzer screams a continuous, violent 2000Hz tone to force evacuation!
Arduino nano

Six 5mm LED diodes of different colors

Six 1 Kohm resistors

A 5 volt buzzer

Necessary Safety Components
- **Arduino Nano** (The ultra-small footprint is perfect).
- **MQ-4, MQ-5, or MQ-6 Gas Sensor Board** (Specifically chosen for the chemical you wish to detect!).
- **Standard Active Piezo Buzzer Module**.
- **Red, Yellow, and Green LEDs** for visual status checking from across the room.
- **A 9V or 12V Power Source** (The heating coil inside the MQ sensor draws dense, continuous current and will rapidly deplete small batteries!).
Female pins (4 pins total)

Male pins (2 in total)

Socket for the arduino nano

PCB

Download Gerber file –> Gerber_GAS_METER_MQ-2
