Ks0196 keyestudio PM2.5 Shield: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
Line 80: Line 80:
</pre>
</pre>


'''Project 2: Now, use testing codes.<br>''''''
'''Project 2: Now, use testing codes.<br>'''
<pre>
<pre>
int dustPin=0;
int dustPin=0;

Revision as of 15:45, 13 October 2017

KS0196 keyestudio PM2.5 Shield


thumb

Introduction

Dust Sensor based on Sharp optics works well in detecting very delicate particle, like cigarette smoke, is a commonly used system of air purifier.
This device contains IR LED and photoeletric transistor. Arranging them with across corners can detect the reflected light of dust in the air. It has a ultra-low power consumption(Max at 20mA, Typical at 11mA ), and can be equipped with sensors up to 7VDC. Analog voltage is proportional to measured concentration of dust , and sensitivity is 0.5V/0.1mg/m3.

thumb

Specification

  • Power Voltage: 5-7V
  • Working Temperature: -10-65 ℃
  • Current Consumption:Max 20mA
  • Detecting Value of Minimum Particle: 0.8μ
  • Sensitivity:0.5V/(0.1mg/m3)
  • Voltage of Cleaning Air: 0.9V(Typical)
  • Storage Temperature:-20~80℃
  • Service Life:5 Years
  • Size:62mm×32mm×20mm

Connection Diagram

Project 1:

thumb

Project 2:

thumb

Sample Code

Download the Libraries of Wire and LiquidCrystal_I2C: [1]

Download the Code: [2] or you can directly copy the below code.

Project 1: The following are sample codes shown by official; when using it, just make a little change in the codes.

//pressing nothing to display value of analog revolving potentiometer
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
int measurePin = 0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2;   //Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Raw Signal Value: ");
  lcd.setCursor(0,2);
  lcd.print("Voltage:");
  lcd.setCursor(0,3);
  lcd.print("Dust Density:");
  pinMode(ledPower,OUTPUT);
}
void loop(){
  digitalWrite(ledPower,LOW); // power on the LED
  delayMicroseconds(samplingTime);
  voMeasured = analogRead(measurePin); // read the dust value
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
  // 0 - 5V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (5.0 / 1024.0);
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 0.1;
  lcd.setCursor(1,1);
  lcd.print(voMeasured);
  lcd.setCursor(9,2);
  lcd.print(calcVoltage);
  lcd.setCursor(14,3);
  lcd.print(dustDensity);
  delay(1000);
}

Project 2: Now, use testing codes.

int dustPin=0;
float dustVal=0; 
int ledPower=2;
int delayTime=280;
int delayTime2=40;
float offTime=9680;

void setup(){
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
pinMode(dustPin, INPUT);
}
 
void loop(){
// ledPower is any digital pin on the arduino connected to Pin 2 on the sensor
digitalWrite(ledPower,LOW); 
delayMicroseconds(delayTime);
dustVal=analogRead(dustPin); 
delayMicroseconds(delayTime2);
digitalWrite(ledPower,HIGH); 
delayMicroseconds(offTime);
 
delay(1000);
if (dustVal>36.455)
Serial.println((float(dustVal/1024)-0.0356)*120000*0.035);
}

Result

Result of Project 1 is shown as follows.

thumb

Result of Project 2: Open serial monitor, the value is displayed as follows.

thumb

Data compared to air quality:
3000 + = Very Bad
1050-3000 = Bad
300-1050 = Ordinary
150-300 = Good
75-150 = Very Good
0-75 = Tiptop

Documents

PDF:

http://www.keyestudio.com/files/index/download/id/1479180426/

Download the Libraries:

http://www.keyestudio.com/files/index/download/id/1506752792/

Get the Code:

http://www.keyestudio.com/files/index/download/id/1506753178/

Get One Now

http://www.keyestudio.com/ks0196-keyestudio-pm2-5-shield.html