Component guide · Beginner · 3 min read
MQ-5 LPG and Natural Gas Sensor

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The MQ-5 is a heated metal-oxide gas sensor tuned for LPG and natural gas. The module gives an analog voltage that rises with gas level and a digital output for a simple alarm. Power it from 5 V, mount it low because LPG is heavier than air, warm it up and calibrate in clean air before trusting readings.
Key specs at a glance
- Detects
- LPG and Natural Gas
- Range
- About 200 to 10,000 ppm LPG, natural gas, town gas
- Heater
- 5 V, about 150 mA (about 0.75 W)
- Output
- Analog (AO) and digital threshold (DO) on modules
- Warm-up
- A few minutes before use; 24 to 48 hours of burn-in for stable readings
- Most sensitive to
- LPG (propane, butane) and natural gas; low response to alcohol and smoke
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1MQ-5 Methane LPG Propane Gas Sensor Module – Tin Oxide Semiconductor, Analog/Digital Output₹100
Option 2DFRobot Gravity Analog LPG Gas Sensor MQ5 for Arduino – 5V Analog Output₹799
Option 3Waveshare MQ-5 Combustible Gas Sensor Module – 200-10000ppm LPG/Natural Gas Detection₹499
Option 4Winsen MQ-5 LPG Gas Sensor Module – Semiconductor CH4/C3H8 Detection₹129
What the MQ-5 is
The MQ-5 is the MQ sensor tuned for LPG and natural gas, the gases used in Indian kitchens. When these gases reach the heated sensing layer its resistance falls and the analog output rises.
It suits learning projects such as a kitchen gas leak indicator that sounds a buzzer and switches an exhaust fan through a relay. MQ sensors are for hobby and learning projects. They are not certified gas alarms; for safety use an approved detector.
MQ-5 pinout
The pins on the MQ-5 and what each one does.
| Pin | Function |
|---|---|
| VCC | 5 V supply for the heater and the comparator |
| GND | Ground |
| AO | Analog output: rises as the gas level rises |
| DO | Digital output from the LM393 comparator; switches at the level set by the trim pot |
- VCC
- 5 V supply for the heater and the comparator
- GND
- Ground
- AO
- Analog output: rises as the gas level rises
- DO
- Digital output from the LM393 comparator; switches at the level set by the trim pot
Wiring the MQ-5
The heater draws about 150 mA, so power it from the 5 V rail, not a 3.3 V pin. The analog output can reach 5 V, so an ESP32 needs a divider (10 kΩ over 20 kΩ gives a third off) on AO.
| MQ-5 pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V | 5V (VIN) |
| GND | GND | GND |
| AO | A0 | GPIO 34 through a 10k/20k divider |
| DO | D2 (optional) | GPIO 27 (optional, via divider) |
- VCC
- Arduino Uno:
- 5V
- ESP32:
- 5V (VIN)
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- AO
- Arduino Uno:
- A0
- ESP32:
- GPIO 34 through a 10k/20k divider
- DO
- Arduino Uno:
- D2 (optional)
- ESP32:
- GPIO 27 (optional, via divider)
Example code
Rs/R0 falls as the gas level rises. Convert it to ppm with the curve in the datasheet; treat the result as an estimate, not a certified reading.
const int AO = A0;
const float RL = 10.0; // load resistor on the module, kOhm (check yours)
const float CLEAN_AIR = 6.5; // Rs/R0 in clean air from the datasheet curve
float R0 = 0;
float readRs() {
long sum = 0;
for (int i = 0; i < 50; i++) { sum += analogRead(AO); delay(5); }
float v = (sum / 50.0) * 5.0 / 1023.0;
return RL * (5.0 - v) / v; // sensor resistance, kOhm
}
void setup() {
Serial.begin(115200);
Serial.println("Warming up 3 minutes in clean air...");
delay(180000);
R0 = readRs() / CLEAN_AIR; // calibrate in clean air
Serial.print("R0 = "); Serial.println(R0);
}
void loop() {
float ratio = readRs() / R0; // lower ratio = more gas
Serial.print("Rs/R0 = "); Serial.println(ratio, 2);
delay(1000);
}Setup and tuning
LPG is heavier than air, so mount the sensor low, about 30 cm above the floor near the cylinder.
set R0 in clean air (clean-air ratio about 6.5).
24 to 48 hours for new sensors.
; a lighter released briefly (unlit) near the sensor is enough.
What you need
Shop this list7 of 8 found in our store · ₹1,833
MQ-5 LPG and methane gas sensor module: the sensor this guide coversWinsen MQ-5 LPG Gas Sensor Module – Semiconductor CH4/C3H8 Detection₹129Closest match, check the specs
DFRobot Gravity Analog LPG Gas Sensor MQ5 for Arduino – 5V Analog Output: another version this guide coversDFRobot Gravity Analog LPG Gas Sensor MQ5 for Arduino – 5V Analog Output₹799
Waveshare MQ-5 Combustible Gas Sensor Module – 200-10000ppm LPG/Natural Gas Detection: another version this guide coversWaveshare MQ-5 Combustible Gas Sensor Module – 200-10000ppm LPG/Natural Gas Detection₹499
Winsen MQ-5 LPG Gas Sensor Module – Semiconductor CH4/C3H8 Detection: another version this guide coversWinsen MQ-5 LPG Gas Sensor Module – Semiconductor CH4/C3H8 Detection₹129- Uno R3 development board: the controller used in the wiring tableFind this part
Buzzer module 3.3-5 V: for an audible alarmBuzzer Module 3.3–5V₹27
Relay module: to switch an exhaust fanHumidity Sensitive Switch Relay Module₹201Closest match, check the specs
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- MQ-2: responds to LPG and smoke.
- MQ-4: better for methane and CNG.
- MQ gas sensors: the family compared.
Try it: Voltage divider calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Mounting it high; LPG sinks to the floor.
- Testing with a large gas release.
- Using the module as a certified gas alarm.
- Switching mains fans without a proper relay and enclosure.
Frequently asked questions
What does the MQ-5 detect?
LPG, natural gas and town gas, with small responses to alcohol and smoke.
Where do I mount it for LPG?
Low, near the floor, because LPG is heavier than air.
MQ-5 or MQ-6?
Both detect LPG; the MQ-6 is more focused on propane and butane.
How long is the warm-up?
A few minutes, with 24 to 48 hours of burn-in when new.
Can it switch a fan?
Yes, through a relay module driven from the board or the DO output.
Parts for this guide
Calculators
Projects that use it
Put this into practice: 11 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.


