

The MQ-2 Gas Sensor Module, manufactured by Winsen or available as a generic component, is a versatile gas detection device designed to sense gases such as LPG, propane, methane, hydrogen, and smoke. It is widely used in safety systems, home automation, and industrial applications to detect gas leaks or monitor air quality. The sensor operates by measuring changes in resistance of its sensitive element when exposed to target gases, providing both analog and digital outputs for easy integration with microcontrollers.








| Parameter | Value |
|---|---|
| Operating Voltage | 5V DC |
| Operating Current | ~150 mA |
| Detection Range | 200 ppm to 10,000 ppm |
| Preheat Time | 20 seconds |
| Output Types | Analog (AO) and Digital (DO) |
| Sensitivity | Adjustable via onboard potentiometer |
| Dimensions | ~32mm x 20mm x 22mm |
| Operating Temperature | -20°C to 50°C |
| Manufacturer Part ID | MQ-2 |
The MQ-2 Gas Sensor Module typically has four pins. The table below describes each pin:
| Pin Name | Description |
|---|---|
| VCC | Power supply input (5V DC) |
| GND | Ground connection |
| AO | Analog output (proportional to gas concentration) |
| DO | Digital output (HIGH/LOW based on threshold) |
VCC pin to a 5V DC power source and the GND pin to ground.AO pin to read analog values corresponding to gas concentration.DO pin for digital HIGH/LOW output, which is triggered based on the threshold set by the onboard potentiometer.AO pin to an analog input pin of a microcontroller (e.g., Arduino).DO pin to a digital input pin of the microcontroller.Below is an example of how to connect and use the MQ-2 Gas Sensor Module with an Arduino UNO to read analog values:
// MQ-2 Gas Sensor Example with Arduino UNO
// Connect AO to A0, DO to D2, VCC to 5V, and GND to GND
const int analogPin = A0; // Analog pin connected to AO
const int digitalPin = 2; // Digital pin connected to DO
int analogValue = 0; // Variable to store analog reading
int digitalValue = 0; // Variable to store digital reading
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(digitalPin, INPUT); // Set digital pin as input
}
void loop() {
// Read analog value from AO pin
analogValue = analogRead(analogPin);
// Read digital value from DO pin
digitalValue = digitalRead(digitalPin);
// Print readings to Serial Monitor
Serial.print("Analog Value: ");
Serial.print(analogValue);
Serial.print(" | Digital Value: ");
Serial.println(digitalValue);
delay(1000); // Wait 1 second before next reading
}
analogValue) represents the gas concentration, with higher values indicating higher concentrations.digitalValue) will be HIGH (1) if the gas concentration exceeds the threshold set by the potentiometer.| Issue | Possible Cause | Solution |
|---|---|---|
| No output from the sensor | Incorrect wiring or loose connections | Verify all connections and wiring. |
| Analog readings are unstable | Insufficient preheat time | Allow the sensor to preheat for 20 seconds. |
| Digital output always HIGH or LOW | Threshold not set correctly | Adjust the potentiometer to set the threshold. |
| Sensor not detecting gas | Sensor contamination or damage | Clean the sensor or replace if damaged. |
| Fluctuating readings | Power supply instability | Use a stable 5V DC power source. |
Can the MQ-2 detect multiple gases simultaneously?
How do I calibrate the MQ-2 sensor?
What is the lifespan of the MQ-2 sensor?
Can I use the MQ-2 with a 3.3V microcontroller?
By following this documentation, users can effectively integrate the MQ-2 Gas Sensor Module into their projects for reliable gas detection and monitoring.