Measuring Air Quality With IoT


Pollution is increasing day by day and health risk is incresing with increasing pollution. A simple air quality detection system can be made to detect the quality of air around us.  So let us create an Air Quality Monitor with the Internet of Things.

Requirements

  • Intel Edison
  • Grove Base Shield
  • Air Quality Sensor
  • Jumper Cables
  • USB Cable

Air Quality Sensor

This sensor is designed for comprehensive monitoring over indoor air conditions. It’s responsive to a wide scope of harmful gases, such as carbon monoxide, alcohol, acetone, thinner, formaldehyde and so on. Due to the measuring mechanism, this sensor cannot output specific data to describe target gas concentrations quantitatively. But it’s still competent enough to be used in applications that require only qualitative results, like auto refresher sprayers and auto air cycling systems.

image001 (1)

image002 (1)

Features

  • Responsive to a wide scope of target gases
  • Cost efficient
  • Durable

Connections

  1. Power on the Edison board.
  2. Wait for 15-20 seconds to boot up.
  3. Stack grove base shield.
  4. Connect the air quality sensor to A0 port.

Working

Download the file!

Save this to your Arduino folder.

Then open the example below by the path:

File / Example / AirQuality_Sensor / AirQuality_Sensor

Upload the code and see the results in serial monitor.

image003 (1)

Code

#include "AirQuality.h"  

#include "Arduino.h"  

AirQuality airqualitysensor;  

int current_quality =-1;  

void setup()  

{  

    Serial.begin(9600);  

    airqualitysensor.init(14);  

}  

void loop()  

{  

    current_quality=airqualitysensor.slope();  

    if (current_quality >= 0)// if a valid data returned.  

    {  

        if (current_quality==0)  

        Serial.println("High pollution! Force signal active");  

        else if (current_quality==1)  

        Serial.println("High pollution!");  

        else if (current_quality==2)  

        Serial.println("Low pollution!");  

        else if (current_quality ==3)  

        Serial.println("Fresh air");  

    }  

}  

ISR(TIMER2_OVF_vect)  

{  
  if(airqualitysensor.counter==122)//set 2 seconds as a detected duty  

    {  
        airqualitysensor.last_vol=airqualitysensor.first_vol;  

        airqualitysensor.first_vol=analogRead(A0);  

        airqualitysensor.counter=0;  

        airqualitysensor.timer_index=1;  

        PORTB=PORTB^0x20;  
    }  

    else  

    {  
        airqualitysensor.counter++;  
    }  

}

Cautions

 

  • Require relatively clean air as an initial condition.
  • Long time exposure to highly polluted air can significantly weaken its sensitivity.

Leave a comment

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