Introduction: AEROBOT Air Quality Sensor V1.0

This instructable is about making an inexpensive and a highly accurate air quality sensor named AEROBOT. This project shows temperature,relative humidity, PM 2.5 dust density and alerts about the air quality of the surroundings. It uses a DHT11 sensor for temperature and relative humidity, a sharp optical dust sensor for dust density and an ultrasonic sensor to inform users about inaccurate readings due to blocking of the sensor. This project can be made easily and doesn't need any expertise in arduino. The dust sensor is very quick and can read even the slightest contamination in the surroundings. its maximum range is unknown but it usually is ineffective after the dust density goes over 600. But this is far more than the average contamination of 150. The measuring range of temperature is from -10 to 80 degree celsius and that of relative humidity is from 10% to 90%. Therefore this project is highly effective and efficient as a air quality sensor for homes and offices not in the radius of high pollution.

Things you would need:

• 1 Arduino uno/mega
• DHT11 sensor
• Sharp optical dust sensor
• Ultrasonic sensor
• 1 Button
• 3 LEDs (optional)
• 1 buzzer (optional)
• 220 µf capacitor
• 2*220 ohm resistors
• breadboard

you can watch the project in working here

Step 1: Connecting the LCD

Picture of Connecting the LCD

The first thing you need to do before working on the LCD is to check it. For this, do the connections as shown in the 1st diagram. Connect pin 15 on the LCD to Arduino’s 5V pin. Next, connect pin 16 on the LCD to the Arduino’s GND pin. These pins are used to power the LCD’s backlight.

Next, you need to set up the logic for the LCD. To do this, connect pin 1 on the LCD to the Arduino’s GND pin. Then, connect pin 2 on the LCD to the Arduino’s 5V pin. Next, you need to set up the contrast adjusting potentiometer. Take the 10K potentiometer and connect the first terminal to the Arduino’s 5V pin and the second terminal (middle pin) to the LCD’s pin 3 and the third terminal to the Arduino’s GND pin. Next, power up the Arduino. You will notice that the backlight on the LCD turns ON. Also, when you turn the knob on the potentiometer, the character blocks on the LCD turn bright/dim. Check out the picture on below to see what I’m talking about. If your LCD displayed what is shown in the photo below, it means that your LCD is correctly set up! If you were not able to achieve this, double check your connections and your potentiometer. Adjusting the contrast on the LCD

Completing the Connections Now, we need to connect the data lines and other pins that work with the LCD. Check out the connection in the 2nd diagram. Final connections between the Arduino, potentiometer, and LCD

Let’s start with connecting the control wires for the LCD. Connect the LCD’s pin 5 (RW) to the Arduino’s GND pin. This pin is not used, and serves as the Read/Write pin. Next, connect the LCD’s pin 4 (RS) to the Arduino’s digital pin 7. The RS pin is used to tell the LCD whether we are sending it data or commands (to change the position of the cursor). Next, connect the LCD’s pin 6 (EN) to the Arduino’s digital pin 8. EN is the enable pin on the LCD, this is used to tell the LCD that data is ready for reading. Next, we have to connect the four data pins on the LCD. Connect the LCD’s pin 14 (DB7) to the Arduino’s digital pin 12. Then, connect the LCD’s pin 13 (DB6) to the Arduino’s digital pin 11. Next, the LCD’s pin 12 (DB5) to the Arduino’s digital pin 10, then the LCD’s pin no 11 (DB4) to the Arduino’s digital pin 9.

Step 2: Connecting the DHT11 Sensor

Picture of Connecting the DHT11 Sensor

Now connect the DHT11 sensor's input pin to arduino pin 7 and connect the Vcc and the ground wires respectively. Be sure to secure it and place it fare from the bunch of wires connected to the lcd.

Step 3: Connecting the Ultrasonic Sensor

Picture of Connecting the Ultrasonic Sensor

The ultrasonic sensor i added in here is for a precaution so that whenever something is blocking the dust sensor(i would come to that later) the ultrasonic sensor senses it and gives a warning so that the dust sensor does not give improper readings.

Connect the trig pin of the sensor to arduino pin 6 an the echo pin of the sensor to arduino pin 5 and also place this sensor away from all the wires because the sensor is so sensitive that if there's a wire in front of it then it will show you the warning.

Step 4: Setting Up the Dust Sensor

Picture of Setting Up the Dust Sensor

Now comes the most difficult part and the most amazing sensor of this project-the dust sensor. Just set up the dust sensor as shown in diagram 2. and connect the dust pin to arduino pin 2 and the led pin to arduino pin 3 and dont forget to include the capacitor. After setting it up just check the dust values it gives with a real air quality sensor just to be sure.

Step 5: Finishing Up

Picture of Finishing Up

I have added a buzzer so that it beeps when the air quality gets critical. Its just an extra setup, you can also add LEDs if you want to.

Step 6: The Code

Picture of The Code

So here's the code:


int dustPin=2;

int ledPower=3;

int dustVal=0;

int delayTime=280;

int delayTime2=40;

float offTime=9680;

dht DHT;

#define DHT11_PIN 7

#define trigPin 6

#define echoPin 5

int buzzer=3;

const int buttonPin = A0;

int buttonState = 0;

int flag = 0;

// initialize the libuttonPinrary with the numbuttonPiners of the interface pins

LiquidCrystal lcd(13, 8, 9, 10, 11, 12);

void setup() { // set up the LCD's numbuttonPiner of columns and rows:

lcd.begin(16, 2);


pinMode(buttonPin, INPUT);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);



for (int i = 1; i <= 100; i++) {

lcd.setCursor(2, 0);

lcd.print("AEROBOT v1.0");

lcd.setCursor(1, 1);

lcd.print("booting up-");



delay(100); }


lcd.setCursor(1, 0);

lcd.print("AEROBOT is now");

lcd.setCursor(0, 1);

lcd.print("checking the air");




void loop() {







long duration, distance;

digitalWrite(trigPin, LOW);


digitalWrite(trigPin, HIGH);


digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration / 2) / 29.1;

if (distance < 6) {

lcd.setCursor(3, 0);

lcd.print("please move");

lcd.setCursor(5, 1);

lcd.print(" aside");


lcd.clear(); }

else {

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH)

{ ++flag;

delay(500); }

int chk = DHT.read11(DHT11_PIN);

if (buttonState == HIGH && flag%2==1) {




lcd.setCursor(0, 0);





lcd.setCursor(1, 1);







else if (buttonState==HIGH && flag%2==0)

{ lcd.clear();

lcd.setCursor(0, 0);

lcd.print("PM 2.5=");



if (dustVal <= 100)

{ digitalWrite(buzzer,LOW);

lcd.setCursor(0, 1);

lcd.print("YOU ARE SAFE"); }

else if (dustVal <= 200) {


lcd.setCursor(0, 1);

lcd.print("MOPUP SUGGESTED"); }

else if (dustVal <= 300) {


lcd.setCursor(0, 1);

lcd.print("WARNING! CLEANUP"); }

else if (dustVal <= 400) {


lcd.setCursor(0, 1);

lcd.print("STATUS CRITICAL!"); }


lcd.clear(); }

else {

lcd.setCursor(0, 0);








lcd.print("PM 2.5=");




lcd.print(" ug/m^3");

lcd.setCursor(1, 1);









if (dustVal <= 100)

{ lcd.print("NO THREATS FOUND!");

digitalWrite(buzzer,LOW); }

else if (dustVal <= 200) {


digitalWrite(buzzer,LOW); }

else if (dustVal <= 300) {

lcd.print("WARNING! CLEANUP ");

digitalWrite(buzzer,LOW); }

else if (dustVal <= 450) {

lcd.print("!STATUS CRITICAL!");

digitalWrite(buzzer,HIGH); }

delay(500); lcd.scrollDisplayLeft(); }


}//that pretty much explains itself.


Ben jee ub (author)2017-04-16

My Son (11) and me are bilding our First project (yours!). I find it wondrful!
We are almost there ... the LCD is connected ... but I can't find this: "Just set up the dust sensor as shown in diagram 2". I also dont see how you installed the button.
Please help us ... Thx!

sachinv12 (author)Ben jee ub2017-04-20

sry for the late reply but I am not able to get what u r saying,please explain

ArkadiuszO2 (author)sachinv122017-04-20

I think Ben jee ub is asking for the same thing I asked you via PM. Is it possible for you to give us more detailed instructiuon how to connect dust sensor? In other words where do we connect each of the cables from picture in Step 4.

Ben jee ub (author)ArkadiuszO22017-04-20

Indeed ;-)

sachinv12 (author)Ben jee ub2017-04-20

I am not getting the link of the page from where I learnt abt it but I found an instructable close to what I have will automatically understand where to connect the input and output pins according to the code!

sachinv12 (author)sachinv122017-04-20

this instructable will help you (there's a small problem in the share section)

Ben jee ub (author)sachinv122017-04-20

Thanks for the search & thanks for the inspiration ;-)

sachinv12 (author)Ben jee ub2017-04-22

you are welcome and be inspired!

ArkadiuszO2 (author)Ben jee ub2017-04-20

I've got the schematics from sachinv12, you can find them here:

Is this helpfull or do you need 1 to 1 instruction (can do it tommorow).

Ben jee ub (author)ArkadiuszO22017-04-20

Beautiful! thanks for the follow up ;-)

Super proposal for a 1 on 1 but I have to try it myself first. Thank you very much!

I began to think it was because of air the quality ... LOL

selinaguo (author)2017-04-07

That looks so cool! I'm trying to make something like this. I had nearly no clue how to do it before until I saw your wonderful Aerobot! Just wondering if it is possible to connect the output PM value to a motor in this program. For example, if the value exceeds a certain value, the motor starts.. Is there a way to use this PM value sort of like a analog switch? I don't know much about Arduino so please excuse me if this question looks quite obvious. Thank you so much!

ArkadiuszO2 (author)selinaguo2017-04-11

selinaguo i think it can be easily done with relay and simple if in main loop. I do not understand why the author has dustVal <= 450 (i would wrie dustVal >= 450), but as for adding that if:

1. You need to declare relaly on some pin (const int relay1 = 18;)

2. In void setup() add:

pinMode(relay1, OUTPUT);

3. In void loop() add:

if (dustVal >= 450)

digitalWrite(relay1, HIGH);


digitalWrite(relay1, LOW);

This way if dustVal will reach 450 or more relay1 will turn on anything connected to it (you need to have soth like this Keep in mind i'm still learning how to do stuff (beginner here) so correct me if i wrote smth wrong. If you need help with wiring the relay ask, i will help.

selinaguo (author)ArkadiuszO22017-04-20

Wow gosh so sorry for my late reply! That looks feasible! Thank you sooo much for your help!! I'll try it when I get back and if there are any more problems I might still come back for help:) Again thanks a lot!!

sachinv12 (author)ArkadiuszO22017-04-20

than you for your contribution ,this really taught me a good amount

sachinv12 (author)selinaguo2017-04-20

that's a great idea and it can be daily used but I have never worked with relays and connecting motors, this was my first moderately difficult project

sachinv12 (author)sachinv122017-04-20

done easily*

sachinv12 (author)2017-04-01

thank you all for ur wishes! hope to improve next time

T.L.J.S (author)2017-03-21

Good Work. Congrats Sachin

AnisulH (author)2017-03-21

Good work

AbhinavC11 (author)2017-03-20

Congrats and Well Done.
Best of Luxk for Future Endeavours.
Abhinav Chhibber

Kishor_cit (author)2017-03-20

Good work Sachin

pradeepls (author)2017-03-20

Thats awesome Sachin, keep up the good work.

GirishB15 (author)2017-03-20

Great job Sachin...
Keep it up

About This Instructable




More by sachinv12:AEROBOT Air Quality Sensor V1.0
Add instructable to: