Air Quality Monitoring System

Arduino air quality check

Welcome to the Quanta Project, in this project we are going to make a system to check the quality of the air. As we know a good quality maintain good health so. you must check the quality of the air at your home and at your office and wherever you stay. We decided to make an Arduino based air quality check system that monitors the quality automatically. so, if you wanna make or learn this project, please read all the steps carefully. I hope you will learn a lot like Arduino interfacing with the MQ series sensor, interfacing with the LCD display.

How does it work?

There are many sensors we are using in this system for the detection of the co2, co, methane, and many other toxic gases. like MQ 2, MQ 3, MQ 7, MQ135 and DHT for the temperature and humidity.there are a coil inside each sensor which activated by a particular gas so, by this, we calculate the amount of the gas present in the air with the help of the sensor. and send this reading to the Arduino and now the amount of gas and many other factors displayed over the LCD.

Normal individual spends an expected 90% of their time inside with the goal that poor indoor air quality (IAQ) represents a significant hazard to general wellbeing. Poor air quality may cause expanded transient medical issues, for example, exhaustion and sickness just as incessant respiratory illnesses, coronary illness, and lung malignant growth. It is assessed that yearly expenses and profitability misfortunes in the US are $10 to $20 billion identified with debilitated structure disorder, which is characterized to depict intense wellbeing and inconvenience impacts that give off an impression of being connected to poor indoor air quality and the time spent in a structure.

Components Required:-

  • Arduino Uno
  • MQ7
  • MQ135
  • MQ 6
  • DHT11
  • 16X2 LCD

Circuit Diagram:-

Code for Air monitoring:-

// Include Libraries

#include “Arduino.h”

#include “DHT.h”

#include “LiquidCrystal.h”

#include “MQ7.h”// Pin Definitions

#define DHT_PIN_DATA2

#define LCD_PIN_RS8

#define LCD_PIN_E7

#define LCD_PIN_DB43

#define LCD_PIN_DB54

#define LCD_PIN_DB65

#define LCD_PIN_DB76

#define MQ135_5V_PIN_AOUTA3

#define MQ6_5V_PIN_AOUTA1

#define MQ7_PIN_B1A5

// Global variables and defines// object initialization



MQ7 mq7(MQ7_PIN_B1);// define vars for testing menu

const int timeout = 10000;       //define timeout of 10 sec

char menuOption = 0;

long time0;// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with


void setup(){    // Setup Serial which is useful for debugging

// Use the Serial Monitor to view printed messages


while (!Serial) ; // wait for serial port to connect. Needed for native USB

Serial.println(“start”);       dht.begin();

// set up the LCD’s number of columns and rows

lcd.begin(16, 2);

menuOption = menu();   }// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.void loop(){          if(menuOption == ‘1’) {

// DHT22/11 Humidity and Temperature Sensor – Test Code

// Reading humidity in %

float dhtHumidity = dht.readHumidity();

// Read temperature in Celsius, for Fahrenheit use .readTempF()

float dhtTempC = dht.readTempC();

Serial.print(F(“Humidity: “)); Serial.print(dhtHumidity); Serial.print(F(” [%]t”));

Serial.print(F(“Temp: “)); Serial.print(dhtTempC); Serial.println(F(” [C]”));

}    else if(menuOption == ‘2’) {

// LCD 16×2 – Test Code

// Print a message to the LCD.

lcd.setCursor(0, 0);

lcd.print(“Circuito Rocks !”);

// Turn off the display:



// Turn on the display:




else if(menuOption == ‘3’)


// Disclaimer: The Hazardous Gas  Sensor – MQ-135 is in testing and/or doesn’t have code, therefore

it may be buggy. Please be kind and report any bugs you may find.

}    else if(menuOption == ‘4’)    {    // Disclaimer: The LPG, Butane and Propane Gas Sensor – MQ-6 is in testing and/or doesn’t have code, therefore it may be buggy. Please be kind and report any bugs you may find.    }    else if(menuOption == ‘5’) {

// Carbon Monoxide Sensor – MQ-7 – Test Code

//read CO levels from MQ-7 (please note that the MQ-7 requires few minutes of pre-heating)

int mq7Val =;

Serial.print(F(“Val: “)); Serial.println(mq7Val);    }       if (millis() – time0 > timeout)    {        menuOption = menu();    }   }// Menu function for selecting the components to be tested// Follow serial monitor for instrcutionschar menu(){    Serial.println(F(“nWhich component would you like to test?”));

Serial.println(F(“(1) DHT22/11 Humidity and Temperature Sensor”));

Serial.println(F(“(2) LCD 16×2”));

Serial.println(F(“(3) Hazardous Gas  Sensor – MQ-135”));

Serial.println(F(“(4) LPG, Butane and Propane Gas Sensor – MQ-6”));

Serial.println(F(“(5) Carbon Monoxide Sensor – MQ-7”));

Serial.println(F(“(menu) send anything else or press on board reset buttonn”));

while (!Serial.available());

// Read data from serial monitor if received    while (Serial.available())    {

char c =;

if (isAlphaNumeric(c))        {                         if(c == ‘1’)

Serial.println(F(“Now Testing DHT22/11 Humidity and Temperature Sensor”));

else if(c == ‘2’)

Serial.println(F(“Now Testing LCD 16×2”));

else if(c == ‘3’)

Serial.println(F(“Now Testing Hazardous Gas  Sensor – MQ-135 – note that this component doesn’t

have a test code”));

else if(c == ‘4’)

Serial.println(F(“Now Testing LPG, Butane and Propane Gas Sensor – MQ-6 – note that this component

doesn’t have a test code”));

else if(c == ‘5’)

Serial.println(F(“Now Testing Carbon Monoxide Sensor – MQ-7”));



Serial.println(F(“illegal input!”));

return 0;

}            time0 = millis();            return c;        }    }}Upload the code into Arduino and make connection according to the wiring diagram

What do you think?

3 points
Upvote Downvote

Written by shahid

Leave a Reply

Your email address will not be published. Required fields are marked *

Laser Door Security Alarm DIY

Autonomous plant watering Rover