The GP2Y10 is a fine dust sensor, originally created by Sharp for controlling air cleaners and similiar devices.
The sensor uses a LED emitting light into a tiny dark chamber. Floating fine dust ("aerosol") inside the chamber reflects some light, the reflected light is detected by a photo diode.
Beware: Due to the purpose the sensor is made for it has some limitations. It is not possible to differ between PM1.0, PM2,5 and PM10. As it gives just a summarized analog value it is nearly impossible to really calibrate it to a real " x µg/m³ Dust" value reading. If you need separate values for PM1,0, PM2,5 and PM10 you should consider using a PMSx003 or a SDS-011 for PM2,5 and PM10.
The GP2Y10 gives back an analog value up to 3,4 V. To use analog values you need an ESP8266 with analog input (ESP-07s, ESP-12/12E/12F) or a nodeMCU or WeMOS D1 Mini.
The analog to digital converter of the ESP takes up to 1V! If you use an ESP with bare analog input you need two resistors as voltage divider to cut down the voltage from the sensor to 1V max.
Please note: Some nodeMCU's and the WeMOS D1 Mini have this divider already built in.
A Hint about GP2Y10 on Breakout Boards
There are some breakout boards with pre-mounted GP2Y10 in the market. Some of this boards use a transistor on the board for LED driving. The transistor inverts LED-on and LED-off, this leading to sensor failure.
If you're able to compile your own ESPEasy firmware you may swap "0" and "1" in the GP2Y10 plugin for using these breakout boards.
Set up the circuit as shown in the schematics. According to your ESP-type choose a version with or without voltage divider. The 150 Ohm-resistor and the 220µF capacitor are always necessary for the LED circuit inside the sensor. The sensor will fail without these components
Set up the ESPEasy task according to the screenshot. If you have chosen other GPIO pins set them accordingly. Omit the "Formula" field for now, we'll set it later.
The Device List should now show something like this (Here together with a OLED display and a SI7021 humidity sensor)
As said this sensor is somewhat difficult to calibrate. For an exact calibration it needs a commercial dust meter as a reference. These are rare and very expensive so we will try to give a way for calibrating the sensor approximately.
Please read the wiki basics about calibrating first, it makes things more understandable. [link]
calibrating - Step 1
Sadly the sensor does not give a zero value. Even in really clean air there still is a low output around 0,3...0,5 V. The exact value is individual for your sensor. For the sample sensor used here we found this formula to correct the zero deviation:
%value% - 1940
You may start with this value, entering the formula into the "Formula" field.
So how can you get some clean air? The easiest way is a really rainy day. As you know rain clears the air. Place the sensor at a open window or on a rain safe place outside. Wait some minutes until the sensor settles down. Now log several values by refreshing the tasklist page again and again or logging the values with domoticz, fhem or another home control.
Theoretically the lowest value you see will be zero. As tolerances are individual to every sensor this most likely won't happen.
Search for the lowest value you see in your log and add it to the correction factor of 1940.
You see -92 as lowest value: 1940 + (-92) =1848 You see 47 as lowest value: 1940 + 47 = 1987
Replace the value in the formula with the value you just calculated.
Repeat these steps several times. It needs some patience to get a good zero point.
Calibrating - Step 2
The sensor gives back a voltage which equals a certain dust value. A voltage of 3V equals about 400µg/m³ of dust in the air. The voltage divider cuts down this voltage to about 1/3. Even worse, the analog to digital converter does not measure in exact steps like 0,1V or such. (See "Basics: Analog-to-digital Converter" in the Wiki for further explanation (link]) The formula has to calculate with all these factors.
To get a "as near as possible" real value we have to multiply by a second correction factor.
We found this formula works quite well:
(%value%-1940) * 0,0256
Replace the "1940" with the value you found in step one above!
Always keep in mind: This is only a very approximate calibration!
As the sensors capabilities are limited you won't get a really exact value of "x µg/m³" of dust. Anyways the value you get is more then enough to evaluate the air quality in your room or if you should open the window or start an air cleaner.
It should be mentioned that dust sensors age over time. The calibration should be repeated now and then to reflect this. Expensive laser sensors sometimes do this automatically using their built-in processor. The GP2Y10 lacks such a processor so you have to take care of this.