In this tutorial, we will interface an optical dust sensor with Surilli WiFi. Whenever any quantity of dust is detected, the optical dust sensor will sense it.
What Is an Optical Dust Sensor?
An optical dust sensor is designed to sense smoke / dust particles. An infrared emitting diode and a phototransistor are diagonally arranged into this device, to allow it to detect the reflected light of dust in air. It is especially effective in detecting very fine particles like cigarette smoke, and is commonly used in air purifier systems.
1. Optical dust sensor
2. Connecting wires
3. Surilli WiFi
4. Breadboard
5. 150 ohms resistor
6. 220uF capacitor
STEP 1: Set Up Arduino IDE for SurilliMake sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).
STEP 2: The CircuitryThe circuitry is very simple. It's mostly the programming. Follow the figure below to set up your hardware.
Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload. After it is uploaded, the optical dust sensor will start working and its results can be viewed on the Serial Monitor in Arduino IDE.
Arduino Codeint measurePin = A0;
int ledPower = 12;
unsigned int samplingTime = 280;
unsigned int deltaTime = 40;
unsigned int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
}
void loop(){
digitalWrite(ledPower,LOW);
delayMicroseconds(samplingTime);
voMeasured = analogRead(measurePin);
delayMicroseconds(deltaTime);
digitalWrite(ledPower,HIGH);
delayMicroseconds(sleepTime);
calcVoltage = voMeasured*(5.0/1024);
dustDensity = 0.17*calcVoltage-0.1;
if ( dustDensity < 0)
{
dustDensity = 0.00;
}
Serial.println("Raw Signal Value (0-1023):");
Serial.println(voMeasured);
Serial.println("Voltage:");
Serial.println(calcVoltage);
Serial.println("Dust Density:");
Serial.println(dustDensity);
delay(1000);
}
Play with the program to see how it reacts to different values and logic.
If you make something fun and interesting, do share it with our community.
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with the Surilli family for more amazing stuff. :-)
Comments