Grove Dust Sensor
来自Jack's Lab
(版本间的差异)
(→Overview) |
(→Example code) |
||
| (未显示1个用户的11个中间版本) | |||
| 第12行: | 第12行: | ||
* Standby Current Supply 90mA | * Standby Current Supply 90mA | ||
* Dimensions 59(W) × 45(H) × 22(D) mm | * Dimensions 59(W) × 45(H) × 22(D) mm | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == Example code == | ||
| + | |||
| + | <source lang=cpp> | ||
| + | /* | ||
| + | Grove - Dust Sensor Demo v1.0 | ||
| + | Interface to Shinyei Model PPD42NS Particle Sensor | ||
| + | Program by Christopher Nafis | ||
| + | Written April 2012 | ||
| + | |||
| + | http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html | ||
| + | http://www.sca-shinyei.com/pdf/PPD42NS.pdf | ||
| + | |||
| + | JST Pin 1 (Black Wire) => //Arduino GND | ||
| + | JST Pin 3 (Red wire) => //Arduino 5VDC | ||
| + | JST Pin 4 (Yellow wire) => //Arduino Digital Pin 8 | ||
| + | */ | ||
| + | |||
| + | int pin = 8; | ||
| + | |||
| + | unsigned long duration; | ||
| + | unsigned long starttime; | ||
| + | |||
| + | unsigned long sampletime_ms = 30000; //sampe 30s | ||
| + | |||
| + | unsigned long lowpulseoccupancy = 0; | ||
| + | float ratio = 0; | ||
| + | float concentration = 0; | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(9600); | ||
| + | pinMode(8,INPUT); | ||
| + | starttime = millis(); //get the current time; | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | duration = pulseIn(pin, LOW); // return us | ||
| + | lowpulseoccupancy = lowpulseoccupancy + duration; | ||
| + | |||
| + | if ((millis()-starttime) >= sampletime_ms) // if the sampel time = = 30s | ||
| + | { | ||
| + | // Integer percentage 0=>100 | ||
| + | ratio = lowpulseoccupancy / (sampletime_ms * 10.0); | ||
| + | |||
| + | // using spec sheet curve | ||
| + | concentration = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62; | ||
| + | |||
| + | Serial.print("concentration = "); | ||
| + | Serial.print(concentration); | ||
| + | Serial.println(" pcs/0.01cf, LowPulsOccu = "); | ||
| + | Serial.print(lowpulseoccupancy); | ||
| + | Serial.print(", Ratio = "); | ||
| + | Serial.println(ratio); | ||
| + | |||
| + | lowpulseoccupancy = 0; | ||
| + | starttime = millis(); | ||
| + | } | ||
| + | } | ||
| + | </source> | ||
| + | |||
| + | <br><br> | ||
| + | |||
| + | == Output == | ||
| + | |||
| + | [[文件:PPD42NS-Characteristics.jpg]] | ||
<br> | <br> | ||
| 第19行: | 第86行: | ||
* http://wiki.seeedstudio.com/Grove-Dust_Sensor/ | * http://wiki.seeedstudio.com/Grove-Dust_Sensor/ | ||
* https://seeeddoc.github.io/Grove-Dust_Sensor/ | * https://seeeddoc.github.io/Grove-Dust_Sensor/ | ||
| + | * [https://publiclab.org/system/images/photos/000/010/161/original/Spec_PPD42NJ_Eng_SPP13001V00_20130319.pdf PPD42NS Datasheet] | ||
| + | <br><br> | ||
| + | <br><br> | ||
| + | <br><br> | ||
| + | <br><br> | ||
| + | <br><br> | ||
<br><br> | <br><br> | ||
2018年10月25日 (四) 22:11的最后版本
目录 |
[编辑] 1 Overview
- Detectable range of concentration 0~28,000 / 0 ~ 8000 pcs/liter / pcs/0.01cf
- Detecting the particle diameter >1μm
- Output: Negative Logic, Digital output, High: over 4.0V(Rev.2), Low: under 0.7V
- Weight 28g
- VCC 4.75~5.75V
- Standby Current Supply 90mA
- Dimensions 59(W) × 45(H) × 22(D) mm
[编辑] 2 Example code
/*
Grove - Dust Sensor Demo v1.0
Interface to Shinyei Model PPD42NS Particle Sensor
Program by Christopher Nafis
Written April 2012
http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html
http://www.sca-shinyei.com/pdf/PPD42NS.pdf
JST Pin 1 (Black Wire) => //Arduino GND
JST Pin 3 (Red wire) => //Arduino 5VDC
JST Pin 4 (Yellow wire) => //Arduino Digital Pin 8
*/
int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 30000; //sampe 30s
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
void setup() {
Serial.begin(9600);
pinMode(8,INPUT);
starttime = millis(); //get the current time;
}
void loop() {
duration = pulseIn(pin, LOW); // return us
lowpulseoccupancy = lowpulseoccupancy + duration;
if ((millis()-starttime) >= sampletime_ms) // if the sampel time = = 30s
{
// Integer percentage 0=>100
ratio = lowpulseoccupancy / (sampletime_ms * 10.0);
// using spec sheet curve
concentration = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62;
Serial.print("concentration = ");
Serial.print(concentration);
Serial.println(" pcs/0.01cf, LowPulsOccu = ");
Serial.print(lowpulseoccupancy);
Serial.print(", Ratio = ");
Serial.println(ratio);
lowpulseoccupancy = 0;
starttime = millis();
}
}
[编辑] 3 Output
[编辑] 4 Reference
- http://wiki.seeedstudio.com/Grove-Dust_Sensor/
- https://seeeddoc.github.io/Grove-Dust_Sensor/
- PPD42NS Datasheet
