

The MQ-4 is a popular gas sensor module used for the detection of methane (CH4) in the air. Methane is a colorless, odorless gas, which makes it difficult to detect without specialized sensors. The MQ-4 sensor is widely used in industrial and home environments to monitor gas leaks and ensure safety. Common applications include gas leak alarms, methane detection systems in mines, and environmental monitoring.








| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VCC | Power supply (5V DC) |
| 2 | GND | Ground |
| 3 | DO | Digital output (0V or 5V) |
| 4 | AO | Analog output (0.1V to 0.3V normally) |
// MQ-4 Methane Sensor with Arduino UNO
int analogPin = A0; // Analog input pin connected to AO
int digitalPin = 2; // Digital input pin connected to DO
int analogValue = 0; // Variable to store the analog value
int digitalValue = 0; // Variable to store the digital value
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(digitalPin, INPUT); // Set the digital pin as input
}
void loop() {
analogValue = analogRead(analogPin); // Read the analog value
digitalValue = digitalRead(digitalPin); // Read the digital value
// Print the results to the Serial Monitor
Serial.print("Analog Value: ");
Serial.print(analogValue);
Serial.print(" | Digital Value: ");
Serial.println(digitalValue ? "HIGH" : "LOW");
delay(1000); // Wait for a second before the next read
}
Q: How long does the MQ-4 sensor last? A: The lifespan of the MQ-4 sensor can vary based on usage, but it typically lasts for several years with proper calibration and maintenance.
Q: Can the MQ-4 sensor detect other gases? A: While the MQ-4 is designed for methane detection, it may show some sensitivity to other gases. However, it is not recommended to use it for detecting gases other than methane.
Q: Is the MQ-4 sensor suitable for outdoor use? A: The MQ-4 can be used outdoors but should be protected from water, dust, and extreme weather conditions to ensure accurate readings.
Q: How do I know if the sensor is working correctly? A: You can test the sensor by applying a known concentration of methane and checking if the readings are within the expected range. Regular calibration is also essential for maintaining accuracy.