The MQ-2 is a versatile gas sensor manufactured by Arduino, designed to detect a variety of gases such as LPG, propane, methane, and smoke. It operates on the principle of resistive change, where the sensor's resistance varies in the presence of target gases. This change is converted into an analog output, making it easy to interface with microcontrollers and other electronic systems.
The MQ-2 sensor is designed for ease of use and reliable performance. Below are its key technical details:
Parameter | Value |
---|---|
Manufacturer | Arduino |
Part ID | MQ-2 |
Operating Voltage | 5V DC |
Load Resistance (RL) | Adjustable (typically 10 kΩ) |
Heater Voltage (VH) | 5V ± 0.2V |
Heater Power Consumption | ≤ 800 mW |
Detection Range | 200 ppm to 10,000 ppm (varies by gas) |
Preheat Time | ≥ 24 hours for optimal accuracy |
Output Signal | Analog voltage (0-5V) |
Operating Temperature | -20°C to 50°C |
Humidity Range | 35% to 95% RH |
Dimensions | 32mm x 20mm x 22mm |
The MQ-2 sensor module typically has four pins. Below is the pinout and description:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin (5V DC) |
2 | GND | Ground pin |
3 | AOUT | Analog output pin; provides a voltage proportional to the gas concentration |
4 | DOUT | Digital output pin; triggers HIGH when gas concentration exceeds a threshold (adjustable via onboard potentiometer) |
The MQ-2 sensor is straightforward to use in a circuit. Follow the steps below to integrate it into your project:
VCC
pin to the 5V pin on the Arduino UNO and the GND
pin to the Arduino's GND.AOUT
pin to an analog input pin on the Arduino (e.g., A0).DOUT
pin to a digital input pin on the Arduino (e.g., D2). Adjust the onboard potentiometer to set the gas concentration threshold for triggering the digital output.Below is an example of how to use the MQ-2 sensor with an Arduino UNO to read analog values and detect gas concentration:
// MQ-2 Gas Sensor Example Code
// This code reads the analog output of the MQ-2 sensor and prints the value
// to the Serial Monitor. Adjust the threshold value as needed for your application.
const int analogPin = A0; // Pin connected to AOUT of MQ-2
const int digitalPin = 2; // Pin connected to DOUT of MQ-2 (optional)
int sensorValue = 0; // Variable to store analog reading
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(digitalPin, INPUT); // Set digital pin as input
}
void loop() {
// Read the analog value from the sensor
sensorValue = analogRead(analogPin);
// Print the analog value to the Serial Monitor
Serial.print("Analog Value: ");
Serial.println(sensorValue);
// Check the digital output (optional)
if (digitalRead(digitalPin) == HIGH) {
Serial.println("Gas concentration exceeded threshold!");
}
delay(1000); // Wait for 1 second before the next reading
}
No Output or Incorrect Readings
Fluctuating Analog Values
Digital Output Not Triggering
Sensor Not Detecting Gas
Q1: Can the MQ-2 detect multiple gases simultaneously?
A1: Yes, the MQ-2 can detect multiple gases such as LPG, propane, methane, and smoke. However, it cannot differentiate between them.
Q2: How do I convert the analog output to gas concentration (ppm)?
A2: The analog output voltage can be mapped to gas concentration using the sensor's sensitivity curve provided in the datasheet. Calibration in a known gas environment is required for accurate results.
Q3: Can I use the MQ-2 with a 3.3V microcontroller?
A3: The MQ-2 is designed for 5V operation. If using a 3.3V microcontroller, you will need a level shifter or a 5V power source for the sensor.
Q4: How long does the MQ-2 last?
A4: The sensor has a typical lifespan of 2-3 years under normal operating conditions.