Skip to content
AkerminMeasure. Monitor. Improve. Compare Products
Learning Center

How to Make a Gas Leakage Detector

You want to build a gas sensor project, for a school class, a workshop or simply to learn how detectors work. Here is a design that genuinely responds to gas, and the honest limits of what a homemade unit can do.

As an Amazon Associate, Akermin earns from qualifying purchases. Product links on this page are affiliate links.

The simplest working design is an MQ-series metal oxide gas sensor module, a small microcontroller board such as an Arduino, a buzzer and an LED, powered from a 5 volt supply. The sensor’s resistance falls when combustible gas reaches its heated element; the microcontroller reads that change as a voltage, compares it with a baseline recorded in clean air, and sounds the buzzer when it rises past a threshold. Pick the sensor for the gas you care about, let it warm up properly, and calibrate it before trusting the threshold. A homemade unit is a learning project, not a safety device, so a home with gas appliances still needs a listed commercial gas alarm.

How a metal oxide gas sensor actually works

The hobby sensors sold as MQ-2, MQ-4, MQ-5, MQ-6 and similar contain a small tube of tin dioxide, a semiconductor, wrapped around a tiny heater coil and covered by a stainless steel mesh cap. When the heater holds the tin dioxide at a high temperature, oxygen from the air sits on its surface and traps electrons, so the material has high resistance. When a reducing gas such as methane, propane or butane arrives, it reacts with that surface oxygen, releases the electrons, and the resistance drops. More gas means lower resistance.

The module turns that resistance into a voltage with a load resistor, giving an analogue output that rises as gas concentration rises. Most modules also include a comparator with a small adjustment screw, which gives a simple on or off digital output. Commercial combustible gas detectors use either this semiconductor principle or catalytic bead sensors, which burn gas on a heated bead and measure the temperature change.

Choosing parts for the gas you want to detect

Every MQ sensor responds to several gases, but each is tuned to be most sensitive to a particular family. Check the datasheet curves for your exact part.

Part Role Notes
MQ-4 Methane, natural gas Good choice for mains gas projects
MQ-5 or MQ-6 LPG, propane, butane, also natural gas Common for bottled gas kitchens and caravans
MQ-2 General combustibles and smoke Broad response, less selective
Microcontroller board Reads the analogue signal, decides when to alarm Any board with an analogue input works
Active buzzer and LED Alarm outputs An active buzzer only needs power to sound
5 volt supply Powers the heater and board The heater draws far more current than the board, so batteries drain quickly

Avoid the MQ-7 for a gas leak project. It is designed for carbon monoxide and needs a cycling heater voltage to work properly.

Building and programming the detector

  1. Wire the power. Connect the module’s VCC and GND to a regulated 5 volt supply that can deliver enough current for the heater. A USB charger is fine for a bench project.
  2. Connect the signal. Run the module’s analogue output (often labelled AO) to an analogue input on the board. Connect the buzzer and LED to digital output pins, using a resistor in series with the LED.
  3. Burn in the sensor. New metal oxide sensors drift heavily at first. Leave the powered sensor running for a day or two before calibrating; the datasheets for this family recommend an extended preheat.
  4. Record a clean-air baseline. In fresh air, with the sensor warm, have the program average the analogue reading over a minute or so and store it.
  5. Set a threshold above baseline. Program the alarm to trigger when the reading rises by a set margin over the baseline and stays there for several seconds. Requiring the reading to persist avoids alarms from brief puffs of air.
  6. Add a warm-up delay. Every time the device powers on, ignore readings for the first few minutes while the heater stabilises, and show that with a slow blinking LED.
  7. Add a latch. Once triggered, keep the alarm on until a button is pressed, so a brief leak is not missed by someone out of the room.

If you use the module’s built-in digital output instead, turn the adjustment screw until the output just switches off in clean air, then a little further to give margin.

Testing the detector without creating a hazard

Test outdoors or by an open window, away from any flame or spark. Hold an unlit butane lighter near the sensor and press the gas release briefly without striking it; a short burst is enough. The analogue reading should climb within seconds and the alarm should trigger, then the reading should fall back toward baseline over a minute or two in fresh air. Never test with a gas hob tap left open or a bottle valve released indoors.

Then test what it should not respond to strongly. Alcohol hand gel, cooking fumes, aerosol sprays and even high humidity can move metal oxide sensors, which is why commercial units suffer nuisance alarms. Our guide to what causes false gas detector readings lists the common culprits. Record how your build reacts so you understand its limits.

Why a homemade detector is not a safety alarm

The project teaches the principle well, but it falls short of a real alarm in ways that matter.

  • No real calibration. Without a certified test gas, you do not know what concentration your threshold represents. Commercial alarms are set to trigger well below the lower explosive limit; our explainer on ppm versus LEL shows what that means.
  • Drift. MQ sensors change with temperature, humidity and age. Without compensation, a threshold that worked in winter may never trigger in summer, or alarm constantly.
  • No fault detection. A disconnected wire or failed heater looks like clean air. Listed alarms monitor themselves and warn on faults.
  • Ignition risk. Hobby electronics are not designed for explosive atmospheres. The sensor’s mesh cap acts as a flame arrestor, but the rest of the circuit, connectors and relays can spark.
  • Limited life. All gas sensors age, as covered in our page on gas sensor lifespan.

For actual protection, fit a listed natural gas or LPG alarm as the manufacturer directs, high on the wall for natural gas, which is lighter than air, and low for propane and butane, which are heavier. For leak hunting around pipe joints, a handheld sniffer such as the Forensics gas leak detector is the practical tool.

If your detector ever alarms for real

Treat any alarm, from a homemade or commercial device, along with any smell of gas, as genuine. Do not switch lights or appliances on or off, do not use a phone inside, put out naked flames, turn off the gas at the meter if it is safe and easy to reach, open doors, leave the building and call the gas emergency line from outside. A carbon monoxide alarm is a separate device; a combustible gas sensor will not warn you about carbon monoxide from a badly burning appliance.

Build it, then compare it

Assemble the circuit, let the sensor burn in for a day before you calibrate, and log the readings in clean air, near a lighter’s gas burst and near cleaning sprays. Comparing those three numbers is the most useful thing the project teaches, and it shows clearly why the kitchen still needs a listed alarm on the wall.

Frequently Asked Questions

Which MQ sensor is best for detecting a natural gas leak?

The MQ-4 is tuned for methane, the main component of natural gas, and the MQ-5 also responds well. The MQ-2 works but is less selective. Check the sensitivity curves in the datasheet for the specific part.

Can I run a DIY gas detector on batteries?

You can, but the sensor heater draws a lot of current compared with the microcontroller, so small batteries drain quickly. A mains USB supply is more practical for a detector that stays on.

Why does my MQ sensor reading keep changing in clean air?

Metal oxide sensors drift during warm-up and with changes in temperature and humidity. A new sensor also needs a long burn-in. Average readings over time and recalibrate the baseline after burn-in.

Can I add a text or phone alert to my homemade detector?

Yes, a Wi-Fi capable board can send a notification when the threshold is crossed. It adds convenience but does not fix the calibration and reliability limits, so it still does not replace a listed alarm.

Will this detector also detect carbon monoxide?

Not reliably. Combustible gas sensors are not designed for carbon monoxide at the low concentrations that matter for health. Fit a separate carbon monoxide alarm.