The MQ-4 is a gas sensor designed to detect methane (CH₄) and natural gas concentrations in the air. It operates on the principle of resistive change, where the sensor's resistance varies in the presence of target gases. The MQ-4 provides an analog output signal proportional to the gas concentration, making it suitable for a wide range of applications.
The MQ-4 sensor is a robust and reliable component with the following key specifications:
Parameter | Value |
---|---|
Operating Voltage | 5V DC |
Load Resistance (RL) | Adjustable (typically 10 kΩ) |
Heater Voltage (VH) | 5V ± 0.2V DC/AC |
Heating Current | < 150 mA |
Gas Detection Range | 200 ppm to 10,000 ppm (CH₄) |
Preheating Time | ≥ 24 hours |
Sensitivity | Detects methane and natural gas |
Operating Temperature | -20°C to 50°C |
Humidity Range | ≤ 95% RH |
Output Signal | Analog voltage (proportional to gas concentration) |
The MQ-4 sensor typically comes with four pins or six pins, depending on the module version. Below is the pin configuration for the 4-pin version:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (5V DC) |
2 | GND | Ground connection |
3 | AOUT | Analog output signal (proportional to gas level) |
4 | DOUT | Digital output signal (threshold-based, optional) |
For the 6-pin version, two additional pins are used for the internal heater connections (H1 and H2). These are typically pre-wired in most modules.
Below is an example of how to connect the MQ-4 sensor to an Arduino UNO and read the analog output:
// MQ-4 Gas Sensor Example with Arduino UNO
// Reads the analog output of the MQ-4 sensor and prints the value to the Serial Monitor
const int gasSensorPin = A0; // Analog pin connected to MQ-4 AOUT
int sensorValue = 0; // Variable to store the sensor reading
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
Serial.println("MQ-4 Gas Sensor Test");
}
void loop() {
sensorValue = analogRead(gasSensorPin); // Read the analog value from the sensor
Serial.print("Gas Sensor Value: ");
Serial.println(sensorValue); // Print the sensor value to the Serial Monitor
delay(1000); // Wait for 1 second before the next reading
}
analogRead()
function reads the voltage from the AOUT pin and converts it to a digital value (0–1023 for a 10-bit ADC).No Output Signal:
Inaccurate Readings:
Fluctuating Output:
Sensor Not Responding to Gas:
Q: Can the MQ-4 detect gases other than methane?
A: While the MQ-4 is optimized for methane and natural gas, it may respond to other combustible gases. However, its sensitivity and accuracy for non-target gases may be lower.
Q: How long does the MQ-4 last?
A: The sensor typically has a lifespan of 2–3 years under normal operating conditions.
Q: Can I use the MQ-4 outdoors?
A: The MQ-4 can be used outdoors, but it should be protected from water, extreme temperatures, and high humidity to ensure reliable operation.
Q: Is the digital output (DOUT) always available?
A: The DOUT pin is only available on MQ-4 modules with an onboard comparator circuit. Check your module's specifications to confirm.
By following this documentation, users can effectively integrate the MQ-4 gas sensor into their projects for reliable methane and natural gas detection.