Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
40 min
Share

Detect smoke and air quality using MQ-135 Sensor

There are many reasons that may cause air pollution and affect the quality of the air. In many places, it is necessary to monitor air quality, such as in hospitals, and the rate of harmful gas emissions, such as in factories.

Project Video

Overview

In this tutorial we make a high-efficiency alarm system that will notify you when harmful gases are released into the air using the MQ-135 sensor.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Air Quality Sensor (MQ-135)
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the MQ-135 sensor and the Arduino, as shown in the image below.

 Connections from the MQ135 sensor:


      • VCC pin→ Arduino 5V pin


      • GND pin→ Arduino GND pin


       • A0 pin→ Arduino pin A0

Coding


/*
 Voltaat learn (http://learn.voltaat.com/)
 Link for full tutorial:

 Tutorial: Detect smoke and air quality using MQ-135 Sensor

 The function of this sketch is to Detect smoke and air quality using MQ-135 Sensor and Arduino

 Connections from the MQ135 sensor:
 • VCC pin→ Arduino 5V pin
 • GND pin→ Arduino GND pin
 • A0 pin→ Arduino pin A0
*/


// define MQ135 variable with A0 value that represent the input analog pin in the arduino
int MQ135 = A0;

// define standardAir variable with 200 value
int standardAir = 200;


// Commands inside void setup run once
void setup()
{
 // MQ135 is defined as an input
 pinMode(MQ135, INPUT);

 // Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);

}

// Commands inside void loop run forever
void loop()
{
 // Read the value of analog input from MQ135 and assign it in the variable sensorRead
 int sensorRead = analogRead(MQ135);

 // print "Sensor Reading: " to the serial monitor at the same line
 Serial.print("Sensor Reading: ");

 // print The sensorRead value to the serial monitor at the same line
 Serial.print(sensorRead);

 // compare the sensor reading value with the standard fresh air value that we set in the code
 if (sensorRead > standardAir)
 {
   // print " ,Gas is detected" to the serial monitor at new line
   Serial.println(" ,Gas is detected");
 }
 else
 {

   // print " ,No gas detected" to the serial monitor at new line
   Serial.println(" ,No gas detected");
 }


}

Testing it Out

You should also ensure that you have selected the correct baud rate (9600) as specified in the code.

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

As shown in the image below, the serial monitor now displays the sensor reading value and gas detection status. The value is updated and printed every second due to the delay we added in our code.

know when your plant needs watering

Resources

No items found.