MQ-9 Gas Sensor Module
MQ-9 Gas Sensor Module
The MQ-9 Gas Sensor Module is a highly sensitive and reliable gas detector module designed to detect the presence of Carbon Monoxide (CO), Methane (CH4), and Liquefied Petroleum Gas (LPG) in the air. This module is widely used in various applications, including industrial automation, environmental monitoring, and safety systems.
The MQ-9 Gas Sensor Module is capable of detecting the concentration of CO, CH4, and LPG gases in the air and provides an analog output signal proportional to the gas concentration. The module is equipped with a built-in heating element that helps to enhance the sensitivity and stability of the sensor.
5V DC
150mA (typical)
1.5-2.5 V (CO), 2.0-3.0 V (CH4), 2.5-3.5 V (LPG)
100-1000 ppm (CO), 100-10000 ppm (CH4), 100-10000 ppm (LPG)
5V DC, 1.5W
-10C to 50C
20-80% RH
32mm x 20mm x 10mm
The MQ-9 Gas Sensor Module should be used in well-ventilated areas, and it is recommended to calibrate the module before use. Additionally, the module should not be used in explosive atmospheres or in the presence of flammable gases.
MQ-9 Gas Sensor Module DocumentationOverviewThe MQ-9 Gas Sensor Module is a versatile gas detection module capable of detecting Carbon Monoxide (CO), Methane (CH4), and Liquefied Petroleum Gas (LPG). This module is widely used in IoT projects, robotics, and industrial automation applications where gas detection is a critical safety parameter.Pinout and ConnectionsThe MQ-9 Gas Sensor Module has a simple pinout:| Pin | Function |
| --- | --- |
| VCC | Power supply (5V) |
| GND | Ground |
| OUT | Analog output (0-5V) |Operating PrincipleThe MQ-9 sensor works on the principle of catalytic combustion, where the gas molecules react with the sensor's metal oxide surface to produce a change in resistance. The sensor is heated to a high temperature (around 300C) to facilitate this reaction. The resistance change is then converted into an analog voltage output, which is proportional to the gas concentration.Code Examples### Example 1: Basic Gas Detection with ArduinoIn this example, we'll demonstrate how to use the MQ-9 sensor with an Arduino board to detect gas concentrations.
```c++
const int sensorPin = A0; // Analog input pin for MQ-9 sensorvoid setup() {
Serial.begin(9600);
}void loop() {
int sensorValue = analogRead(sensorPin);
float voltage = sensorValue (5.0 / 1023.0);
Serial.print("Gas concentration: ");
if (voltage < 0.2) {
Serial.println("No gas detected");
} else if (voltage < 0.5) {
Serial.println("Low gas concentration");
} else if (voltage < 1.0) {
Serial.println("Moderate gas concentration");
} else {
Serial.println("High gas concentration");
}
delay(1000);
}
```
### Example 2: IoT-based Gas Detection with ESP32 and BlynkIn this example, we'll demonstrate how to use the MQ-9 sensor with an ESP32 board and Blynk app to create a wireless gas detection system.
```c++
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>char auth[] = "Your Blynk Auth Token";
char ssid[] = "Your WiFi SSID";
char pass[] = "Your WiFi Password";BlynkTimer timer;void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);// Set up MQ-9 sensor pin
pinMode(32, INPUT); // ESP32 ADC pin 32 for MQ-9 sensortimer.setInterval(1000L, sendGasData);
}void loop() {
Blynk.run();
timer.run();
}void sendGasData() {
int sensorValue = analogRead(32);
float voltage = sensorValue (5.0 / 4095.0);
Blynk.virtualWrite(V1, voltage);
}
```
### Example 3: Gas Detection with Raspberry Pi and PythonIn this example, we'll demonstrate how to use the MQ-9 sensor with a Raspberry Pi and Python to create a gas detection system.
```python
import RPi.GPIO as GPIO
import timeGPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN) # Raspberry Pi GPIO 17 for MQ-9 sensorwhile True:
sensorValue = GPIO.input(17)
voltage = sensorValue (5.0 / 1023.0)
print("Gas concentration: ", voltage)
if voltage < 0.2:
print("No gas detected")
elif voltage < 0.5:
print("Low gas concentration")
elif voltage < 1.0:
print("Moderate gas concentration")
else:
print("High gas concentration")
time.sleep(1)
```
Important NotesThe MQ-9 sensor requires a warm-up time of around 24 hours before use.
The sensor is sensitive to temperature and humidity, which may affect its accuracy.
It's essential to calibrate the sensor according to the manufacturer's instructions for accurate readings.
Always handle the sensor with care, as it can be damaged by excessive heat, vibration, or mechanical stress.