Introduction:
DSM501B is a compact sized particle density sensor. It detects the level of indoor airborne dust, particles, and pollen. It gives output in the form of PWM. The output of the sensor can be directly connected to μ-com to control fan speed and it is also used to display the level of particles. The size of that can be detected by the sensor is limited to minimum 0.7 μm.
Components Required:
- Arduino Uno
- Dust Sensor
- Jumper wires
- Bread Board
Usage:
Dust Sensor Module had variety of applications. They are used in most of the daily life equipments. Some of the examples are: Ventilators, Air purifier, Air conditioner, etc.
Connections:
- PIN 3 (Vcc) –> Arduino Vcc
- PIN 5 (Gnd) – -> Arduino Ground
- PIN 2 (Vout 2) –> Arduino pin 8
Code:
int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 1000;//sampe 1s ;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
int gLed = 7;
int yLed = 6;
int rLed = 5;
void setup() {
Serial.begin(9600);
pinMode(8,INPUT);
pinMode(gLed,OUTPUT);
pinMode(yLed,OUTPUT);
pinMode(rLed,OUTPUT);
starttime = millis();//get the current time;
}
void loop() {
duration = pulseIn(pin, LOW);
lowpulseoccupancy = lowpulseoccupancy+duration;
if ((millis()-starttime) > sampletime_ms)//if the sampel time == 30s
{
ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100
concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
Serial.print("concentration = ");
Serial.print(concentration);
Serial.print(" pcs/0.01cf - ");
if (concentration < 1.0) {
Serial.println("It's a smokeless and dustless environment");
digitalWrite(gLed, HIGH);
digitalWrite(yLed, LOW);
digitalWrite(rLed, LOW);
}
if (concentration > 1.0 && concentration < 20000) {
Serial.println("It's probably only you blowing air to the sensor :)");
digitalWrite(gLed, HIGH);
digitalWrite(yLed, LOW);
digitalWrite(rLed, LOW);
}
if (concentration > 20000 && concentration < 315000) {
Serial.println("Smokes from matches detected!");
digitalWrite(gLed, LOW);
digitalWrite(yLed, HIGH);
digitalWrite(rLed, LOW);
}
if (concentration > 315000) {
Serial.println("Smokes from cigarettes detected! Or It might be a huge fire! Beware!");
digitalWrite(gLed, LOW);
digitalWrite(yLed, LOW);
digitalWrite(rLed, HIGH);
}
lowpulseoccupancy = 0;
starttime = millis();
}
}
No comments:
Post a Comment