The MQ-6 sensor module is designed for the detection of LPG (liquefied petroleum gas) concentrations in the air. It is a widely used sensor for gas leak detection in household and industrial settings to prevent accidents related to gas leakage. The sensor can also detect natural gas and is suitable for creating safety alarms, gas level monitoring systems, and for integration into IoT applications for smart monitoring.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V DC) |
2 | GND | Ground |
3 | DOUT | Digital output (TTL logic level) |
4 | AOUT | Analog output (proportional to gas concentration) |
// MQ-6 LPG Gas Sensor with Arduino UNO
int analogPin = A0; // Analog input pin connected to AOUT on the sensor
int digitalPin = 2; // Digital input pin connected to DOUT on the sensor
int sensorValue = 0; // Variable to store the sensor value
void setup() {
pinMode(digitalPin, INPUT); // Set the digital pin as input
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop() {
sensorValue = analogRead(analogPin); // Read the analog value from sensor
Serial.print("Gas concentration (analog): ");
Serial.println(sensorValue); // Print the analog reading
if (digitalRead(digitalPin) == HIGH) {
// Check if the digital pin is HIGH
Serial.println("Gas detected!");
} else {
Serial.println("No gas detected.");
}
delay(1000); // Wait for 1 second before reading again
}
Q: Can the MQ-6 sensor detect gases other than LPG? A: Yes, the MQ-6 can also detect gases like propane and butane, which are components of natural gas.
Q: How do I know if the sensor is working correctly? A: You can test the sensor by applying a known concentration of LPG and observing the output. If the readings are within the expected range, the sensor is functioning correctly.
Q: What is the purpose of the onboard potentiometer? A: The potentiometer is used to adjust the load resistance and calibrate the sensor's sensitivity to the target gas concentration.