https://blog.naver.com/darknisia/221222455928
[아두이노 중급] 19. 미세먼지센서(GP2Y1010AU0F, GPA2Y1014AU0F)
이번 포스트에는 조금 한 물 간 주제인 먼지센서에 대해서 써볼까 한다. 한 때 미세먼지가 엄청난 화두가 ...
blog.naver.com
https://devicemart.blogspot.com/2019/12/gp2y1010au0f.html
[아두이노] GP2Y1010AU0F 미세먼지 센서 사용해보기
전기/전자부품, 로봇/기계부품, 코딩교육 국내 1위 쇼핑몰 디바이스마트 공식 블로그입니다.
devicemart.blogspot.com
/*
Standalone Sketch to use with a Arduino UNO and a
Sharp Optical Dust Sensor GP2Y1010AU0F
*/
int measurePin = A0; //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(){
Serial.begin(9600);
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
// linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
// Chris Nafis (c) 2012
dustDensity = voMeasured*0.000830078125 - 0.1;
Serial.print("Raw Signal Value (0-1023): ");
Serial.print(voMeasured);
Serial.print(" - Voltage: ");
Serial.print(calcVoltage);
Serial.print(" - Dust Density: ");
Serial.println(dustDensity); // unit: mg/m3
delay(1000);
}
'임베디드 > Arduino' 카테고리의 다른 글
아두이노 내부 풀업 저항 사용하기 (0) | 2020.11.15 |
---|---|
발열패드 COM-11288 (0) | 2020.10.22 |
dht22 (0) | 2020.10.21 |
analogWrite() 함수 (0) | 2020.09.18 |
RGB LED 랜덤함수 (0) | 2020.09.18 |