====== SHARP GP2Y1010 ====== **reverse engineering** Afin de mettre au point notre propre détecteur de particules fines, nous avons commencé par une phase de reverse engineering sur 2 capteurs low-cost du marché : le SHARP GP2Y1010 et le SHINYEI PPD42NS. Ci-dessous les photos du Sharp désossé avec légendes. {{ :wiki:projets:plume_sharp_all.png?300 |plume_sharp_all}} {{ :wiki:projets:plume_sharp_scattered.jpg?400 |plume_sharp_scattered}} {{ :wiki:projets:plume_sharp_circuit.jpg?500 |plume_sharp_circuit}} {{ :wiki:projets:plume_sharp_casing.jpg?500 |plume_sharp_casing}} {{ :wiki:projets:plume_sharp_optics.jpg?400 |plume_sharp_optics}} Le faisceau collimaté de l'émetteur est diffusé par les particules fines. Le flux diffusé par les particules situées dans la champ optique collimaté du récepteur à un certain angle constitue la mesure. 
En pratique, ce flux est très faible. Il est le paramètre contraignant le dispositif. **Code** /* Interface to Sharp GP2Y1010AU0F Particle Sensor Program by Christopher Nafis Written April 2012 http://www.sparkfun.com/datasheets/Sensors/gp2y1010au_e.pdf http://sensorapp.net/?p=479 Sharp pin 1 (V-LED) => 5V (connected to 150ohm resister) Sharp pin 2 (LED-GND) => Arduino GND pin Sharp pin 3 (LED) => Arduino pin 2 Sharp pin 4 (S-GND) => Arduino GND pin Sharp pin 5 (Vo) => Arduino A0 pin Sharp pin 6 (Vcc) => 5V */ #include #include #include int dustPin=0; int ledPower=2; int delayTime=280; int delayTime2=40; float offTime=9680; int dustVal=0; int i=0; float ppm=0; void setup(){ Serial.begin(9600); pinMode(ledPower,OUTPUT); i=0; ppm =0; } void loop(){ i=i+1; digitalWrite(ledPower,LOW); // power on the LED delayMicroseconds(delayTime); dustVal=analogRead(dustPin); // read the dust value ppm = ppm+dustVal; delayMicroseconds(delayTime2); digitalWrite(ledPower,HIGH); // turn the LED off delayMicroseconds(offTime); } ====== SHINYEI PPD42NS ====== **reverse engineering** {{ :wiki:projets:plume_shinyei_all.jpg?400 |plume_shinyei_all}} {{ :wiki:projets:plume_shinyei_scattered.png?400 |plume_shinyei_scattered (aqicn.org)}} **Code** /* Interface to Shinyei Model PPD42NS Particle Sensor Program by Christopher Nafis Written April 2012 http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html http://www.sca-shinyei.com/pdf/PPD42NS.pdf JST Pin 1 (Black Wire) => Arduino GND JST Pin 3 (Red wire) => Arduino 5VDC JST Pin 4 (Yellow wire) => Arduino Digital Pin 8 */ int pin = 8; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 30000; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; void setup() { Serial.begin(9600); pinMode(8,INPUT); starttime = millis(); } void loop() { duration = pulseIn(pin, LOW); lowpulseoccupancy = lowpulseoccupancy+duration; if ((millis()-starttime) > sampletime_ms) { ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve Serial.print(lowpulseoccupancy); Serial.print(","); Serial.print(ratio); Serial.print(","); Serial.println(concentration); lowpulseoccupancy = 0; starttime = millis(); } }