Sunteți pe pagina 1din 10

RB-See-200

Seeedstudio Grove Air Quality Sensor


Grove - Air quality sensor

Introduction
The sensor is designed for indoor air quality testing. The main gas detected is carbon monoxide, alcohol,
acetone, thinner, formaldehyde and other slightly toxic gases. The signal of sensor's is analog which can
not be used as the standard of air pollution. Calculate the rate of voltage rised in unit time then judge
the pollution level according the rate.

Feature

Low power consumption


High sensitivity
Tiny outline
Long life

Application Ideas

Automatic air ventilation


Indoor air quality detector

Cautions

Make sure the air is clean when the sensor restart.


Make sure the sensor's net side be fixed vertical downward.
The sensor is not suitable for detecting pollution environment which has lasted a long time.

Usage
Hardware Installation
Connect the sensor to base shield A0 port, download program then open serial monitor. Waitting for 2
minutes (the sensor need to preheat), then testing will begin. We define 4 status, first is high
pollution(with force signal output), second is high pollution(without force signal), next is low pollution,
the last is air fresh. The four signals in program is "force","high_pollution","low_pollution" and
"air_fresh".

Program
/***************************
* File Name

************************

: air quality sensor.pde

* Author

: Seeedteam

* Version

: V1.0

* Date

2011 Seeedstudio

: 29/11/2011

* Description

********************************************************************************
*
*******************************************************************************/
boolean low_pollution;
boolean high_pollution;
boolean air_fresh;
boolean force;
boolean error;
boolean signal=0;
unsigned char counter=0;
unsigned char i=0;
unsigned int temp=0;
float low_voltage=0;
int first_vol=0;
int last_vol=0;
long vol_standard=0;

void sys_init()

{
unsigned char i=0;
digitalWrite(13,LOW);
Serial.println("sys_starting...");
delay(20000);//300000
digitalWrite(13,HIGH);
low_voltage=analogRead(A0);
Serial.println(low_voltage);
while(low_voltage)
{
if(low_voltage<798 && low_voltage>10)//798 corresponding voltage is 3.9V
{
first_vol=analogRead(A0);//initialize first value
last_vol=first_vol;
vol_standard=last_vol;
Serial.println("Sensor ready.");
error=0;
break;
}
else if(low_voltage>798||low_voltage<=10)
{
i++;
delay(60000);//600000
Serial.println("waitting sensor init..");
low_voltage=analogRead(A0);

if(i==5)
{
i=0;
error=1;
Serial.println("Sensor Error!");
}
}
else
break;
}
}

void interrupt_init()
{
TCCR2A=0;//normal model
TCCR2B=0x07;//set clock as 1024*(1/16M)
TIMSK2=0x01;//enable overflow interrupt
}

void slope()
{
while(signal)
{
if(first_vol-last_vol>400||first_vol>700)
{

low_pollution=0;
high_pollution=0;
force=1;
air_fresh=0;
Serial.println("High pollution! Force signal active.");
signal=0;
avg_voltage();
break;
}
else if((first_vol-last_vol>400&&first_vol<700)||first_vol-vol_standard>150)
{
high_pollution=1;
low_pollution=0;
force=0;
air_fresh=0;
Serial.print("sensor_value:");
Serial.print(first_vol);
Serial.println("\t High pollution!");
signal=0;
avg_voltage();
break;
}
else if((first_vol-last_vol>200&&first_vol<700)||first_vol-vol_standard>50)
{
low_pollution=1;

high_pollution=0;
//low_pollution=0;
force=0;
air_fresh=0;
//Serial.println(first_vol-last_vol);
Serial.print("sensor_value:");
Serial.print(first_vol);
Serial.println("\t Low pollution!");
signal=0;
avg_voltage();
break;
}
else
{
//temp+=first_vol;
avg_voltage();
high_pollution=0;
low_pollution=0;
force=0;
air_fresh=0;
Serial.print("sensor_value:");
Serial.print(first_vol);
//Serial.print("\t avg_vol:");
//Serial.print(avg_vol);
Serial.println("\t Air fresh");

//Serial.println(i,DEC);
signal=0;
}
}
}

void avg_voltage()
{
if(i==150)//sum 2 minutes
{
vol_standard=temp/150;
temp=0;
Serial.print("Vol_standard:");
Serial.println(vol_standard);
i=0;
}
else
{
temp+=first_vol;
//Serial.println(i,DEC);
i++;
}
}

void setup()

{
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(13,OUTPUT);
//pinMode(2,OUTPUT);
//pinMode(3,OUTPUT);
sys_init();
interrupt_init();
Serial.println("Test begin...");
sei();
}

void loop()
{
slope();
}

ISR(TIMER2_OVF_vect)
{
if(counter==122)//set 2 seconds as a detected duty
{
last_vol=first_vol;
first_vol=analogRead(A0);
counter=0;
signal=1;

PORTB=PORTB^0x20;
}
else
{
counter++;
//Serial.println(counter,DEC);
}
}

S-ar putea să vă placă și