|
|
(2 intermediate revisions by 2 users not shown) |
Line 3: |
Line 3: |
| |- | | |- |
| | | | | |
− | [[File: Microduino-Dust.jpg|400px|thumb|right| Sensor-Dust]] | + | [[File: Microduino-Dust.jpg|200px|thumb|right| Sensor-Dust]] |
| The product number of Sensor-Dust is: '''MSDT62''' | | The product number of Sensor-Dust is: '''MSDT62''' |
| | | |
Line 9: |
Line 9: |
| | | |
| ==Sensor Pin Introduction== | | ==Sensor Pin Introduction== |
− | {{Sensor_explain | + | {{ST_Pinout |
− | |nameA=[[Sensor-Dust]] | + | |st_name=Dust Sensor |
− | |modeA=Soft serial port tx
| + | |pin3=Analog Input |
− | |modeB=Soft serial port rx | |
| }} | | }} |
| + | |
| ==Features== | | ==Features== |
| *Adopt SHARP GP2Y1010AUOF air quality sensor; | | *Adopt SHARP GP2Y1010AUOF air quality sensor; |
Line 57: |
Line 57: |
| | | |
| ==Application== | | ==Application== |
− | *All hardware needed: [[Microduino-CoreUSB]], [[Microduino-Sensorhub]], [[Sensor-IO Split]], a USB cable and several wires;
| + | It can be used to detect the air quality and indoor dust and so on. |
− | ** Make sure you build Microduino IDE or refer to: [[Microduino Getting started]]
| |
− | *Program
| |
− | <source lang="cpp">
| |
− | | |
− | #include <SoftwareSerial.h>
| |
− | SoftwareSerial pmSerial(4, 5); //PM2.5 sensor soft serail port
| |
− | #define INTERVAL_pm25 200
| |
− | unsigned long pm25_time = millis();
| |
− | | |
− | void setup() {
| |
− | Serial.begin(9600); // See the connection status in Serial Monitor
| |
− | pmSerial.begin(2400); //start the soft serial port at first
| |
− | }
| |
− | | |
− | void loop() {
| |
− | if (pm25_time > millis()) pm25_time = millis();
| |
− | if (millis() - pm25_time > INTERVAL_pm25) {
| |
− | Serial.println(PM25()) ;
| |
− | pm25_time = millis(); //update the counter
| |
− | }
| |
− | }
| |
− | | |
− | float PM25() {
| |
− | int data_s = 0; //serial receives the data
| |
− | int num = -1; //serial receives the data and counts
| |
− | int sum = 0; //checksum
| |
− | int cal[5]; //receive the data buffer
| |
− | float dustDensity = 0; //PM2.5 intensity
| |
− | | |
− | pmSerial.listen();
| |
− | while (1) {
| |
− | if (pmSerial.available() > 0) { //serail cache data
| |
− | data_s = pmSerial.read(); //read the serial cache data
| |
− | if (data_s == 0xAA) { //attain the starting position of the data frame
| |
− | num = 0; //start to count
| |
− | }
| |
− | else if (num >= 0) {
| |
− | cal[num++] = data_s; //read teh data and the number+1, and store the data into the buffer
| |
− | if (num == 6) { //read to the last bit of the data frame
| |
− | sum = cal[0] + cal[1] + cal[2] + cal[3]; //calculate the checksum
| |
− | if (sum == cal[4] && cal[5] == 0xFF) { //checksum match, the last bit of the data frame is 0xFF, representing the data frame received is normal
| |
− | dustDensity = (cal[0] * 256 + cal[1]) * (5.0 / 1024) * 550; //calculate the PM2.5 intensity, in ug/m3
| |
− | }
| |
− | else { //the data received is abnormal
| |
− | dustDensity = 0; //clear the intensity
| |
− | }
| |
− | break;
| |
− | }
| |
− | }
| |
− | }
| |
− | }
| |
− | pmSerial.stopListening();
| |
− | return dustDensity ;
| |
− | }
| |
− | </source>
| |
− | *Software:
| |
− | *Stack all modules together and then connect the Dust sensor's fan control interface with the D10 pin of the Sensorhub with a wire.
| |
− | *Connect Microduino-Dust sensor's control detection interface to the IO splitter's IN interface with a wire. And then connect the IO splitter's A-OUT interface to Sensorhub A0, the IO splitter's *B-OUT interface to Sensorhub D12.
| |
− | *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.
| |
− | *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== |
| | | |
| ==History== | | ==History== |