Metal Oxide Semiconductor (MOS)
Metal Oxide Semiconductor (MOS)
100-10000 ppm (dependent on gas type)
Analog
5V
-20C to 50C
<10 seconds
32mm x 22mm x 14mm (L x W x H)
Application Areas
| The MQ-2 Gas Sensor Module is suitable for a wide range of applications, including |
Home and industrial safety systems
Gas leak detection systems
Environmental monitoring systems
IoT projects and prototypes
Industrial automation and control systems
Smart home automation systems
Conclusion
The MQ-2 Gas Sensor Module is a highly sensitive and versatile detection module that offers a cost-effective solution for detecting a wide range of combustible gases. Its compact design, easy-to-use interface, and high sensitivity make it an ideal choice for various IoT applications, prototyping, and development projects.
MQ-2 Gas Sensor Module DocumentationOverviewThe MQ-2 Gas Sensor Module is a highly sensitive gas detection module that can detect various gases, including H2, LPG, CH4, CO, smoke, and propane. This module is suitable for a wide range of applications, from simple gas detection to industrial automation.Technical SpecificationsSupply Voltage: 5V
Operating Current: 150mA
Sensitivity: 0.1-10 ppm
Response Time: 10-60 seconds
Output Signal: Analog Voltage (0-5V)
Detection Range:
+ H2: 100-1000 ppm
+ LPG: 100-1000 ppm
+ CH4: 100-1000 ppm
+ CO: 10-100 ppm
+ Smoke: 10-100 ppm
+ Propane: 100-1000 ppmPinoutVCC: 5V Power Supply
GND: Ground
OUT: Analog Output SignalCode Examples### Example 1: Basic Gas Detection with ArduinoThis example demonstrates how to use the MQ-2 Gas Sensor Module with an Arduino board to detect the presence of gas.
```c++
const int gasSensorPin = A0; // Analog input pin for the gas sensor
int sensorValue = 0;void setup() {
Serial.begin(9600);
}void loop() {
sensorValue = analogRead(gasSensorPin);
Serial.print("Gas Sensor Value: ");
Serial.println(sensorValue);if (sensorValue > 400) {
Serial.println("Gas Detected!");
} else {
Serial.println("No Gas Detected.");
}delay(1000);
}
```
In this example, we connect the OUT pin of the MQ-2 Gas Sensor Module to an analog input pin on the Arduino board (A0). We then read the analog value from the sensor using the `analogRead()` function and print it to the serial monitor. If the value exceeds 400, we trigger an alarm by printing "Gas Detected!" to the serial monitor.### Example 2: Gas Level Monitoring with ESP32 and WiFiThis example demonstrates how to use the MQ-2 Gas Sensor Module with an ESP32 board to monitor gas levels and send the data to a remote server using WiFi.
```c++
#include <WiFi.h>
#include <HTTPClient.h>const char ssid = "your_wifi_ssid";
const char password = "your_wifi_password";
const char serverUrl = "http://example.com/gas_level";WiFiClient wifiClient;
HTTPClient http;int gasSensorPin = 32; // Digital pin for the gas sensor
int sensorValue = 0;void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}Serial.println("Connected to WiFi");
Serial.println("Initializing HTTP client...");
}void loop() {
sensorValue = analogRead(gasSensorPin);
Serial.print("Gas Level: ");
Serial.println(sensorValue);http.begin(wifiClient, serverUrl);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");String json = "{""gas_level"": " + String(sensorValue) + "}";
int httpResponseCode = http.POST(json);if (httpResponseCode > 0) {
Serial.println("Data sent successfully!");
} else {
Serial.println("Error sending data: " + String(http.errorString(httpResponseCode)));
}http.end();
delay(10000);
}
```
In this example, we connect the OUT pin of the MQ-2 Gas Sensor Module to a digital pin on the ESP32 board (32). We then read the analog value from the sensor using the `analogRead()` function and send the data to a remote server using the `HTTPClient` library. The server can then log the gas level data and trigger alarms or notifications as needed.