The MQ-2 is a versatile gas sensor capable of detecting a wide range of gases, including LPG (liquefied petroleum gas), propane, hydrogen, methane, and smoke particles. It is widely used in safety applications such as gas leak detectors and smoke alarms. The sensor's high sensitivity and fast response time make it an essential component in any project involving the detection of combustible gases.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V DC) |
2 | GND | Ground |
3 | DOUT | Digital output (TTL logic level) |
4 | AOUT | Analog output (Voltage proportional to gas concentration) |
// MQ-2 sensor example with Arduino UNO
int analogPin = A0; // Analog input pin connected to MQ-2 AOUT pin
int digitalPin = 2; // Digital input pin connected to MQ-2 DOUT pin
int sensorValue = 0; // Variable to store the sensor value
void setup() {
pinMode(digitalPin, INPUT); // Set the digital pin as input
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
sensorValue = analogRead(analogPin); // Read the analog value from sensor
Serial.print("Gas concentration (analog): ");
Serial.println(sensorValue); // Print the analog reading
if (digitalRead(digitalPin) == HIGH) {
// Check if the digital output is high
Serial.println("Gas detected!");
} else {
Serial.println("No gas detected.");
}
delay(1000); // Wait for 1 second before the next loop
}
Q: How long does the MQ-2 sensor last? A: The lifespan of the MQ-2 sensor can vary depending on usage and environment, but it typically lasts for about 5 years.
Q: Can the MQ-2 sensor detect carbon monoxide (CO)? A: The MQ-2 is not specifically designed for CO detection and may not be reliable for this purpose. For CO detection, use a sensor specifically designed for that gas.
Q: Is the MQ-2 sensor sensitive to alcohol vapors? A: Yes, the MQ-2 sensor can respond to alcohol vapors, but it is not selective. It is important to consider cross-sensitivity when using this sensor for specific gas detection.