The MQ-4 is a highly sensitive gas sensor module designed to detect methane (CH4), natural gas, and other combustible gases in the air. It is widely used in gas leakage detecting equipment for homes and industries. Its fast response time and high sensitivity make it an ideal choice for safety systems in gas line monitoring, methane gas detection systems, and DIY projects that require gas monitoring capabilities.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V) |
2 | GND | Ground |
3 | DO | Digital output (TTL) |
4 | AO | Analog output (Variable voltage) |
// MQ-4 Gas Sensor with Arduino UNO
int analogPin = A0; // Analog output of MQ-4 connected here
int digitalPin = 2; // Digital output of MQ-4 connected here
int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
pinMode(digitalPin, INPUT); // Set the digital pin as input
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int analogValue = analogRead(analogPin); // Read the analog value from sensor
int digitalValue = digitalRead(digitalPin); // Read the digital value from sensor
// Print the analog value to the serial monitor
Serial.print("Analog Value: ");
Serial.println(analogValue);
// Check the digital output and turn on/off the LED
if (digitalValue == HIGH) {
digitalWrite(ledPin, HIGH); // Turn on the LED if gas is detected
} else {
digitalWrite(ledPin, LOW); // Turn off the LED if no gas is detected
}
delay(100); // Wait for 100 milliseconds
}
Q: How long does the MQ-4 sensor last? A: The lifespan of the MQ-4 sensor can vary based on usage, but typically it can last for several years with proper calibration and maintenance.
Q: Can the MQ-4 sensor detect gases other than methane? A: While the MQ-4 is optimized for methane detection, it may also respond to other combustible gases, albeit with less sensitivity.
Q: Is the MQ-4 sensor suitable for outdoor use? A: The MQ-4 can be used outdoors but should be protected from extreme weather conditions and water exposure to ensure accurate readings.
For further assistance, please refer to the manufacturer's datasheet or contact technical support.