Pages

Monday, August 19, 2013

An optical dust meter that uses the GP2Y1010AU0F sensor library made with AVR Atmega

This project is a dust detector that use the GP2Y1010AU0F sensor.
Attached you can also find the GP2Y1010AU0F sensor library for AVR Atmega.



GP2Y1010AU0F is a dust sensor by optical sensing system. An infrared emitting diode (IRED) and an phototransistor are diagonally arranged into this device. It detects the reflected light of dust in air. Especially, it is effective to detect very fine particle like the cigarette smoke.


Unfortunately the datasheet does not tell anything about the particle size detected, it just tell us that this sensor is for fine particle like cigarette smoke, that is to say about 0.5micron.

This sensor output a pulse-driven wave form that we can read using the ADC of our microcontroller to convert it to usefull data.
Looking at the figure 2 of the GP2Y1010AU0F datasheet we can derive the method to convert the output data.
Note that the sample time should be 280us to perform the correct reading, and this delay should consider that ADC conversion takes 13 ADC clock cycles, so ADCtime(s) = (1/ADCclock)*13 = (1/FCPU/ADCprescaler)*13.
So to perform reading at correct time we have to subtract the time taken by ADC convertion to the suggested time.
As example lets consider a micro running at 8Mhz, with ADC prescaler set to 64
(1/(8000000/64))*13 = 0.000104s = 104us
280us - 104us = 176us
we have to delay 176us and then we can read the sensor output voltage.
Once we have obtained the sampling voltage, we can convert it to mg/m^3 using the fig 3 of the GP2Y1010AU0F datasheet, that shows the dust density (mg/m^3) related to output voltage of the sensor (V).
Chris Nafis does some interesting consideration on this sensor in his Air Quality Monitoring page. Also he does linear interpolation and find the graph obtained the slope and the base for the convertion function.




Code

Notes
  • read risk disclaimer
  • excuse my bad english

23 comments:

  1. Hello Davide, cool job! My name is Trent. I am installing the same sensor for my project. I have no idea where 'LED' terminal goes (I cannot find it in the manual). My project kinda stuck at the stage. Can you please tell me what is 'PB0-ICP' and where it goes? Thank you :)

    ReplyDelete
    Replies
    1. hello,
      look at the image posted above (the one with the sensor with numbers on plug, you can see pin from 1 to 6)
      then look at the schmatics image, you can find the same pin numbers for wiring it to sensor. so PB0 goest to pin3 of sensor.

      Delete
  2. Hey there. I want to buy this sensor but I have some questions and I was wondering if you could help me. First of all I would like to know what is the lowest sensitivity this sensor has. Is it some ugr/m3 or is it mgr/m3?
    Secondly, I saw that you are measuring ugr/m3!!! Is this measurement real???Can this sensor measure this low? How did you calibrated it?

    It would be great if you could answer me these things above.

    Kind regards,
    Tony

    ReplyDelete
    Replies
    1. hello,
      in sensor datasheet, you should find a "Output Voltage vs. Dust Density" figure, you can use this to estimate mg/m^3.
      If you want to calibrate this sensor (or any sensor) you must have a calibrated information too, then correlate the information you get from the sensor you would like to calibrate with the calibrated data, Chris Nafis does this consideration, read his article.
      Datasheet does not states nothing about the lowest sensitivity, it just tell us "Output voltage at no dust", you should correlate this with "Output Voltage vs. Dust Density" figure to obtain the lowest sensitivity, unfortunatelly they tell us voltage at no dust can vary from 0v to 1.5v, that is to say from 0mg/m^3 to ~1.6mg/m^3.

      Delete
    2. And how did you calibrated it?

      Delete
    3. no, unfortunatelly i does not have any calibration source, any calibrated dust meter.

      Delete
    4. Ok. One last question. How much off from reality would you be assuming that you are using the datasheet that shows that Output Voltage vs. Dust Density graph to get some measurements?

      Delete
    5. having nothing to refer to, i do not know, Chris show us this sensor does pretty good metering, but you can not expect this to be precise more than +-10ug/m^3, imho.

      Delete
    6. Thank you very much.
      You can check my blog http://hedproject.wordpress.com/
      I'll come back with an air quality project too.

      Thanx again
      Tony

      Delete
  3. hello mr.davide, can i ask sourcecode for basic compiler.?

    ReplyDelete
    Replies
    1. hello, my code it's for avrgcc compiler, but you can easly rewrite it for a basic compiler.

      Delete
  4. Hello Davide Sir,
    Kindly let me know how to test that value coming on LCD is right and sensor is working fine without using a fan???
    Thanks !!!!

    ReplyDelete
    Replies
    1. Hello, you have to test against a calibrated device. You can also search for your local area PM value, which maybe some state entity release for free.
      It is better to use a fan to get vehiculated air, but the sensor even work without it.

      Delete
  5. Hi. Where can I find the eagle library for this dust sensor?

    ReplyDelete
    Replies
    1. Hello, I've just use a pin header, haven't found any eagle library.

      Delete
  6. Salve,
    per un progetto scolastico sto usando questo sensore con Arduino.
    Sono partito da uno sketch che si trova in rete, sto utilizzando il sensore in montagna all'esterno e in uscita ho dei valori che mi sembrano elevati (80/90 μg/cm^3).
    I valori che escono da questo sensore si riferiscono a quale tipo, PM10,PM 2.5 o altro??

    Daniele

    ReplyDelete
    Replies
    1. Ciao, purtroppo il datasheet non specifica l'intervallo di valore letto da questo sensore. Tuttavia, la correlazione eseguita da Chris Nafis sembrerebbe dimostrare che questo sensore le lettura sono correlabili a quelle seguite con un Dylos DC1100 Pro impostato in Small Count Reading, ossia > 0.5 micron (ref. http://www.howmuchsnow.com/arduino/airquality/)

      Delete
  7. hello,I just want to know if I will be able to interface the dust sensor with atmega128 or atmega16u2..which is better?

    ReplyDelete
    Replies
    1. Hello, both are the same. ATmega family is pretty similar, you can port code easly.

      Delete
  8. I can't solve this: #error "no definitions available for this AVR"

    ReplyDelete
    Replies
    1. Hello, you are using a not supported AVR. It may be supported but not tested or listed. You have to try and check where and if register changes by the one used in the library.

      Delete