


MQ-2 Gas Sensor
A sensor designed for detecting various gases including smoke, LPG, and methane
Introduction
The MQ-2 gas sensor is widely used for detecting a variety of gases including smoke, carbon monoxide, LPG, and methane. It is a versatile sensor that finds applications in safety systems, environmental monitoring, and air quality control. The sensor provides both analog and digital outputs for easy integration with microcontrollers like Arduino or Raspberry Pi.
Pinout
The MQ-2 sensor module has the following pins:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (5V). |
2 | GND | Ground connection. |
3 | DO | Digital output, HIGH when gas concentration exceeds threshold. |
4 | AO | Analog output, which increases with gas concentration. |

Working Principle
The MQ-2 gas sensor operates using a metal oxide semiconductor (MOS) that changes its resistance when exposed to various gases. Here’s how it works:
- The sensor has a heating element that heats up the semiconductor material inside.
- When gases such as smoke, LPG, methane, or carbon monoxide come in contact with the sensor, the resistance of the semiconductor layer changes.
- The change in resistance is detected and converted to a voltage signal, which can be read as an output.
- The sensor gives an analog output that increases as the gas concentration rises, and the digital output (DO) goes HIGH when the concentration exceeds a set threshold.
Features
Key features of the MQ-2 gas sensor include:
- Detects multiple gases including smoke, LPG, methane, and carbon monoxide.
- Provides both analog and digital outputs for flexibility in interfacing.
- High sensitivity and fast response time to detected gases.
- Easy to use with microcontrollers like Arduino or Raspberry Pi.
- Affordable and reliable for environmental monitoring applications.
Applications
The MQ-2 sensor is used in various applications such as:
- Gas leakage detection in homes or factories (e.g., LPG, methane).
- Smoke detection in fire alarms and safety systems.
- Air quality monitoring in indoor environments.
- Environmental sensing for pollution detection.
- Portable gas detectors for safety personnel.
Calibration
To achieve accurate readings from the MQ-2 sensor, calibration is required:
- Let the sensor warm up for at least 24 hours before initial use to stabilize the sensor.
- Use a known concentration of the target gas to calibrate the sensor.
- Measure the analog output (AO) at different concentrations of the target gas and adjust the threshold for the digital output (DO) if necessary.
Troubleshooting
If the MQ-2 sensor is not working correctly, try these troubleshooting tips:
- No output: Ensure the sensor is powered correctly and connected to the microcontroller.
- Unstable readings: Allow the sensor to stabilize and warm up for proper sensor readings.
- Incorrect gas concentration readings: Ensure proper calibration with known gas concentrations.
- Digital output not triggered: Verify the threshold setting for the digital output and adjust if necessary.