The MQ135 is a versatile and sensitive gas sensor capable of detecting a wide range of gases including ammonia (NH3), nitrogen oxides (NOx), alcohols, aromatic compounds, sulfides, and carbon dioxide (CO2). Due to its sensitivity and fast response time, it is widely used in both indoor and outdoor air quality monitoring systems. Common applications include environmental monitoring, air purifiers, ventilation systems, and smart home devices for ensuring the safety and well-being of occupants.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V) |
2 | GND | Ground |
3 | DOUT | Digital output (TTL logic level) |
4 | AOUT | Analog output (Voltage proportional to gas concentration) |
// MQ135 Gas Sensor with Arduino UNO
int analogPin = A0; // Analog input pin connected to AOUT on the MQ135
int digitalPin = 2; // Digital input pin connected to DOUT on the MQ135
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
}
void loop() {
sensorValue = analogRead(analogPin); // Read the analog value from sensor
Serial.print("Gas concentration: ");
Serial.println(sensorValue); // Print the sensor value to the serial monitor
// Check the digital pin for threshold exceedance
if (digitalRead(digitalPin) == HIGH) {
// Gas concentration is above the threshold
Serial.println("Gas level is high!");
} else {
// Gas concentration is below the threshold
Serial.println("Gas level is normal.");
}
delay(1000); // Wait for 1 second before reading again
}
Q: Can the MQ135 detect CO2 accurately? A: The MQ135 can detect CO2, but it is not a dedicated CO2 sensor. For precise CO2 measurements, a specialized infrared CO2 sensor is recommended.
Q: How do I adjust the sensitivity of the digital output? A: Use the onboard potentiometer to adjust the threshold for the digital output. Turn it clockwise to increase sensitivity and counterclockwise to decrease it.
Q: Is the MQ135 sensor suitable for outdoor use? A: While the MQ135 can be used outdoors, it should be protected from water, dust, and direct sunlight to ensure accurate readings.