Measuring Air Quality With IoT

Introduction

 
Pollution is increasing day by day. It is very hard to breathe nowadays. Conditions are worse in big cities as they are highly polluted. Pollution around us is very harmful to babies and senior citizens. It will be much more helpful if we are able to detect the air quality around us. So let us create an Air Quality Monitor with IoT.
 
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.
 
Air Quality Sensor
 
Air Quality Sensor
 
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 the 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 the serial monitor.
 
result
 
Code
  1. #include "AirQuality.h"  
  2. #include "Arduino.h"  
  3. AirQuality airqualitysensor;  
  4. int current_quality =-1;  
  5. void setup()  
  6. {  
  7.     Serial.begin(9600);  
  8.     airqualitysensor.init(14);  
  9. }  
  10. void loop()  
  11. {  
  12.     current_quality=airqualitysensor.slope();  
  13.     if (current_quality >= 0)// if a valid data returned.  
  14.     {  
  15.         if (current_quality==0)  
  16.         Serial.println("High pollution! Force signal active");  
  17.         else if (current_quality==1)  
  18.         Serial.println("High pollution!");  
  19.         else if (current_quality==2)  
  20.         Serial.println("Low pollution!");  
  21.         else if (current_quality ==3)  
  22.         Serial.println("Fresh air");  
  23.     }  
  24. }  
  25. ISR(TIMER2_OVF_vect)  
  26. {  
  27.     if(airqualitysensor.counter==122)//set 2 seconds as a detected duty  
  28.     {  
  29.    
  30.         airqualitysensor.last_vol=airqualitysensor.first_vol;  
  31.         airqualitysensor.first_vol=analogRead(A0);  
  32.         airqualitysensor.counter=0;  
  33.         airqualitysensor.timer_index=1;  
  34.         PORTB=PORTB^0x20;  
  35.     }  
  36.     else  
  37.     {  
  38.         airqualitysensor.counter++;  
  39.     }  
Cautions
  • Require relatively clean air as an initial condition.
  • Long time exposure to highly polluted air can significantly weaken its sensitivity.
Read more articles on Internet of Things (IoT):