Description
MQ2 Flammable Gas and Smoke Sensor Module
The MQ2 Smoke Sensor Module is a popular gas sensor used to detect LPG, smoke, alcohol, propane, hydrogen, methane, and carbon monoxide. It's often used in air quality monitoring, fire detection, and gas leak detection systems.
The MQ2 gas sensor is also known as a chemiresistor. It contains a sensing material whose resistance changes when it comes in contact with the gas. This change in the value of resistance is used for the detection of gas.
Technical Specifications:
- Operating Voltage: 5V DC
- Heating Consumption: ≤ 800 mW
- Detection Range: 200 – 10000 ppm
- Analog Output (A0): Outputs a variable voltage based on gas concentration
- Digital Output (D0): HIGH or LOW based on set threshold (adjustable via onboard potentiometer)
Pinouts:
Connection with Arduino:
Module |
Arduino UNO |
VCC |
5V power supply |
GND |
Ground |
A0 |
A0 |
D0 |
D2 (optional for digital reading) |
Sample code:
Analog reading:
int mq2Pin = A0; // MQ2 A0 connected to Arduino A0
void setup() {
Serial.begin(9600); // Start the serial communication
}
void loop() {
int sensorValue = analogRead(mq2Pin); // Read analog value from MQ2
Serial.print("MQ2 Sensor Reading: ");
Serial.println(sensorValue); // Print the value to Serial Monitor
delay(1000); // Delay for 1 second
}
Optional: Trigger Buzzer or Relay When Gas Detected:
int mq2Pin = A0;
int buzzer = 8; // Connect a buzzer or relay to pin 8
void setup() {
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
}
void loop() {
int value = analogRead(mq2Pin);
Serial.println(value);
if (value > 400) { // Set your own threshold
digitalWrite(buzzer, HIGH); // Turn buzzer/relay ON
} else {
digitalWrite(buzzer, LOW); // Turn OFF
}
delay(500);
}