Home Code Arduino and OPEN-SMART PM2.5 Optical Dust Smoke Sensor Module example

Arduino and OPEN-SMART PM2.5 Optical Dust Smoke Sensor Module example

by shedboy71
[lebox id="1"]

It is a dust sensor by optical sensing system. An infrared emitting diode and an phototransistor are diagonally arranged into this device. It detects the reflected light of dust in air.

Especially, it is effective to detect very fine particle like the cigarette smoke.

In addition it can distinguish smoke from house dust by pulse pattern of output voltage. It can easily connected for Arduino board because of the PM2.5 Adapter module.

– Working voltage: 4.8-5.5VDC
– Operating current: <= 20 mA
– Output mode: analog output
– Application: Air purifier, Air conditioner, Air monitor

Parts

Name Link
Arduino UNO Arduino UNO R3
OPEN-SMART PM2.5 sensor OPEN-SMART PM2.5 Optical Dust Smoke Sensor Module with Adapter Module
Connecting area Cable Dupont Jumper Wire Dupont 30CM

Code

[codesyntax lang=”cpp”]

// Demo code for PM2.5 sensor with Adapter module by OPEN-SMART Team
// Hardware:
// 1 x I2C 1602 LCD
// 1 x PM2.5 sensor with Adapter module
// Function:
// measure the PM2.5 and display on serial monitor of Arduino IDE and I2C 1602 LCD.

#include <Wire.h>
//#include <LiquidCrystal_I2C.h>

//LiquidCrystal_I2C lcd(0x38,16,2);

int VO_PIN = A0;
int LED_PIN = 2;

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(LED_PIN,OUTPUT);
//lcd.init(); // initialize the lcd
// Print a message to the LCD.
//lcd.backlight();

}

void loop(){
digitalWrite(LED_PIN,LOW);
delayMicroseconds(samplingTime);

voMeasured = analogRead(VO_PIN);

delayMicroseconds(deltaTime);
digitalWrite(LED_PIN,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);
// lcd.setCursor(0,0);
//lcd.print(calcVoltage);
//lcd.print(“V”);
//lcd.setCursor(0,1);
//lcd.print(“Dust:”);
//lcd.print(dustDensity);
Serial.println(“Dust Density:”);
Serial.println(dustDensity);
delay(500);
//lcd.clear();

delay(1000);
}

[/codesyntax]

Output

Open the serial monitor

Raw Signal Value (0-1023):
111.00
Voltage:
0.54
Dust Density:
0.00
Raw Signal Value (0-1023):
117.00
Voltage:
0.57
Dust Density:
0.00

Share
[lebox id="2"]

You may also like

Leave a Comment