MQ-5 Gas Sensor For Methane(CNG), Propane, and Natural Gas Detector Module
MQ-5 Gas Sensor For Methane(CNG), Propane, and Natural Gas Detector Module
The MQ-5 Gas Sensor is a highly sensitive and reliable detector module designed to detect the presence of Methane (CNG), Propane, and Natural Gas in the air. This module is widely used in various applications, including industrial safety monitoring, gas leak detection, and air quality monitoring.
The MQ-5 Gas Sensor module detects the concentration of combustible gases in the air and provides an analog output voltage proportional to the gas concentration. The module is based on a metal oxide semiconductor (MOS) sensor, which operates on the principle of catalytic combustion. When the sensor detects the presence of a combustible gas, the sensor's resistance changes, causing a variation in the output voltage.
| Pin | Function |
| --- | --- |
| VCC | Power supply (5V DC) |
| GND | Ground |
| OUT | Analog output (0-5V) |
The module dimensions are approximately 32mm x 22mm x 17mm (L x W x H).
| Parameter | Operating Condition |
| --- | --- |
| Operating Temperature | -20C to 50C |
| Operating Humidity | 20% to 80% RH |
| Power Supply | 5V DC |
| Response Time | < 10 seconds |
The MQ-5 Gas Sensor module should be used in well-ventilated areas, and it is recommended to calibrate the module before use. Additionally, the module should be handled with care to avoid damage or contamination.
MQ-5 Gas Sensor Module DocumentationOverviewThe MQ-5 Gas Sensor Module is a highly sensitive and accurate gas detector designed to detect the presence of methane (CNG), propane, and natural gas. This module is ideal for implementing gas detection systems in various applications, including industrial automation, environmental monitoring, and safety devices.Pinout and ConnectionsThe MQ-5 Gas Sensor Module has a simple 5-pin interface:VCC: Power supply (5V)
GND: Ground
OUT: Analog output signal
DOUT: Digital output signal (optional)
AOUT: Analog output signal (optional)Operating PrincipleThe MQ-5 Gas Sensor Module utilizes a tin dioxide (SnO2) sensing material, which changes its electrical conductivity in response to the presence of target gases. The sensor heats up to an optimal temperature, causing the sensing material to react with the gas molecules, resulting in a change in the electrical resistance. This change is converted into an analog output signal, which is proportional to the gas concentration.Technical SpecificationsGas detection range: 200-10000 ppm (methane), 300-10000 ppm (propane), and 200-10000 ppm (natural gas)
Sensitivity: 0.2-1.0 V/ppm
Operating voltage: 5V
Operating temperature: 20C to 50C
Response time: <10 secondsExample Code 1: Analog Gas Concentration Measurement using ArduinoIn this example, we will use an Arduino Uno board to read the analog output signal from the MQ-5 Gas Sensor Module and display the gas concentration on the serial monitor.
```c
const int sensorPin = A0; // Analog input pin for MQ-5 sensorvoid setup() {
Serial.begin(9600);
}void loop() {
int sensorValue = analogRead(sensorPin);
float gasConcentration = (sensorValue 5.0) / 1024.0; // Convert analog value to voltage
gasConcentration = (gasConcentration - 0.2) / 0.01; // Calculate gas concentration in ppmSerial.print("Gas Concentration: ");
Serial.print(gasConcentration);
Serial.println(" ppm");delay(1000); // Take readings every 1 second
}
```
Example Code 2: Digital Gas Detection using Raspberry PiIn this example, we will use a Raspberry Pi board to read the digital output signal from the MQ-5 Gas Sensor Module and trigger a warning when the gas concentration exceeds a certain threshold.
```python
import RPi.GPIO as GPIO
import time# Set up GPIO library
GPIO.setmode(GPIO.BCM)# Set up digital output pin for MQ-5 sensor
sensorPin = 17
GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)def detect_gas():
if GPIO.input(sensorPin) == 0:
print("Gas detected!")
# Trigger warning or alarm here
else:
print("No gas detected.")while True:
detect_gas()
time.sleep(1) # Check for gas every 1 second
```
Example Code 3: IoT Gas Monitoring System using ESP8266 and MQTTIn this example, we will use an ESP8266 board to read the analog output signal from the MQ-5 Gas Sensor Module, send the gas concentration data to an MQTT broker, and display it on a remote dashboard.
```c
#include <WiFi.h>
#include <PubSubClient.h>// MQTT broker details
const char mqttServer = "Your_MQTT_Broker_IP";
const char mqttTopic = "gas-monitoring";WiFiClient espClient;
PubSubClient client(espClient);void setup() {
Serial.begin(9600);
WiFi.begin("Your_WiFi_SSID", "Your_WiFi_Password");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}Serial.println("Connected to WiFi");
client.setServer(mqttServer, 1883);
}void loop() {
int sensorValue = analogRead(A0);
float gasConcentration = (sensorValue 5.0) / 1024.0; // Convert analog value to voltage
gasConcentration = (gasConcentration - 0.2) / 0.01; // Calculate gas concentration in ppmchar gasConcentrationStr[8];
dtostrf(gasConcentration, 4, 2, gasConcentrationStr);if (!client.connected()) {
reconnect();
}
client.publish(mqttTopic, gasConcentrationStr);delay(10000); // Send data every 10 seconds
}void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
if (client.connect("ESP8266Client")) {
Serial.println("Connected");
client.publish(mqttTopic, "Connected");
} else {
Serial.print("Failed, rc=");
Serial.print(client.state());
Serial.println(" Try again in 5 seconds");
delay(5000);
}
}
}
```
Note: In all examples, ensure to connect the MQ-5 Gas Sensor Module to the correct pins on your microcontroller board and adjust the code accordingly. Additionally, calibrate the sensor according to the manufacturer's instructions to achieve accurate gas concentration readings.