Cities are becoming overpopulated and heavily polluted every day. Pollution is a major problem in urban areas, whether in developed or developing countries. Countries like India are expected to increase their urban population from 30% to 50% in the next decade. The increase in population in cities is concomitant with the increase in vehicles and the increase in pollution. Considering the emerging problem of pollution and dust, car manufacturers can add a smart feature to their models. Cars these days are packed with a variety of features, and protection against dust and pollution could be one of them. This can be a useful feature in countries like India and China.
This project attempted to model this feature using the popular prototyping board – the Arduino. In this Arduino project, the GP2Y1010AU0F optical dust sensor and MQ-135 air quality sensors are interfaced with the Arduino. The dust sensor is used to detect the dust density of the air, while the MQ-135 is used to detect the air quality. If the dust level in the air exceeds a threshold or the pollution level is higher, the microcontroller (in this case, Arduino) automatically activates the car windows. The actuation of the car windows is shown here by driving a DC motor. This is a simple prototype for this feature addition. A commercial implementation might use an automotive microcontroller interfaced with similar sensors.
Required components
- Arduino UNO x1
- Optical dust sensor GP2Y1010AU0F x1
- Resistance 150Ω x1
- Air Quality Sensor MQ-135 x1
- L293D x1
- DC motor x1
- 9V battery x1
- Breadboard x1
- Connection wires/jumper wires
Circuit Connections
For air quality measurement, the MQ-135 sensor needs to be preheated in clean air. After preheating for 24 hours, the value of R 0 can be determined. The MQ-135 air quality sensor has four pins – VCC, GND, Dout and Aout. To preheat the sensor, connect VCC to the Arduino's 5V output, GND to the Arduino's ground pin, and Aout to an Arduino's analog input pin, such as A4 in this project. Load the Arduino Sketch-1 onto the board and leave it for 24 hours. Then check the R 0 value of the serial monitor and disassemble the circuit.
It should be noted that according to the MQ-135 sensor technical sheet, the recommended load resistance for the MQ-135 varies from 10KΩ to 47KΩ. Many MQ-135 sensor modules come with the wrong load resistor mounted on their board. Check the PCB connections for load resistance and if it is less than 10 KΩ, replace it with a 22 KΩ one. After obtaining the R 0 value for the MQ-135 sensor, it can be used in the project circuit. We can use the dust sensor directly in the project circuit.

We need to load the Arduino Sketch-2 into the Arduino and interface the GP2Y1010AU0F optical dust sensor, MQ-135 air quality sensor and DC motor to assemble the project circuit with the Arduino UNO. Extend the 5V output and ground connections from the Arduino UNO to a breadboard. For interfacing, the MQ-135 air quality sensor connects its VCC pin to the Arduino's 5V output, the GND pin to the Arduino's ground, and the Aout pin to the Arduino's A4 analog input pin, respectively.
The GP2Y1010AU0F optical dust sensor has a six-pin connector with the following pin configuration.
To interface the GP2Y1010AU0F optical dust sensor with Arduino UNO, make the connections summarized in the table below. 
A DC motor connects the L293D motor driver IC for interfacing, as summarized in the table below.

The above connections connect the negative terminal of the 9-12V battery with the GND of the Arduino, making it a common ground between the Arduino and the L293D motor driver IC.
Arduino 1 Sketch
Arduino 2 Sketch
How it works
This circuit detects the air quality and dust density of the surrounding air and, according to the measured values, operates the car's windows. To show the operation of the car window, a DC motor is activated in the circuit. To measure air quality, the MQ-135 sensor is used. The sensor is preheated for 24 hours to obtain the R 0 value. The header file uses the R0 value in the MQ-135 library. Once the actual R 0 is obtained, it will be replaced with the default values in the MQ135.h file. The MQ135 library can be downloaded from this link.
With a load resistance of 22KΩ, the MQ-135 sensor can measure the CO 2 concentration in the air. The sensor is connected to Arduino pin A4. The CO 2 concentration in the air is obtained using the getPPM function from the MQ135 library. If the CO 2 concentration is greater than 700 PPM, the car windows are closed by starting the engine.

Simultaneously, the dust density is also measured by the circuit. Sharp's GP2Y1010AU0F optical dust sensor helps detect fine particles such as cigarette smoke and dust particles in the air. It consists of an IR diode and a photosensor mounted diagonally in an air inlet. When air containing dust particles enters the inlet, the dust particles scatter infrared radiations from the diode toward the photosensor. The greater the density of the dust. The more infrared light is scattered, the higher the photosensor's output voltage. The GP2Y1010AU0F sensor can detect dust particles as small as 0.5um and dust density up to 0.580 mg/m 3 . If the dust density is greater than 0.4, the car windows are closed by starting the engine.
The Arduino is programmed to measure dust levels and CO 2 concentrations in the surrounding air. If CO 2 concentration is more than 700 PPM or the dust level is more than 0.4 mg/m 3 the Arduino drives the motor through the L293D motor driver IC and the windows are closed.
The code
To preheat the MQ-135 sensor, Arduino Sketch-1 is used. The sketch starts with importing the MQ135 library. In the setup function, the baud rate for serial communication with the Serial Monitor is set to 9600 bps. In the loop function, the analog reading from the MQ-135 sensor is read at pin A4 and the value of R0 is obtained using the getRZero method. The value obtained is printed on the Serial Monitor. The value is observed after preheating the sensor for 24 hours in clean air. This value is obtained as 929.15 for a load resistance of 22K. The load resistance and R 0 values are changed in the header file.
The Arduino Sketch-2 is loaded into the Arduino UNO to function as the real circuit. The sketch begins by importing the MQ-135 sensor library. This library can be downloaded as a Zip file from the link mentioned above and imported by navigating to Sketch->Add Library ->add .Zip library.
Then the pins are assigned to the connections to the L293D motor driver IC. This is followed by pin connections to the dust sensor and declaring variables to store dust level calculations and values. Next, an object from the MQ135 library is instantiated, pins are assigned to connections with the MQ-135 sensor and a variable to store the CO 2 concentration value is declared.
In the setup function, the baud rate for serial communication with the Arduino IDE's Serial Monitor is set to 9600. This will be useful in monitoring the CO2 concentration and dust level. The pins connected to the Enable A, Input 1, and Input 2 pins of the L293D are defined as a digital output. The DC motor is stopped, by default, writing the LOW signal to Input 1 and Input 2 of the L293D. The MQ135 sensor pin is defined as input and the pin that connects to the LED dust sensor is defined as output.
A drive_window function is declared, in which the DC motor is rotated to close the window for a short period of time. Then the DC motor is stopped by writing a LOW signal to input 1 and input 2 of the L293D.
In the loop function, firstly the dust level is calculated. The IR diode is turned on for 280 microseconds to measure the dust level and the photosensor output voltage is read. The process of reading the dust sensor output voltage takes about 40 to 50 microseconds, so a delay of 40 microseconds is provided. According to the GP2Y1010AU0F datasheet, the IR diode is pulsed every 10 milliseconds, so there are still 9.68 milliseconds left. The dust level is calculated using the following equations and printed on the Serial Monitor.
calcTension = voMessed*(5.0/1024);
dust density = 0.17*calcVoltage-0.1;
Then, the analog reading from the MQ-135 sensor is obtained and the value of CO 2 concentration in PPM is calculated. If the CO 2 concentration is greater than 700 PPM or the dust level is greater than 0.4 mg/m 3 the drive_motor function is called.
Result
OLYMPUS DIGITAL CAMERA
OLYMPUS DIGITAL CAMERA