MQ-2 Gas Sensor Module For H2, LPG, CH4, CO, Smoke or Propane Detector Module
MQ-2 Gas Sensor Module For H2, LPG, CH4, CO, Smoke or Propane Detector Module
The MQ-2 Gas Sensor Module is a highly sensitive and reliable gas detection module designed to detect the presence of various combustible gases, including Hydrogen (H2), Liquefied Petroleum Gas (LPG), Methane (CH4), Carbon Monoxide (CO), smoke, and propane. This module is ideal for a wide range of applications, including industrial gas detection, home safety, and environmental monitoring.
The MQ-2 Gas Sensor Module uses a metal oxide semiconductor (MOS) sensor to detect changes in the air composition. When a combustible gas is present, the sensor's resistance changes, which is then amplified and processed by the onboard circuitry. The module outputs an analog signal that corresponds to the concentration of the detected gas.
5V
150mA
Metal Oxide Semiconductor (MOS)
0.5-5.0 Volts/Gas Concentration (ppm)
<10 seconds
-20C to 50C
30% to 80% RH
32 x 20 x 10 mm (1.26 x 0.79 x 0.39 inches)
Industrial gas detection and monitoring
Home safety and security systems
Environmental monitoring and air quality detection
IoT projects and devices
Robotics and automation
The MQ-2 Gas Sensor Module is not suitable for use in explosive environments.
The module should be calibrated before use to ensure accurate results.
The sensor's sensitivity and accuracy may vary depending on the specific gas being detected and environmental conditions.
Overall, the MQ-2 Gas Sensor Module is a reliable and versatile solution for detecting combustible gases in various applications. Its high sensitivity, multiple gas detection capabilities, and simple interface make it an ideal choice for developers, hobbyists, and professionals alike.
MQ-2 Gas Sensor Module DocumentationOverviewThe MQ-2 Gas Sensor Module is a highly sensitive and reliable gas detection module capable of detecting various gases, including hydrogen (H2), liquefied petroleum gas (LPG), methane (CH4), carbon monoxide (CO), smoke, and propane. This module is widely used in various applications, such as gas leak detection, industrial process control, and home safety systems.Pinout and ConnectionsThe MQ-2 Gas Sensor Module has the following pinouts:VCC: Power supply (5V or 3.3V)
GND: Ground
DOUT: Digital output (high/low signal indicating gas presence)
AOUT: Analog output (voltage signal proportional to gas concentration)Code Examples### Example 1: Simple Gas Detection Using Digital Output (Arduino)In this example, we will use the digital output of the MQ-2 module to detect the presence of gas.```c++
const int gasSensorPin = 2; // Connect DOUT to digital pin 2void setup() {
pinMode(gasSensorPin, INPUT);
Serial.begin(9600);
}void loop() {
int sensorValue = digitalRead(gasSensorPin);
if (sensorValue == HIGH) {
Serial.println("Gas detected!");
} else {
Serial.println("No gas detected.");
}
delay(1000);
}
```### Example 2: Analog Gas Concentration Measurement (Python with Raspberry Pi)In this example, we will use the analog output of the MQ-2 module to measure the concentration of gas.```python
import RPi.GPIO as GPIO
import timeGPIO.setmode(GPIO.BCM)
gasSensorPin = 18 # Connect AOUT to analog pin 18def read_gas_concentration():
sensorValue = 0
for _ in range(10): # Take 10 readings and average
sensorValue += GPIO.input(gasSensorPin)
sensorValue /= 10
return sensorValuetry:
while True:
gasConcentration = read_gas_concentration()
print("Gas concentration: {0:.2f}%".format(gasConcentration))
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
```### Example 3: Gas Level Monitoring with LED Indicators (C with ESP32)In this example, we will use the analog output of the MQ-2 module to monitor the gas level and indicate the level using LEDs.```c
#include <WiFi.h>const int ledPinRed = 18; // Red LED for high gas level
const int ledPinYellow = 19; // Yellow LED for medium gas level
const int ledPinGreen = 21; // Green LED for low gas level
const int gasSensorPin = 32; // Connect AOUT to analog pin 32void setup() {
pinMode(ledPinRed, OUTPUT);
pinMode(ledPinYellow, OUTPUT);
pinMode(ledPinGreen, OUTPUT);
pinMode(gasSensorPin, INPUT);
}void loop() {
int sensorValue = analogRead(gasSensorPin);
if (sensorValue > 500) {
digitalWrite(ledPinRed, HIGH);
digitalWrite(ledPinYellow, LOW);
digitalWrite(ledPinGreen, LOW);
} else if (sensorValue > 200) {
digitalWrite(ledPinRed, LOW);
digitalWrite(ledPinYellow, HIGH);
digitalWrite(ledPinGreen, LOW);
} else {
digitalWrite(ledPinRed, LOW);
digitalWrite(ledPinYellow, LOW);
digitalWrite(ledPinGreen, HIGH);
}
delay(1000);
}
```Notes and PrecautionsThe MQ-2 Gas Sensor Module requires a 24-hour preheat time before use to ensure optimal performance.
The module is sensitive to temperature and humidity, which may affect its accuracy.
The analog output of the module is not calibrated, and the output voltage may vary depending on the gas concentration and environmental conditions.
It is recommended to use a voltage regulator to ensure a stable power supply to the module.
When working with gas sensors, it is essential to follow proper safety protocols and handle the sensors with care to avoid exposure to hazardous gases.