Difference between revisions of "Sensor-Dust"
From Microduino Wiki
(→Features) |
(→Application) |
||
Line 31: | Line 31: | ||
==Application== | ==Application== | ||
− | *All hardware needed: [[Microduino-CoreUSB]], [[Microduino-sensorhub]], [[ | + | *All hardware needed: [[Microduino-CoreUSB]], [[Microduino-sensorhub]], [[Senor-IO split]], a USB cable and several wires; |
** Make sure you build Microduino IDE or refer to: [[Microduino Getting started]] | ** Make sure you build Microduino IDE or refer to: [[Microduino Getting started]] | ||
*Program | *Program | ||
Line 75: | Line 75: | ||
*Open Arduino IDE, copy the program to IDE and then choose the right board from Tools→Board and then compile. | *Open Arduino IDE, copy the program to IDE and then choose the right board from Tools→Board and then compile. | ||
*Select the right port from Tools→Serial Port in Arduino IDE after compiling, then download program. | *Select the right port from Tools→Serial Port in Arduino IDE after compiling, then download program. | ||
− | *After the download, you can open the serial monitor. After the Dust sensor's fan works for three seconds, the serial console will display the current air dust density and the Dust sensor will have another detection after one second. | + | *After the download, you can open the serial monitor. After the Dust sensor's fan works for three seconds, the serial console will display the current air dust density and the Dust sensor will have another detection after one second. |
==Purchase== | ==Purchase== |
Revision as of 06:17, 26 August 2016
Language: | English • 中文 |
---|
Microduino-Dust is a PM2.5 sensor. ContentsSensor Pin Introduction
Features
Specification
Document
DevelopmentMicroduino-Dust can be applied in outdoor air quality detection or indoor dust detection. Application
#define FAN_PIN 10 //Fan control pin
#define LED_PIN 12 //Sensor LED control pin
#define DUST_PIN A0 //Sensor detection
#define TIME1 280
#define TIME2 40
#define TIME3 9680
int dustVal = 0;
float dustVoltage = 0;
float dustDensity = 0;
void setup(){
Serial.begin(9600);
pinMode(FAN_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
digitalWrite(FAN_PIN, LOW);
}
void loop(){
digitalWrite(FAN_PIN, HIGH); //Open the fan before detecting
delay(3000);
digitalWrite(FAN_PIN, LOW); //Close the fan after 3s delay
digitalWrite(LED_PIN,LOW); //Turn on LED inside the sensor
delayMicroseconds(TIME1); //Wait for 280us
dustVal = analogRead(DUST_PIN); //Analog value sampling
delayMicroseconds(TIME2); // Wait for 40us
digitalWrite(LED_PIN,HIGH); //Turn off the LED
delayMicroseconds(TIME3);
dustVoltage = dustVal * (5.0/1024.0); //Convert the analog value to voltage value.
dustDensity = 0.17 * dustVoltage - 0.1; //Convert the voltage value to dust density (Output unit: mg / m³)
Serial.println(dustDensity);
delay(1000);
}
PurchaseHistoryPictures
|