Standalone: Sharp Dust Sensor 66

We based our work on the excellent post over here but contrary to the author, we did not try out multiple sensors and we are using an Arduino Fio.

In this tutorial, we’ll focus on how to get your Sharp Optical Dust Sensor to work and what to watch out for.

In addition, we will try to provide European shop references and prices in € where possible.

Components

  • Arduino Fio (BoxTec) – ~21.57 €
  • FTDI Basic Breakout 3.3V (BoxTec) – ~14.52 €
  • Sharp Optical Dust Sensor (Robotshop) #GP2Y1010AU0F – 10.75 € – Datasheet
  • 6-pin TE 1.5mm pitch connector cable (DigiKey) #A100196-ND – 1.2 €
  • 220 uF Capacitor
  • 150 Ω Resistor
  • Breadboard
  • M/M jumper cables

Setup

Prerequisites

  • Able to upload sketches via the Arduino IDE to your Arduino

In the figure below you can see the overall setup using an Arduino Fio and the Sharp Dust sensor using a classical Breadboard.

Even though you may use an Xbee shield to load your sketches wirelessly, we use a FTDI breakout board here to connect to our PC.

Overview of the Dust Sensor and the Arduino Fio

  1. Hook up the sensor using the 6 pins in the following way (see Figure below):

Pin numbering on the Sensor

Close-up of breadboard with Dust Sensor and Arduino

You may use the following schema from Sharp and our own drawing to help you in the task:

Official schema from Sharp

Fritzing schema of the Setup using an Arduino Fio

Pins Assignments

Sharp Dust Sensor Attached To
1 (V-LED) 3.3V Pin (150 Ohm in between)
2 (LED-GND) GND Pin
3 (LED) Digital Pin 12
4 (S-GND) GND Pin
5 (Vo) Analog Pin A6
6 (Vcc) 3.3V Pin (Direct)

Code

All updated code and schematics can be found on our github dust module project page.

Before launching the code, there are couple of points which are important.

1. How to interpret the output signal

In the figure below taken from the datasheet, you can see that the Dust density grows linearly with respect to the output voltage (Vo).

In line 52 of the code, we implemented the formula of the linear regression that approximatively follows this curve (courtesy of Chris Nafis).

This will allow us to map output voltages to Dust densities in mg/m³.

Linear range of the Sharp sensor

In addition, on an Arduino, any analog pin will map voltages between integer values from 0-1023 which can be mapped back to a “real” voltage value.

For the Fio, we therefore multiply the analog reading by 3.3/1024.0 and for the Uno, you will want to multiply the reading by 5.0/1024.0.

Important: Be sure to add the trailing zero in these calculations, because if you do not put at least one, you will end up with a nasty bug where all your results will be 0. (Hint: integer division in C)

2. Sampling times

According to the datasheet, we need to switch on the internal LED and wait for 280 µs (microsecond) before measuring the output signal and the duration of the whole excitation pulse should be 320 µs.

We therefore pause for another 40 µs before switching off the LED again.

Pulse-driven wave form

Sampling strategy

 For convenienve, we provide a code snippet here:
 /*
 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 = 6;
int ledPower = 12;

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 - 3.3V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (3.3 / 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);
}

Running

This snippet was captured using an Arduino Uno. While the setup works with an Arduino Fio, we noticed that we are not able to reach all the values possible by the dust sensor. Looking at figure 3 above (the voltage / dust density graph) the Fio’s maximum signal was about 2V with a corresponding maximum dust density of .25 mg/m³. This is a tolerable limitation as the ambient air quality is unlikely to get that high unless you work in proximity to high airborne particle generating activities such as construction.

In the snippet below you can see that by using a 5V input, we are able to reach the maximum readings outlined by Sharp (around 3.75V, cf linear curve above) by completely blocking the sensor, eg we inserted a pen to simulate absolute horrific air (very dense). The values around 0.8-1V were our baseline in our office.

Whilst with a 5V input you will reach your max at around 3.75Vo, you will reach the maximum already at around 2.25 Vo with a 3.3V input.

We will try to use a 5V-3V logic converter breakout board on the Fio to see if similar results can be obtained.

The table below was obtained using an Arduino Uno, and as expected we reached full capacity on this device.

Raw Signal Value (0-1023): 170.00 - Voltage:    0.8330 - Dust Density:    0.0416
Raw Signal Value (0-1023): 188.00 - Voltage:    0.9212 - Dust Density:    0.0566
Raw Signal Value (0-1023): 22.00 - Voltage:    0.1078 - Dust Density:   -0.0817
Raw Signal Value (0-1023): 321.00 - Voltage:    1.5729 - Dust Density:    0.1674
Raw Signal Value (0-1023): 767.00 - Voltage:    3.7583 - Dust Density:    0.5389
Raw Signal Value (0-1023): 767.00 - Voltage:    3.7583 - Dust Density:    0.5389
Raw Signal Value (0-1023): 767.00 - Voltage:    3.7583 - Dust Density:    0.5389
Raw Signal Value (0-1023): 772.00 - Voltage:    3.7828 - Dust Density:    0.5431
Raw Signal Value (0-1023): 768.00 - Voltage:    3.7632 - Dust Density:    0.5397
Raw Signal Value (0-1023): 766.00 - Voltage:    3.7534 - Dust Density:    0.5381
Raw Signal Value (0-1023): 767.00 - Voltage:    3.7583 - Dust Density:    0.5389
Raw Signal Value (0-1023): 767.00 - Voltage:    3.7583 - Dust Density:    0.5389
Raw Signal Value (0-1023): 767.00 - Voltage:    3.7583 - Dust Density:    0.5389

The table below is a readout using the 3.3V supply on the Arduino Fio. As you can, when simulating a completely polluted air, by inserting a pen in the hole, we max out at 2.06V which is equivalent to 250 ug/m^3. As mentioned above, we do not foresee to ever reach these kind of values in Luxembourg, so we will consider this to be acceptable. Keep in mind though that if you want to use this sensor with the full range on an Arduino Fio, you will need a DC-DC step-up/step-down converter in order to supply the 5V input.

Raw Signal Value (0-1023): 192.00 - Voltage: 0.62 - Dust Density [ug/m3]: 5.19
Raw Signal Value (0-1023): 204.00 - Voltage: 0.66 - Dust Density [ug/m3]: 11.76
Raw Signal Value (0-1023): 205.00 - Voltage: 0.66 - Dust Density [ug/m3]: 12.31
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 639.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.08
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 639.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.08
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 341.00 - Voltage: 1.10 - Dust Density [ug/m3]: 86.82
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 640.00 - Voltage: 2.06 - Dust Density [ug/m3]: 250.63
Raw Signal Value (0-1023): 192.00 - Voltage: 0.62 - Dust Density [ug/m3]: 5.19
Raw Signal Value (0-1023): 245.00 - Voltage: 0.79 - Dust Density [ug/m3]: 34.22

Conclusion

The sensor seems to be quite sensitive and shows relatively consistent results. We suggest to define some ranges that define your air quality, eg from 0.5V-1V Good, 1V-1.5V Poor etc… but it is up to you to define this scale. We suggest getting a baseline in an as clean as possible environment and simulate the maximum by inserting (carefully) a pen filling the whole hole. With the boundaries you can discreetly map the values in between to your preference.

An annoying part is that we cannot reach the maximum using the 3.3V input on the Arduino Fio and had to use the Arduino Uno to reach what was written in the datasheet. We will update this post once we get our hands on a 3.3V-5V logic converter.

we hope you enjoyed this tutorial!

66 thoughts on “Standalone: Sharp Dust Sensor

  1. Reply Cyrille Dec 2,2012 20:56

    Nicely done. Glad to hear the 5V testing confirmed our 3V3 limitation suspicions.

  2. Reply Luca May 4,2013 22:18

    A good work. I tried it but I continuously receive 0 values, sometimes 10, 17. Not more. Maybe concentrations in the air were low. Have you tested it with cigarettes?

    In any case I have a IMPORTANT QUESTION: I don’t understand why at line 37 of your code, to turn on the LED you set it as LOW (digitalWrite(ledPower,LOW)). The same happen at line 43 where, to power off the LED, you set it as HIGH (digitalWrite(ledPower,HIGH))

    I’m quite new in Arduino, thus can you explain me the aforementioned question?

    Regards,

    Luca

  3. Reply Chris Favreau May 24,2013 13:17

    Luca,

    The LED control pin (pin 3 on the SHARP dust sensor module) is active low. This means that a LOW ( 0V ) value will turn the LED on and a HIGH ( VCC ) value will turn the LED off.

  4. Reply Cyrille May 26,2013 17:34

    Hi Luca,

    I can’t test my code right now as I am in the US but the led should turn on during sensor recording. The led should be on for a quarter second and off for ten. If the opposite occurs then either you are using a different board or our comments are wrong.

    To max out our sensor readings we would put a pencil in the sensor hole. See our high readings in out output logs.

    I will be back in a month to double check.

    Cheers,
    Cyrille

  5. Reply Lisa Jun 8,2013 16:58

    Hi,

    I’m new in this, I want to know for the displaying output data/ results of the sensor, is it on the arduino ide/sketches sw as well? Or did you used any other sw to display the output data and how to display it?

    • Reply admin Jun 16,2013 16:55

      Hi Lisa,

      you want to go to Arduino IDE -> Tools -> Serial Monitor. This will only work once you are successfully connected to the Arduino, and that your code is running. Then it will display in that window.

      Best of luck,

  6. Reply Luca Jun 15,2013 22:41

    Many thanks,
    I tried and all works

    Luca

  7. Reply Cyrille MdC Nov 16,2013 17:11

    Hey,

    Until we create a new poste we need to mention that the dust sensor REQUIRES 5V and does not provide correct readings with the 3.3V from the fio.

    We have spliced on a voltage regulator (http://www.pololu.com/product/2120) into our circuit to provide 5V to the sensor and to the resistor (see circuit figure above).

    We are very happy with the pololu voltage regulator, a little expensive, but it’s overkill due to the other voltages that it can provide.

    Cheers,
    Cyrille

  8. Reply serialc Feb 21,2014 11:57

    I will port the conversation from a github commit to here, where it belongs:

    marcviader commented

    Dear friends,
    first of all, just say many thanks for your project.

    I would like to ask which size of Particles is measuring the sensor? PM2.5? or PM0.5? or others?
    If I am not wrong, the Dust sensors normally read µg/m3 but of some fixed size particles….PM10, PM2.5, PM0.5…so
    those sensors usually measures which concentration of some specific diameter particles. I have built the sensor with my Arduino UNO and it works, but I am interested to measure PM2.5 or PM0.5, so I need to know which ones measures the Sharp sensor when it gives the data in µg/m3.

    Thanks in advance

    Marc

    serialc commented

    Hi Marc,

    The Sharp sensor does not measure particle size. The only measurement is the general amount of dust detected in the air (using an infrared led and phototransistor) converted to ug/m3.

    See the documentation: https://www.sparkfun.com/datasheets/Sensors/gp2y1010au_e.pdf
    Also check out this: http://www.howmuchsnow.com/arduino/airquality/
    He compares what you are looking for, a PM size sensor, with the Sharp sensor.

    Cheers,
    Cyrille

    marcviader commented

    Dear Cyrille,

    Thank You very much for your answer, I have already seen the links you show in your email, so linked with them, if I well understand, when he compares the results between the Sharp and the Dylos with the cake experiment, he reach a formula which links the Sharp measurement with the Dylos measurement. And the most important (I would like to be sure I well understand that point) the Dylos can work with PM2.5 or PM0.5, and he had use the *PM0.5* with the dylos during the cooking experiment, so, the formula which links the Sharp and the Dylos ((V-0.0356)*120000 using Dylos in PM0.5) could be the rule to help to measure PM0.5 with the Sharp just because both graphics ara parallel enough to get that parallelism as good enough to consider that we could use the Sharp measure to get PM0.5 data with the reached formula.

    Do you agree? Is it right what I understand? I am preparing a Paper to be published related to that and I don’t want to be wrong.

    Thank you very much for your help, time and web,
    Marc

  9. Reply serialc Feb 21,2014 12:07

    Hi Marc,

    While this may work in certain cases you are likely to encounter some very erroneous results when larger dust arrives in the Sharp sensor. The Sharp sensor does not distinguish PM size – I assume the Dylos has a filter or some PM size specific measurement technique but don’t know.

    As soon as you get a PM10 particle size in the Sharp sensor and assume you are receiving PM0.5 amounts your readings will be very wrong.

    If this is for research why not invest in the Dylos sensor and do some comparisons of various particle sizes?

    Cheers,
    Cyrille

    • Reply Marc Viader Feb 21,2014 12:36

      ……..but yes, I agree, the best idea is to check different measures of PM with the Dylos in parallel with the sharp at the street and see what happens….comparing results…in order to obtain if there is some useful relation…

      M

  10. Reply Marc Viader Feb 21,2014 12:25

    Dear Cyrille,

    thanks again,

    as you can see at the picture I already have the Dylos
    But If I want to use more than 30 sensors to create a grid, the dylos will be to expensive…
    I would like to create a “cheap” net of sensors….Sharp could be an interesting option..

    Marc

  11. Reply Marc Viader Feb 21,2014 12:26

    I bought the Dylos to calibrate and compare with the Sharp, but my good surprise was that someone did it before me…:-)

  12. Reply Marc Viader Feb 21,2014 12:29

    I want to measure variations of PM levels created by traffic (cars). I have the support of the Government scientific staff and lab. They gave me the opportunity to compare their very expensive PM sensors with my Sharp in order to be aware what is really doing the Sharp or even the Dylos. But they asked me waht the Sharp will measure in order to compare….

    • Reply David Feb 4,2015 05:25

      I am curious what the results of your comparison were…did the inexpensive sensor perform similarly to more expensive ones?

  13. Reply Marc Viader Feb 21,2014 12:31

    The challenge is to know if it is possible to get some useful info from a cheap sensor like the sharp….related to PM2.5 (or smaller) …..scientific have told me that the interesting size of PM related to human health is form PM2.5 to smaller… smaller are, more dangerous are….

  14. Reply Marc Viader Feb 21,2014 12:32

    cheers,
    Marc
    (sorry big message)

  15. Reply Marc Viader Feb 21,2014 12:35

    ……..but yes, I agree, the best idea is to check different measures of PM with the Dylos in parallel with the sharp at the street and see what happens….comparing results…in order to obtain if there is some useful relation…

    M

  16. Pingback: Dust In The Wind | Cloud ACM

  17. Reply kj May 13,2014 00:39

    Another code that was dust calcvoltage= vomeasured*(5.0/1024.0)
    Why it is different??

  18. Reply Javier Jun 1,2014 10:12

    Thank you for this post,

    I have seen that some people mount the sensor with a fan to increase the airflow. Is the measurement affected by the flow?

    J

  19. Reply Russell Grokett Jul 13,2014 20:04

    Just a quick note if you use the GitHub version of the dustSensor.ino code… it uses pin A5 instead of A6 for the analog measurement. Just verify your measurePin = your actual pin.

  20. Reply andre Aug 12,2014 04:51

    hello, i’m working my project with this sensor right now, and run smoothly..

    I just wandering about the hole for sensitivity adjustment of variable resistor, I adjust it with screwdriver to left and right direction and it change the voltage and dust density value

    it is okay to us to adjust it like that?

    • Reply Trefex Sep 16,2014 08:18

      Hey,

      it’s probably fine as long as you can create a new curve so you know which voltage corresponds to which dust amount.

  21. Reply Kevin Oct 30,2014 18:01

    Hello, I’m new here.

    May I know the Sharp Optical Dust Sensor is suitable to be implemented in vacuum cleaner robot to detect the dust on the floor surface?
    And, can you tell me how to get the output graph of this sensor. From Matlab or other software?

    Thank you.
    Kevin

    • Reply Trefex Oct 31,2014 20:15

      Hi Kevin,

      This sensor works by dust moving through the tunnel in the box. This means it’s not suited to detect dust from a distance, and would therefore probably not find regions with more or less dust on the floor. I can’t offer a solution right now, but it sounds actually quite interesting 🙂

      What about graph are you referring to?

      Best,

      • Reply Kevin Nov 1,2014 03:23

        Hi Trefex,

        Thanks for your advice.
        Basically, I want to plot the “Output Voltage vs Dust Density” of this sensor, but the Matlab was shown “Warning: Matching failure in format.”.

  22. Reply Lewis May 2,2015 02:00

    Hi,

    In my room, I tried with the code and hardware connection as guided above and got the result below. Output voltage vs dustdensity seems matched as provided of Sharp GP2Y1010AU0F sensor spec but the result 0.22 with output voltage 1.9 means 220 ug/m3, right ?

    The data sheet tells that output voltage at no dust is from 0V to 1.5V.

    I’m confused, please shed some light on this..

    Raw Signal Value (0-1023): 591.00 – Voltage: 1.90 – Dust Density: 0.22
    Raw Signal Value (0-1023): 604.00 – Voltage: 1.95 – Dust Density: 0.23
    Raw Signal Value (0-1023): 602.00 – Voltage: 1.94 – Dust Density: 0.23
    Raw Signal Value (0-1023): 592.00 – Voltage: 1.91 – Dust Density: 0.22
    Raw Signal Value (0-1023): 605.00 – Voltage: 1.95 – Dust Density: 0.23
    Raw Signal Value (0-1023): 603.00 – Voltage: 1.94 – Dust Density: 0.23
    Raw Signal Value (0-1023): 601.00 – Voltage: 1.94 – Dust Density: 0.23
    Raw Signal Value (0-1023): 605.00 – Voltage: 1.95 – Dust Density: 0.23
    Raw Signal Value (0-1023): 593.00 – Voltage: 1.91 – Dust Density: 0.22
    Raw Signal Value (0-1023): 589.00 – Voltage: 1.90 – Dust Density: 0.22
    Raw Signal Value (0-1023): 596.00 – Voltage: 1.92 – Dust Density: 0.23
    Raw Signal Value (0-1023): 597.00 – Voltage: 1.92 – Dust Density: 0.23
    Raw Signal Value (0-1023): 603.00 – Voltage: 1.94 – Dust Density: 0.23
    Raw Signal Value (0-1023): 595.00 – Voltage: 1.92 – Dust Density: 0.23
    Raw Signal Value (0-1023): 601.00 – Voltage: 1.94 – Dust Density: 0.23

  23. Reply elin Jul 13,2015 02:10

    Hi Trefex,

    I want to collect datas from dust sensor then send those datas to Web via Ethernet.

    Here is my experiment environment
    – Arduino UNO R3
    – Arduino Ethernet Shield 2
    – Sharp Dust Sensor GP2Y1010AU0F
    – 220 uF Capacitor, 150 Ω Resistor, breadboard, some jumper cables

    The dust sensor worked on the Arduino. The Arduino can fetch datas (raw signal values) like what you posted, which ranges from 200~350 in an office room. I can simply as you said to insert a pen in the hole of dust sensor to make the dust density more condense. Datas change from 350.00 to 764.00 while inserting a pen.

    But if I mounted the Arduino with an Ethernet shield. The Arduino got so many zero datas returned from the sensor and some other values were kind of weird (the raw signal value randomly got 18, 47, 35..).

    Any help will be appreciated.

  24. Reply elin Jul 15,2015 02:06

    I figured out that digital pin12 cannot be used to connect the sensor as it is a SPI communication between Arduino and Ethernet shield.

    So I got no problem with above comment, thanks!

  25. Pingback: Sharp GP2Y10 dust sensor - PocketMagic

  26. Reply Dale Nov 13,2015 09:17

    Hello.
    I have wired everything to your specs and have it on a nano clone and my results dont vary much at all off 1.35v even with smoke induced at 5.0v and with the latest code it has *100 after calcVoltage – 0.1?
    Any suggestions??

  27. Reply Takuya Jan 7,2016 01:32

    このプログラムはRxマイコンでも使えますか?

  28. Pingback: Sharp GP2Y1010 dust sensor - PocketMagic

  29. Reply Tachanka W May 23,2016 02:28

    Can you use Arduino Uno for this?

  30. Reply Kermit Jun 11,2016 21:13

    For whatever reason my sensor seems to be outputting the same data after initial bootup, and the numbers seem much lower than others im finding. I get that .12-ish reading infinitely, regardless of what i insert into the hole, or if I introduce airflow. I’m using a Mega with 5V. Any recommendations?

    Raw Signal Value (0-1023): 411.00 – Voltage: 2.01 – Dust Density: 0.24
    Raw Signal Value (0-1023): 315.00 – Voltage: 1.54 – Dust Density: 0.16
    Raw Signal Value (0-1023): 278.00 – Voltage: 1.36 – Dust Density: 0.13
    Raw Signal Value (0-1023): 268.00 – Voltage: 1.31 – Dust Density: 0.12
    Raw Signal Value (0-1023): 264.00 – Voltage: 1.29 – Dust Density: 0.12

  31. Reply Lucas Santana Jun 17,2016 22:23
    • Reply Lucas Santana Jun 17,2016 22:25

      Sorry about the mess with the comment! I will post the code again here

      #include "TimerOne.h"

      void callback(){
      /* Timing for Dust LED sensing */
      digitalWrite(DUST_LED, DUST_ON);
      delayMicroseconds(280); //sensing time for the dust sensor
      dust = analogRead(DUST_SENSOR);
      delayMicroseconds(40); //ending time for dust sensor pulse
      digitalWrite(DUST_LED, DUST_OFF); //turning OFF dust sensor LED
      }

      void setup(){
      Serial.begin(9600);
      pinMode(DUST_LED,OUTPUT);
      digitalWrite(DUST_LED, DUST_OFF);
      Timer1.initialize(10000); //Setting interrupt every 10ms
      Timer1.attachInterrupt(callback); //Callback funtion for time interrupt
      }

      void main(){
      //your code here
      }

      • Reply AndyM Nov 25,2016 01:54

        That doesn’t work as you think it might. AnalogRead(); takes at least 104us so this gives a pulse width nearer .45ms rather than .32ms

  32. Reply Lin Aug 16,2016 14:03

    I don’t know why the value hasn’t changed forever

  33. Reply Raphael Aug 30,2016 09:03

    Hey there,

    Thanks for this great post!
    I was wondering if you finally managed to test the sensor with the fio and a logic converter! I’d love to hear about that.

    Cheers,
    Raphael

  34. Reply Elvic Sep 21,2016 00:08

    delayMicroseconds(40); is not needed

    Because analogRead(DUST_SENSOR) is slow operation that takes itself about 100 microseconds.

    So, whole sampling pulse could be more than 140

    • Reply AndyM Sep 21,2016 16:59

      Elric,

      It’s worse than that, as you can’t actually get the right timing if you use analogRead(). As you say this takes 104uS so if it starts at 280uS then you can’t turn the LED off until at least 384uS when the spec sheet says 320uS. I’ve checked it with a ‘scope and it’s closer to 450uS pulse width, which distorts the output pulse. I’m writing a post that explains more, with screen shots from the scope and code to fix it. Will post a link in the next few days.

  35. Reply David McLaughlin Sep 22,2016 03:33

    You don’t need a voltage level converter to use with a 3.3V ADC input. Just use a simple resister based potential divider and then scale your input back to 5.0V in the code. For example, a series value of 56K for R1 and 100K for R2 would give you 3.205V with 5.0V input. If you have a nice stable variable power supply you can calibrate this nicely. 🙂

    Should be more than accurate enough.

  36. Reply Werk_AG Oct 28,2016 22:49

    It’s worse than that, as you can’t actually get the right timing if you use analogRead(). As you say this takes 104uS so if it starts at 280uS then you can’t turn the LED off until at least 384uS when the spec sheet says 320uS. I’ve checked it with a ‘scope and it’s closer to 450uS pulse width, which distorts the output pulse

    AndyM, you are absolutely right. The worst is that I see the same error replicated on almost every code supposed to be used with this dust sensor. Without doing anything else, each analogRead takes around 100us. To use the published code we need to play with the ADC prescaler to get an analogRead as lower as 20us to 30us, otherwise the readings are done outside of the specs.

  37. Reply John Nov 1,2016 19:08

    Great writing but I’m a little concerned about the “block the hole” method.
    This sensor measures the reflection of the particles inside the sensor. If there are no particles there is reflection (only a little).
    If there are particles there is reflection. This sensor most likely calibrated to the reflection factor of the usual particles in the air.
    If you put something unusual into the hole how can you be sure if the sensor is saturated or not? What will happen if the object you put into the hole is white or black, glossy or matte?

    As there is no actual exact data to convert the output voltage of the sensor to dust concentration this sensor won’t be able to serve info about the air pollution anything more than informative unless it is calibrated to something precise instrument.

  38. Reply Vinay Nov 7,2016 07:58

    Hi,
    Very nice tutorial, I have one doubt about the position of the sensor. Is it okay if sensor is kept in vertical or horizontal position? As in case of PPD42NJ only vertical position of the sensor is recommended, likewise is there any constraint for Sharp dust sensor?

    Thanks in advance.

  39. Reply hadeel Dec 25,2016 16:18

    I need help
    i am using shrap dust sensor but the readings does not change

  40. Pingback: Capteur de poussières et Micropython (Partie 1) – LAurent_B'log(s)

  41. Reply Olaf Jan 17,2017 10:45

    Interesting project.
    I would like to monitor the particles indoor in living room, kitchen, bedrooms. No-smoking house.
    Would that sensor work? I fear that in the kitchen the oil particles (always present due to cooking steaks, or sometimes frying, even if very light) would stick and reduce effectiveness.
    I also read that cleaning that sensor is not straightforward/recommended.

    • Reply AndyM Jan 26,2017 00:11

      Best way to clean the sensor is probably with a blast of air to dislodge the dust. That might not work with sticky dust but I think you could write code that corrects for this to some extent by recording the minimum ever reading and using this to adjust the offset of the voltage to ppm conversion. One of the Sharp data sheets recommends doing this anyway, to account for reduced LED output through the life of the device.

  42. Reply sandeep Feb 8,2017 03:10

    can i use GP2Y1010AU0F sensor instead of PM2.5/PM10 SDS011 sensor
    if not could you recomend the compitable one

  43. Reply Ali Mar 23,2017 07:27

    Hii i am new I want programme for both interface of LCD with Arduino.And With dust sensor can any of you help me please

  44. Reply degeus Jul 1,2017 21:13

    Thanks for this write-up. That made it a breeze to set things up. (On a Nano, with the same code).

  45. Reply Melanie Keil Jul 18,2017 01:03

    Hello
    I set the dust sensor correctly for analog output, and found the read out on serial monitor, but I would love to hook it to led lights via breadboard so the out put could be visualized better for a youth air quality ed. program on a Native American Reservation. My goal is something like this EPA DIY particle sensor described in following link:

    sensorhttps://www3.epa.gov/airnow/teachers/gh_pmsensorkit_handoutandinstructions.pdf

    If anyone with more experience might be willing to help with the wiring schematics/ code I would be very grateful!

  46. Pingback: Station de mesure – Les capteurs – phmarduino

  47. Reply Pete Aug 5,2017 14:43

    I’ve set up the system with Arduino Nano and it seems to work good. Thanks for all information. Now the question 🙂 My readings are offset by approximately 70 (calculated value). The “noise” is about from -70 to -20. Then I get occasional readings in higher range (100-150). Arduino outputs data every second but I log it every 10 seconds (skipping 9 reads).
    Shall I change the equation to correct for the offset? Negative concentration is probably not reasonable. The air is quite clean right now I think. Does anyone have a logger (PC, RPi) to log the raw data?
    Thanks!

  48. Reply esraa Aug 13,2017 22:19

    what is meaning from dust density????

Leave a Reply