What is a Smoke Sensor MQ-2? A Complete Guide to Digital & Analog Connectivity, Pin Configuration, and Interfacing with Arduino Uno

A Comprehensive Guide to the Smoke Sensor MQ-2: Detection, Interfacing, and Applications
Introduction
The MQ-2 smoke sensor is a versatile and reliable module designed to detect a variety of gases, including methane, LPG, carbon monoxide, alcohol, propane, and hydrogen. Widely utilized in safety, security, and environmental monitoring projects, the MQ-2 is ideal for building smoke alarms, gas leak detectors, and air quality monitoring systems. Whether you’re a student, hobbyist, or professional, the MQ-2 sensor offers affordability, accuracy, and ease of use for your innovative projects.
What is the Smoke Sensor MQ-2?
The MQ-2 smoke sensor is a gas detection module that employs a semiconductor-based sensing element to identify the presence of harmful or flammable gases. It features:
Dual Output Modes:
Analog Output (AO):
Provides a continuous voltage signal proportional to gas concentration for precise monitoring.
Digital Output (DO):
Delivers a simple HIGH or LOW signal when the gas concentration exceeds a predefined threshold, perfect for triggering alarms
Wide Range of Detection:
Capable of detecting gas concentrations from 300 ppm to 10,000 ppm.
Technical Specifications
-
Operating Voltage: 5V DC
-
Current Consumption: ≤150mA
-
Response Time: ≤10 seconds
-
Preheating Time: ~20 seconds
-
Detection Range: 300 ppm to 10,000 ppm
Pin Configuration
The MQ-2 sensor module comes with four essential pins:
-
VCC: Connects to the 5V power supply.
-
GND: Ground connection.
-
DO (Digital Output): Outputs HIGH/LOW signals based on gas concentration.
-
AO (Analog Output): Provides variable voltage proportional to gas concentration.

How Does the MQ-2 Smoke Sensor Work?
The MQ-2 operates via a gas-sensitive resistor that changes resistance when exposed to gas molecules. This resistance variation is converted into an electrical signal, enabling accurate gas concentration monitoring
Interfacing the MQ-2 Sensor with Arduino Uno
Required Components:
-
MQ-2 smoke sensor module
-
Arduino Uno board
-
Jumper wires
-
Breadboard
-
LED (optional for visual indication)
Wiring Instructions:
-
Connect VCC to the Arduino’s 5V pin.
-
Connect GND to the Arduino’s GND pin.
-
Connect AO to an analog input pin (e.g., A0) for analog readings.
-
Connect DO to a digital pin (e.g., D2) for digital readings.

Arduino code for smoke detection system
int analogPin = A0; // Analog pin connected to AO
int digitalPin = 2; // Digital pin connected to DO
int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(analogPin);
int digitalValue = digitalRead(digitalPin);
Serial.print("Analog Value: ");
Serial.println(analogValue);
Serial.print("Digital Value: ");
Serial.println(digitalValue);
if (digitalValue == HIGH) {
digitalWrite(ledPin, HIGH); // Turn on LED if gas is detected
} else {
digitalWrite(ledPin, LOW); // Turn off LED if no gas is detected
}
delay(1000);
}
This code reads the analog and digital values from the MQ-2 sensor. It lights up the LED if the gas concentration exceeds the threshold while displaying values on the Serial Monitor.
Applications of the MQ-2 Sensor
The MQ-2 sensor is highly versatile and finds applications in:
Smoke Alarm Detectors:
Early warning systems for fire hazards. Gas Leak Detectors: Monitoring LPG, methane,. other flammable gases.
Home Security Systems:
Detecting hazardous gas leaks.
Environmental Monitoring:
Measuring air quality.
Science and Engineering Projects:
Ideal for school and final-year projects.
Buying MQ-2 Sensors from QKZee Technologies For authentic MQ-2 smoke sensors and other electronic components, visit QKZee Technologies at Hall Road, Lahore. Known for their reliable engineering services and high-quality products, QKZee Technologies is your one-stop shop for electronic components and project supplies in Pakistan.
Why Choose QKZee Technologies?
-
Best Prices in Lahore: Affordable and genuine components for your projects.
-
Wide Range of Products: From sensors to modules, catering to beginners and professionals alike.
-
Exceptional Customer Service: Expert guidance for engineering and DIY projects.
-
Convenient Location: Located at Hall Road, Lahore—a hub for electronics enthusiasts.
How to Connect with QKZee Technologies:
-
Visit their store at Hall Road, Lahore.
-
Browse their online catalog for detailed product listings and specifications.
-
Contact their support team for assistance.
What gases can the MQ-2 sensor detect?
the MQ-2 sensor can detect methane, LPG, carbon monoxide, alcohol, propane, hydrogen, and smoke.
What is the response time of the MQ-2 sensor?
The MQ-2 sensor has a response time of less than 10 seconds, making it highly responsive to gas concentration changes.
Can I use the MQ-2 sensor with a 3.3V microcontroller?
The MQ-2 sensor requires a 5V power supply for optimal performance. If using a 3.3V microcontroller, consider using a level shifter or regulator.
How do I calibrate the MQ-2 sensor?
Calibration involves exposing the sensor to a known gas concentration and adjusting the potentiometer on the module to set the desired threshold for the digital output.
Is the MQ-2 sensor suitable for outdoor use?
The MQ-2 sensor is not weatherproof and should be used in controlled indoor environments to avoid inaccurate readings due to humidity or temperature fluctuations.