Air Quality monitor using Arduino for indoor and outdoor pollution monitor

Air Quality monitor using Arduino for indoor and outdoor pollution monitor Air Quality monitor using Arduino for indoor and outdoor pollution monitor

Do you know how the air quality has changed from past generations to till now? Its a lot due to the pollution with mix for harmful gases into atmosphere. So monitoring the air quality in high population areas and industrial ares has become vital. Mainly for homes who have kids and old age people need to monitor the air quality and use some air purifiers available in the market. So taking this as scenario we came up with a project where you can monitor the air quality indoors as well as outdoors with the help Arduino and few sensor to get the data.

In this Project, we will discuss only about the air quality monitor which displays the data on a LED Screen. For online version of this project with ESP8266 please refer:

Lets see what are the requirements to build this project.

Requirements:

Hardware Requirements:

  • Arduino Uno R3
  • MQ-135 gas sensor
  • BME 280 temperature, humidity and Pressure sensor
  • PM2.5 Dust and Particulate Matter Sensor

Software Requirements:

  • Arduino IDE

Sensor Details:

MQ-135 gas sensor:

The MQ-135 is a sensor that is responsible for detecting gases such as ammonia, alcohol, benzene, smoke and carbon dioxide. It contains basic electronics to be able to interface with a microcontroller, it has 2 outputs, one analog and one digital.

MQ-135 gas sensor component

What is it for ? The MQ-135 is an air quality control sensor which allows the detection of gases such as ammonia, alcohol, benzene, smoke and carbon dioxide with a range of 10-1000 ppm (parts per million). It is used to prevent high levels of contamination. It is recommended for homes and in industries that handle chemical compounds which can be harmful to health.

How does it work? The MQ-135 sensor has low conductivity when the air is clean. When the sensor detects gases such as ammonia, alcohol, benzene, smoke and carbon dioxide, the conductivity of the sensors is higher along with the increase in gas concentration. An electro circuit is used that converts the change in conductivity to correspond to the output signal of the gas concentration.

Similar ArticleIoT Based Health Monitoring system on ESP32 Web Server

Technical specifications:
  • Working voltage: 5VDC.
  • Dual output: Analog output and TTL level output.
  • High sensitivity to Ammonia (NH3), Nitrogen oxides (NOx), Alcohol, Sulfides, Benzene (C6H6), Carbon Monoxide (CO), smoke and other harmful gases.
  • Adjustable sensitivity with potentiometer.
  • Detection range: 10-1000ppm.
  • Operation current: 150mA
  • Consumption power: 800mW
  • Preheat time: 20 seconds
  • Operating humidity: <95% RH
  • Operation temperature: -20 ° C ~ 70 ° C

BME-280 Temperature, humidity and pressure sensor:

What is it? The atmospheric pressure sensor is a plate that is made up of elements such as smd resistors, smd capacitors and a “BME280” chip developed by the BOSCH company and has the technology to measure pressure, temperature and humidity.

BME 280 product image

In addition, everything is integrated in a single piezo-resistive chip that is really compact and low energy consumption. They are also used in some applications such as: warning about dryness or high temperatures, measurement of volume and air flow, calculation of altitude for auto-pilot systems, adafruit IO (Internet of Things), home automation control, control of heating, ventilation, air conditioning (HVAC) and weather forecast.

Technical Specifications:
  • Operating voltage: 1.8 Volts @ 3.3 Volts
  • Pressure: 300 to 1100 hPa
  • Temperature: -40 ° C to 85 ° C
  • Relative humidity: 0-100% RH

PM2.5 Dust and Particulate Matter Sensor

With the PMS5003 PM2.5 Air Quality Sensor you can reliably measure the concentration of PM2.5 particles (which refers to the concentration of particles 2.5 microns in diameter or less).

dust particulate sensor

The sensor uses the scattering of laser light to irradiate the suspended particles in the air, then captures the scattered laser light and gets a fairly accurate estimate of the amount of suspended particles per unit volume through a microprocessor.

Interfacing Arduino with required sensors:

Lets learn how to connect all the components with the help of a schematic diagram in the below image.

Circuit Diagram:

Air Quality monitor system using Arduino circuit diagram

In the above circuit we connected 3 sensor boards. Initially we connected MQ135 with 5v VCC power supply and GND from arduino and connected the AOUT to the analog A0 pin on Arduino.

Then connected BME 280 with 3.3V  and GND from Arduino to VIN and GND of BME 280 respectively. then SCL pin to A5 and SDA pin to A4 pin of Arduino .

PMS5003 is connected to Arduino as pin1 of sensor to 5V supply from Arduino and pin2(GND) to GND, Pin 4(RX) of sensor to Tx of Arduino and Pin5(TX) of sensor to RX of Arduino. You can see the above image to know color wire of PMS5003 is for which function.

Code to upload using Arduino IDE:

Before uploading the code you need to install few required libraries listed with download links below in Arduino IDE.

Required Libraries:

  • MQ135 Library,  Download Link: here
  • BME280 Library, Download Link: here
  • Adafruit Unified Sensor Library,  Download Link: here

Disconnect PMS5003 Dust and Particulate Matter Sensor before uploading code because its pins are connected to TX and RX of Arduino. You can connect it again after code has uploaded.

#include <Wire.h>
#include <Arduino.h>
#include "MQ135.h"
#include <Adafruit_BME280.h>
#include <Adafruit_Sensor.h>

#define LENG 31   //0x42 + 31 bytes equal to 32 bytes
unsigned char buf[LENG];
 
int PM01Value=0;          //define PM1.0 value of the air detector module
int PM2_5Value=0;         //define PM2.5 value of the air detector module
int PM10Value=0;         //define PM10 value of the air detector module
float h, t, p, pin, dp;
char temperatureFString[6];
char dpString[6];
char humidityString[6];
char pressureString[7];
char pressureInchString[6];
 
Adafruit_BME280 bme; // I2C
 
void setup()
{
  Serial.begin(9600);   
  delay(10);
  Serial.println();
  
 
  if (!bme.begin()) 
  {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
}
 
void loop()
{
  if(Serial.find(0x42)){    //start to read when detect 0x42
    Serial.readBytes(buf,LENG);
 
    if(buf[0] == 0x4d){
      if(checkValue(buf,LENG)){
        PM01Value=transmitPM01(buf); //count PM1.0 value of the air detector module
        PM2_5Value=transmitPM2_5(buf);//count PM2.5 value of the air detector module
        PM10Value=transmitPM10(buf); //count PM10 value of the air detector module 
      }           
    } 
  }
 
  static unsigned long OledTimer=millis();  
    if (millis() - OledTimer >=1000) 
    {
      OledTimer=millis(); 
      
      Serial.print("PM1.0: ");  
      Serial.print(PM01Value);
      Serial.println("  ug/m3");            
    
      Serial.print("PM2.5: ");  
      Serial.print(PM2_5Value);
      Serial.println("  ug/m3");     
      
      Serial.print("PM10 : ");  
      Serial.print(PM10Value);
      Serial.println("  ug/m3");   
      Serial.println();
 
      MQ135 gasSensor = MQ135(A0);
      float air_quality = gasSensor.getPPM();
      Serial.print("Air Quality: ");  
      Serial.print(air_quality);
      Serial.println("  PPM");   
      Serial.println();
 
      h = bme.readHumidity();
      t = bme.readTemperature();
      t = t*1.8+32.0;
      dp = t-0.36*(100.0-h);
    
      p = bme.readPressure()/100.0F;
      pin = 0.02953*p;
      dtostrf(t, 5, 1, temperatureFString);
      dtostrf(h, 5, 1, humidityString);
      dtostrf(p, 6, 1, pressureString);
      dtostrf(pin, 5, 2, pressureInchString);
      dtostrf(dp, 5, 1, dpString);
 
      Serial.print("Temperature = ");
      Serial.println(temperatureFString);
      Serial.print("Humidity = ");
      Serial.println(humidityString);
      Serial.print("Pressure = ");
      Serial.println(pressureString);
      Serial.print("Pressure Inch = ");
      Serial.println(pressureInchString);
      Serial.print("Dew Point = ");
      Serial.println(dpString);
 
      Serial.println("...............................................");
 
    }
 
  }
char checkValue(unsigned char *thebuf, char leng)
{  
  char receiveflag=0;
  int receiveSum=0;
 
  for(int i=0; i<(leng-2); i++){
  receiveSum=receiveSum+thebuf[i];
  }
  receiveSum=receiveSum + 0x42;
 
  if(receiveSum == ((thebuf[leng-2]<<8)+thebuf[leng-1]))  //check the serial data 
  {
    receiveSum = 0;
    receiveflag = 1;
  }
  return receiveflag;
}
int transmitPM01(unsigned char *thebuf)
{
  int PM01Val;
  PM01Val=((thebuf[3]<<8) + thebuf[4]); //count PM1.0 value of the air detector module
  return PM01Val;
}
//transmit PM Value to PC
int transmitPM2_5(unsigned char *thebuf)
{
  int PM2_5Val;
  PM2_5Val=((thebuf[5]<<8) + thebuf[6]);//count PM2.5 value of the air detector module
  return PM2_5Val;
  }
//transmit PM Value to PC
int transmitPM10(unsigned char *thebuf)
{
  int PM10Val;
  PM10Val=((thebuf[7]<<8) + thebuf[8]); //count PM10 value of the air detector module  
  return PM10Val;
}

 

Working of Air Quality monitor system using Arduino:

After uploading the code open the serial monitor of the Arduino IDE to check the air quality and its metrices like the image shown below.

airquality on serial monitor of arduino ide

Here the Quality of air is indicated in Parts Per Million (PPM) Units where lower the number of PPM indicates the good quality of air and higher the number indicates the polluted air with toxic gases which can cause health issues.

Add a comment

Leave a Reply

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