Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino-based automatic car windows for protection from dust and pollution

By Nikhil Agnihotri March 2, 2021

Cities are getting overpopulated and much polluted day by day. Pollution is a major problem in urban areas, be it developed countries or developing ones. Countries like India are projected to increase their urban population from 30% to 50% by the next decade. The increase in population in cities is coetaneous with an 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. Automobiles are nowadays loaded with various features, and protection from dust and pollution can be one of them. This can be a handy feature in countries like India and China.

This project has tried 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 sense the air’s dust density, while the MQ-135 is used to sense the air quality. If the air’s dust level is greater than a threshold or the pollution level is greater, the microcontroller (Arduino in this case) automatically actuates the car windows. The actuation of car windows is shown here by driving a DC motor. This is a simple prototype for this feature addition. A commercial implementation may use an automotive microcontroller interfaced with similar sensors.

Components required

  1. Arduino UNO x1
  2. GP2Y1010AU0F optical dust sensor x1
  3. Resistor 150Ω x1
  4. MQ-135 Air Quality Sensor x1
  5. L293D x1
  6. DC Motor x1
  7. 9V Battery x1
  8. Breadboard x1
  9. Connecting Wires/Jumper Wires

Circuit connections

For measurement of air quality, the MQ-135 sensor needs to be pre-heat in clean air. After preheating for 24 hours, the value of R0 can be determined. MQ-135 air quality sensor has four pins – VCC, GND, Dout, and Aout. For preheating the sensor, connect VCC to Arduino’s 5V output, GND to Arduino’s ground pin, and Aout to an Arduino analog input pin, like A4 in this project. Load the Arduino Sketch-1 to the board and leave it for 24 hours. Then, check the value of R0 from the serial monitor and disassemble the circuit.

It should be noted that according to the datasheet of the MQ-135 sensor, the recommended load resistance for MQ-135 ranges from 10KΩ to 47KΩ. Many MQ-135 sensor modules come with the wrong load resistance assembled on their board. Trace the PCB connections for load resistance and if it is smaller than 10 KΩ, replace it with 22KΩ one. After getting the R0 value for the MQ-135 sensor, it can be used in the project circuit. The dust sensor we can use directly in the project’s circuit.

We need to load Arduino Sketch-2 to Arduino and interface GP2Y1010AU0F optical dust sensor, MQ-135 air quality sensor, and DC motor for assembling the project’s circuit with Arduino UNO. Extend the 5V output and Ground connections from Arduino UNO to a breadboard. For interfacing, the MQ-135 air quality sensor connects its VCC pin to Arduino’s 5V Out, GND pin to Arduino’s ground, and Aout pin to Arduino’s analog input pin A4, respectively.

The GP2Y1010AU0F optical dust sensor has a six-pin connector with the following pin configuration.

For interfacing 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 Arduino’s GND making it a common ground between the Arduino and the L293D motor driver IC.

Arduino Sketch 1

Arduino Sketch 2

How it works

This circuit detects the air quality and dust density of the surrounding air and, according to measured values, actuate a car’s windows. To show the actuation of the car’s window, a DC motor is driven in the circuit. For measuring air quality, the MQ-135 sensor is used. The sensor is preheated for 24 hours to obtain the R0 value. The header file uses the value of R0 in the MQ-135 library. Once the actual R0 value is obtained, it is 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 concentration of CO2 in the air. The sensor is connected to Arduino’s A4 pin. The concentration of CO2 in the air is obtained using the getPPM() function of the MQ135 library. If the concentration of CO2 is greater than 700 PPM, the car’s windows are closed by actuating the motor.

Simultaneously, the dust density is also measured by the circuit. Sharp’s GP2Y1010AU0F optical dust sensor helps detect fine particles like cigarette smoke and dust particles in the air. It consists of an IR diode and a photosensor that is assembled diagonally across an air inlet. When air containing dust particles enters the inlet, the dust particles scatter the IR radiations from the diode towards the photosensor. Greater is the dust density. More IR light is scattered, greater is the output voltage of the photosensor. The GP2Y1010AU0F sensor can detect dust particles as small as 0.5um and dust density up to 0.580 mg/m3. If the dust density is greater than 0.4, the car’s windows are closed by actuating the motor.

The Arduino is programmed to measure dust levels and concentrations of CO2 in the surrounding air. If either CO2 concentration is greater than 700 PPM or dust level is greater than 0.4 mg/m3, the Arduino drives the motor via L293D motor driver IC, and the windows are closed.

The code

For preheating the MQ-135 sensor, Arduino Sketch-1 is used. The sketch begins with importing the MQ135 library. In the setup() function, the baud rate for serial communication with Serial Monitor is set to 9600 bps. In the loop() function, analog reading from the MQ-135 sensor is read from pin A4, and the value of R0 is obtained using the getRZero() method. The obtained value is printed to the Serial Monitor. The value is observed after preheating the sensor for 24 hours in clean air. This value is obtained to be 929.15 for a load resistance of 22K. The values of load resistance and R0 are changed in the header file.

The Arduino Sketch-2 is loaded to the Arduino UNO for it working as the actual circuit. The sketch begins by importing the MQ-135 sensor library. This library can be downloaded as a Zip file from the above-mentioned link and imported by navigating to Sketch-> Include Library -> add .Zip library.

Next, the pins are assigned to connections with L293D Motor Driver IC. This is followed by pin connections to the dust sensor and declaration of variables to store calculations and value of dust level. Then, an object of the MQ135 library is instantiated, pins are assigned to connections with the MQ-135 sensor, and a variable to store the value of CO2 concentration is declared.

In the setup() function, the baud rate for serial communication with Arduino IDE’s Serial Monitor is set to 9600. This will be useful in monitoring CO2 concentration and dust level. The pins connected to L293D’s Enable A, Input 1, and Input 2 pins are set as a digital output. The DC motor is stopped, by default, by writing the LOW signal to Input 1 and Input 2 of L293D. The MQ135 sensor pin is set as input, and the pin connecting to the LED dust sensor is set as output.

A function drive_window() 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 both Input 1 and Input 2 of L293D.

In the loop() function, first of all, dust level is calculated. The IR diode is turned ON for 280 microseconds for measuring dust level, and the output voltage from the photosensor is read. The process of reading output voltage from the dust sensor takes around 40 to 50 microseconds, so a delay of 40 microseconds is provided. According to the datasheet of GP2Y1010AU0F, the IR diode is pulsed every 10 milliseconds, so still, 9.68 milliseconds are left. The dust level is calculated using the following equations and printed to the Serial Monitor.

calcVoltage = voMeasured*(5.0/1024);
dustDensity = 0.17*calcVoltage-0.1;

Then, the analog reading from the MQ-135 sensor is obtained, and the value of CO2 concentration in PPM is calculated. If the CO2 concentration is greater than 700 PPM or dust level is greater than 0.4 mg/m3, the drive_motor() function is called.

Result

OLYMPUS DIGITAL CAMERA

OLYMPUS DIGITAL CAMERA

 

 

You may also like:


  • What are the top tools for developing embedded software?

  • What is the Modbus protocol and how does it work?

  • EMG-controlled wheelchair with Arduino

  • Arduino color sensor used in hospitals

  • Biometric sensor with Arduino

  • Interfacing Raspberry Pi with Arduino

Filed Under: Electronic Projects, Tutorials

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions.

  • Power amplifier stability
  • can we acheive a goal close to output which matches the Marki tool output
  • Problems with LVS of IO pads
  • Create Voltage Report in HFSS
  • Persistent Shoot-Through vin=vout in Synchronous Buck Converter – Physical Phenomenon Issue

RSS Electro-Tech-Online.com Discussions

  • Unknown, to me, electric motor fitting
  • Can a small solar panel safely trickle-charge old NiMH AA batteries?
  • KiCad custom symbol definition correct approach
  • Measuring controller current output with a meter
  • restarting this Christmas project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Posifa sensors improve low-flow accuracy in compact systems
  • Acopian releases low-profile power supplies rated to 900 W
  • Octavo Systems OSDZU-3 REF Development Platform
  • Same Sky adds enclosure design to its audio engineering capabilities
  • Waterproof SMA-to-MHF I LK assemblies introduced by Amphenol RF

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe