Professional Documents
Culture Documents
3
Introduction
This sensor is designed for comprehensive monitor over indoor air condition. Its
responsive to a wide scope of harmful gases, as carbon monoxide, alcohol, acetone,
thinner, formaldehyde and so on. Due to the measuring mechanism, this sensor cant
output specific data to describe target gases concentrations quantitatively. But its
still competent enough to be used in applications that require only qualitative results,
like auto refresher sprayers and auto air cycling systems.``
Features
Usage
With Arduino
We encapsulated the decision structure in a .cpp file. You can find information there
on how to modify the thresholds.
3.Wait at least 2 minutes after powering on for heat-up of the sensor. Then open the
example below by the path: File -> Example ->AirQuality_Sensor-
>AirQuality_Sensor.
/*
* By: http://www.seeedstudio.com
*/
#include "AirQuality.h"
#include "Arduino.h"
AirQuality airqualitysensor;
void setup()
Serial.begin(9600);
airqualitysensor.init(14);
void loop()
current_quality=airqualitysensor.slope();
if (current_quality==0)
else if (current_quality==1)
Serial.println("High pollution!");
else if (current_quality==2)
Serial.println("Low pollution!");
ISR(TIMER2_OVF_vect)
airqualitysensor.last_vol=airqualitysensor.first_vol;
airqualitysensor.counter=0;
airqualitysensor.timer_index=1;
PORTB=PORTB^0x20;
else
airqualitysensor.counter++;
int AirQuality::slope(void)
while(timer_index)
if(first_vol-last_vol>400||first_vol>700)
timer_index=0;
avg_voltage();
return 0;
}
else if((first_vol-last_vol>400&&first_vol<700)||first_vol-vol_standard>150)
Serial.print("sensor_value:");
Serial.print(first_vol);
timer_index=0;
avg_voltage();
return 1;
else if((first_vol-last_vol>200&&first_vol<700)||first_vol-vol_standard>50)
//Serial.println(first_vol-last_vol);
Serial.print("sensor_value:");
Serial.print(first_vol);
timer_index=0;
avg_voltage();
return 2;
else
avg_voltage();
Serial.print("sensor_value:");
Serial.print(first_vol);
timer_index=0;
return 3;
}
return -1;
With Raspberry Pi
cd yourpath/GrovePi/Software/Python/
import time
import grovepi
# SIG,NC,VCC,GND
air_sensor = 0
grovepi.pinMode(air_sensor,"INPUT")
while True:
try:
sensor_value = grovepi.analogRead(air_sensor)
else:
print "Air fresh"
time.sleep(.5)
except IOError:
print "Error"