วันพุธที่ 8 กุมภาพันธ์ พ.ศ. 2560

arduino ตรวจจับควัน


Dust Sensor (ตรวจจับควันและฝุ่นละออง) 

ผลการค้นหารูปภาพสำหรับ Dust Sensor (ตรวจจับควันและฝุ่นละออง)

                Dust Sensor เป็น Sensor ใช้สำหรับตรวจจับควันและฝุ่นละอองในอากาศ ค่าที่ได้ออกมาเป็น Analog 1-1023 ลักษณะการทำงานคือ Sensor จะส่งแสงเลเซอร์ ไปกระทบกับตัวรับ และให้อากาศผ่านในช่อง หากการรับแสงมีน้อยแสดงว่าฝุ่นละออกเยอะ หากมีการรับแสงได้มากแสดงว่าฝุ่นละอองน้อย สามารถวัด ควันธูป แป้ง ฝุ่น ได้ นำไปประยุคใช้กับ Air purifier, Air conditioner, Air monitor

ในหนึ่งชุดประกอบด้วย

Dust Sensor Sharp GP2Y1010AU0F 1 ตัว
สายไฟ  1 ชุด
ตัวต้านทาน 150ohm   1 ตัว
ตัวเก็บประจุ  16v220uF 1 ตัว

ตัวอย่างโค้ด

int measurePin = A1;

int ledPower = 12;

int samplingTime = 280;

int deltaTime = 40;

int sleepTime = 9680;

int voMeasured = 0;

float calcVoltage = 0;

float dustDensity = 0;

int totalvoMeasured = 0;

float totaldustDensity = 0;



#include

#include



// Module connection pins (Digital Pins)

#define CLK 2

#define DIO 3



// The amount of time (in milliseconds) between tests

#define TEST_DELAY   2000



TM1637Display display(CLK, DIO);



void setup()

{

  Serial.begin(9600);

  pinMode(ledPower,OUTPUT);

 display.setBrightness(0xF);

 uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };

 display.setSegments(data);

 pinMode(4, OUTPUT);

 pinMode(5, OUTPUT);

 pinMode(6, OUTPUT);

}

void loop()

{

for (int i=1; i <= 10; i++){

  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);

  calcVoltage = voMeasured * (3.3 / 1024);


/*  if(voMeasured<=85){       //ตั้งค่า

  voMeasured = 0;

  }

  else{

    voMeasured = voMeasured-85;

  }*/

  voMeasured = map(voMeasured, 80, 418, 0, 100);

if(voMeasured<=0){

    voMeasured = 0;

  }


  dustDensity = 0.17 * calcVoltage - 0.1;

  totalvoMeasured = voMeasured+totalvoMeasured;

  totaldustDensity = dustDensity+totaldustDensity;

  delay(100);

}

  totalvoMeasured = totalvoMeasured/10;

  totaldustDensity = totaldustDensity/10;

  Serial.print("Raw Signal Value (0-100): ");

  Serial.print(totalvoMeasured);

  Serial.print(" - Dust Density: ");

  Serial.println(totaldustDensity);

  uint8_t segto;

  display.showNumberDec(totalvoMeasured);     //แสดง ใน 7 segment

  delay(500);

  if(totalvoMeasured <= 40){

    digitalWrite(4, LOW);

    digitalWrite(5, LOW);

    digitalWrite(6, LOW);

    }

  else if (totalvoMeasured <= 60){

    digitalWrite(4, HIGH);

    digitalWrite(5, LOW);

    digitalWrite(6, LOW);

    }

  else if (totalvoMeasured <= 80){

    digitalWrite(4, LOW);

    digitalWrite(5, HIGH);

    digitalWrite(6, LOW);

    }

  else{

    digitalWrite(4, LOW);

    digitalWrite(5, LOW);

    digitalWrite(6, HIGH);

    }

  totalvoMeasured = 0;

  totaldustDensity = 0;

  delay(500);

}

ข้อมูลเพิ่มเติม

datasheets : https://www.sparkfun.com/datasheets/Sensors/gp2y1010au_e.pdf


อ้างอิง

https://www.9arduino.com/

ไม่มีความคิดเห็น:

แสดงความคิดเห็น