Build Your Own Arduino Gas Leak Detector


Gas leaks are no joke, but building a gadget to sniff them out can actually be fun. In this little project, we will put together a budget-friendly LPG leak detector using an Arduino Uno, an MQ-5 gas sensor, a buzzer, and an LED. When the sensor smells gas in the air, it will beep with the buzzer and flash the LED until things are safe again.
It is beginner-friendly, uses parts you can get easily, and is a neat way to apply your electronics skills to something practical.
How It Works
The MQ-5 sensor sits quietly, sniffing the air for LPG, propane, or methane. If gas levels go above the safe limit, it sends a signal to the Arduino. The Arduino then turns on the buzzer and LED to warn you. Once the air clears, it shuts everything off automatically.
While we are using the MQ-5 here, MQ-2 and MQ-6 can do similar jobs. MQ-2 is more of a multi-gas generalist, and MQ-6 is extra sensitive to LPG and butane.
What You Will Need
Arduino Uno – the brains of the operation
MQ-5 Gas Sensor – the nose
Buzzer – the warning sound
LED – visual alert
220Ω resistor – for the LED
Breadboard and jumper wires – for quick assembly
9V battery or USB cable – power source
Wiring It Up
This is a simple circuit. Power the Arduino with a battery or USB. The MQ-5 digital output goes to Arduino pin A2. The buzzer goes to A0 (we used a 10kΩ resistor to make it quieter, but that is optional). The LED goes to A1 with a 220Ω resistor.
The Code
We are using the sensor’s digital output, which keeps the code nice and simple.
const int gasSensorDigitalPin = A2;
const int ledPin = A1;
const int buzzerPin = A0;
void setup() {
pinMode(gasSensorDigitalPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
Serial.println("Gas Detection System Initialized (Digital Mode)");
}
void loop() {
int gasState = digitalRead(gasSensorDigitalPin);
if (gasState == LOW) {
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
Serial.println("!! Gas Leak Detected !!");
} else {
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
Serial.println("Environment Normal");
}
delay(800);
}
LOW means danger. HIGH means everything is fine.
Tuning the Sensor
The small blue knob on the sensor is a potentiometer. Turn it to set how sensitive the sensor is. Clockwise makes it less sensitive. Counter-clockwise makes it more sensitive. You will need to experiment. Test with a lighter (unlit) near the sensor until you get a reliable trigger without constant false alarms.
Testing
Upload the code, power it on, and give it a minute. Then waft some gas from a lighter near the sensor. You should hear the buzzer and see the LED. If you do not, adjust the potentiometer again.
Where to Use It
Near kitchen stoves or LPG cylinders at home
Food trucks and small restaurants
Warehouses storing LPG cylinders
RVs and camping setups
Classrooms or workshops as a teaching project
A Quick Reality Check
This is a cool DIY build, but it is not a certified safety device. Use it as a helper, not your main line of defense. For serious safety, buy a proper commercial gas detector.
The complete step-by-step tutorial is available here: Arduino Based Gas Leakage Detector
Subscribe to my newsletter
Read articles from Electroscope Archive directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
