Professional Documents
Culture Documents
The
sensor works optically, using an infrared light (emitted by an infrared emitting diode) reflected off of the
dust or smoke particles to generate an output voltage which correlates linearly to particle concentration
up to approximately 0,5mg/m3 which is far more than we will (hopefully) measure, since that
concentration is associated with very serious pollution. The system setup is very simple, is it directly
connected to an Arduino board and uses a small amount of code to integrate with it and transform the
voltage measured to actual concentrations and outputting them as text to whatever output the Arduino
system is connected to. In our case, we will use the Arduino boards along with a GSM router to establish
an uplink with a dedicated server in order to receive and process the information from the whole
network, looking for patterns and trends in pollution and verifying the effectiveness of our project.
/************************************************************************************
*********************
* File : DustSensor
* Hardware Environment:
* Version : V1.0.5-r2
* By : WaveShare
* http://www.waveshare.net
* http://www.waveshare.com
*************************************************************************************
********************/
/*
I/O define
*/
/*
variable
*/
int adcvalue;
/*
private function
*/
int Filter(int m)
int i;
if(flag_first == 0)
flag_first = 1;
for(i = 0, sum = 0; i < _buff_max; i++)
_buff[i] = m;
sum += _buff[i];
return m;
else
sum -= _buff[0];
_buff[9] = m;
sum += _buff[9];
i = sum / 10.0;
return i;
void setup(void)
pinMode(iled, OUTPUT);
void loop(void)
/*
get adcvalue
*/
digitalWrite(iled, HIGH);
delayMicroseconds(280);
adcvalue = analogRead(vout);
digitalWrite(iled, LOW);
adcvalue = Filter(adcvalue);
/*
*/
/*
voltage to density
*/
voltage -= NO_DUST_VOLTAGE;
else
density = 0;
/*
*/
Serial.print(density);
Serial.print(" ug/m3\n");
delay(1000);