AIR QUALITY MONITORING SYSTEM USING ARDUINO UNO AND MQ3


                                                                                                                        
In this tutorial-based article, we are going to learn how to build an Air quality monitoring system using Arduino UNO and MQ3 sensor.                                                                                                                    

   HARDWARE REQUIRED 

  • ARDUINO UNO
  • MQ3 SENSOR
  • JUMPER CABLES
  • LCD
  • BUZZER

 SOFTWARE REQUIRED

  • ARDUINO IDE

INTRODUCTION:

Have you ever wondered what's in the air you breathe? Or how polluted your environment really is?  

Air quality monitoring is an essential tool that allows us to measure and analyze the pollutants in our environment. By using advanced sensors and cutting-edge technologies, we can detect harmful particles in the air and take the necessary steps to improve our surroundings. Air quality monitoring has become integral to modern life, from homes to offices to public spaces. So, the built system can sense gases like NH3, benzene, smoke, alcohol, and CO2 among some other gases.

MOTIVATION:

  • In my hometown, a sudden gas leakage occurred, leading to many sudden deaths, and no one could find out what was happening there.
  • So, if this system had been installed in every home, many people would have been alerted and might have been saved too.
  • This incident motivated us to select this project and create the base model of this.

REAL-TIME IMAGES:





MQ-3 AIR QUALITY SENSOR


  • Like other sensors in the MQ series, MQ-3 also detects various gases in the atmosphere. Some of them are alcohol(Ethanol)-C2H5OH(primary gas detected),methane-CH4,propane-C3H8,butane-C4H10, LPG(Liquefied Petroleum Gas)-A mixture of propane and butane, hydrogen-H2, smoke, and combustible gases.
  • This sensor also has four pins one is for AO(Analog Output), the other one is DO(Digital Output) the other one is for VCC(Power supply) and the other pin is for Ground.
  • The output on the digital pin turns HIGH when the concentrations of these dangerous gases exceed a predetermined threshold. The board's 10k potentiometer can be used to adjust this threshold. An analog voltage that is produced by the analog output pin can be used to measure the concentration of these dangerous gases.
  • This sensor operates on 5V. 
  • This sensor requires a preheat time before it can provide accurate readings. The preheat time ensures stable and reliable measurements.
  • Calibrating the MQ-3 sensor is essential to achieve accurate and consistent readings. Calibration compensates for sensor drift and ensures reliable measurements.



TECHNICAL SPECIFICATIONS


  • Operating Voltage: 5V DC
  • Heating Power: 350 mW
  • Load Resistance(RL): 10 Kilo Ohm
  • Digital Output: 0V to 5V
  • Analog Output: 0V to 5V
  • Operating Temperature: -10 degrees to 50 degrees centigrade

CIRCUIT DIAGRAM

               


PINS ON MQ3

PINS ON ARDUINO UNO

VCC

5V

GND

GND

A0

A0

  

16×2 LCD PIN

PINS ON ARDUINO UNO

RS

Digital Pin 2

EN

Digital Pin 3

D4

Digital Pin 4

D5

Digital Pin 5

D6

Digital Pin 6

D7

Digital Pin 7

  

PINS ON BUZZER

PINS ON ARDUINO UNO

+VE

Digital pin 8

-VE

GND

 

WORKING


When the harmful gases hit the MQ3 sensor it detects it and send the input signal to Arduino and then if the detected signal reaches the maximum threshold value set by us then the buzzer beeps and on LCD we can observe air quality is high. And also we can monitor the time to time air quality on LCD.

CODE

                              

 #include<LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
#define mq A0
#define buz 7
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16,2);
pinMode(buz,OUTPUT);
lcd.print("  Air Quality");
lcd.setCursor(0,1);
lcd.print("  Monitoring  ");
delay(2000);}
void loop() {
// put your main code here, to run repeatedly:
int sense=analogRead(mq);
Serial.print("Air Qality :" +String(sense)+" ");
Serial.println(sense);
lcd.clear();
lcd.print("Air Qality :" +String(sense)+" ");
if(sense>450){
digitalWrite(buz,1);
delay(1000);
digitalWrite(buz,0);
lcd.clear();
lcd.print("AQ level HIGH");
delay(1500);
}
}

HOW DOES THE CODE WORKS?

1. The LiquidCrystal library is included at the beginning of the code. This library allows you to control LCD displays.

2. An instance of the LiquidCrystal class called lcd is created with the pin numbers 8, 9, 10, 11, 12, and 13. These pins are connected to the corresponding pins on the LCD display.

3. Two constants are defined using the #define preprocessor directive: mq is set to A0, which represents the analog input pin on the Arduino board that is used to read the air quality sensor. Buz is set to 7, which represents the digital output pin on the Arduino board connected to the buzzer.

4. The setup() function is where you initialize your program. It runs only once when the Arduino board is powered on or reset. In this function:

  • Serial communication is started at a baud rate of 9600. This allows you to send and receive data between the Arduino and a computer over the USB connection.
  • The LCD display is initialized with 16 columns and 2 rows using lcd.begin(16, 2).
  • The buz pin is configured as an output using pinMode(buz, OUTPUT).
  • Some initial text is printed on the LCD to indicate that air quality monitoring is starting.
  • There is a delay of 2 seconds using delay(2000).

5.The loop() function is where the main code execution takes place. It runs repeatedly after the setup() function has finished. In this function:

  • The sense variable is declared as an integer and is used to store the analog value read from the air quality sensor connected to the mq pin using analogRead(mq).
  • The LCD display is cleared using lcd.clear() to remove any previous content.
  • The current air quality value, stored in the sense variable, is converted to a string using String(sense) and then concatenated with the text "Air Quality:" using the + operator. The resulting string is printed on the LCD display using lcd.print().
  • If the air quality value is greater than 450, it indicates high air pollution:
  • The buzzer is turned on by setting the buz pin to HIGH (1) using digitalWrite(buz, 1).
  • There is a delay of 1 second using delay(1000).
  • The buzzer is turned off by setting the buz pin to LOW (0) using digitalWrite(buz, 0).
  • The LCD display is cleared, and a message indicating a high air quality level is printed using lcd.print().
  • There is a delay of 1.5 seconds using delay(1500).



OUTPUT




SERIAL MONITOR

                                                           NORMAL AIR QUALITY


POLLUTANT DETECTED IN AIR


SERIAL PLOTTER

NORMAL AIR


POLLUTANT DETECTED



CONCLUSION

In conclusion, we want to wind this up with, we have built an air quality monitoring system that detects the VOC, carbon dioxide, carbon monoxide, and also some alcohol like ethanol, etc. From this, we have come to know that every house has to be installed this kit which detects the time-to-time air quality. We have built the basic kit but can be extended with many MQ sensors.















 

Comments