ほこりセンサー

シャープのほこりセンサー(GP2Y1010AU0F)をヤフオクで入手した。
秋月でも売ってたけど、ヤフオクだと他に必要な部品も付属してる。

ほこりセンサー

ほこりセンサー

付属していた部品は次の通り。
接続用ケーブル(6Pin、約14cm) x1
・抵抗10KΩ x1
・抵抗150Ω x1
・NPNトランジスタ(2N3904)
・電解コンデンサー220μF

配線は秋月のデータシートの接続例を参考にした。
プログラムはヤフオクで紹介している http://arduinodev.woofex.net/2012/12/01/standalone-sharp-dust-sensor/ を参考にした。

ほこりセンサーの配線

ほこりセンサーの配線

/*
 Standalone Sketch to use with a Arduino Fio and a
 Sharp Optical Dust Sensor GP2Y1010AU0F
 
 Blog: http://arduinodev.woofex.net/2012/12/01/standalone-sharp-dust-sensor/
 Code: https://github.com/Trefex/arduino-airquality/
 
 For Pin connections, please check the Blog or the github project page
 Authors: Cyrille Médard de Chardon (serialC), Christophe Trefois (Trefex)
 Changelog:
   2012-Dec-01:  Cleaned up code
 
 This work is licensed under the
 Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
 To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
 or send a letter to Creative Commons, 444 Castro Street, Suite 900,
 Mountain View, California, 94041, USA.
*/
 
int measurePin = 0;//6;
int ledPower = 12;
 
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
 
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
float vcc = 5.0; //3.3;
 
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 - 3.3V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (vcc / 1024);
 
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 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);
 
  delay(1000);
}

 

変えたのは、measurePinを6->0にしてA0を使うようにして、ソースコード中の3.3を変数vccを新設して5.0に。

ほこりセンサーの出力

ほこりセンサーの出力

カテゴリー: Arduino, 部品 タグ: , パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA