eaglestrike66
Published © LGPL

Affordable air quality sensor

A Arduino Air quality sensor using an MQ-135 Sensor and a RGB LED

BeginnerFull instructions provided375
Affordable air quality sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
MQ-135
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Plastic Enclosure, Project Box
Plastic Enclosure, Project Box
Optional
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit

There wasn't a Mq135 in the options so You can look at the bottom of the sensor for the pin names

Code

Untitled file

C/C++
#define sensor    A0 
 const int r = 11;
 const int g =10;
 const int b= 9;
int gasLevel = 0;         
String quality =""; 

void setup() {
  Serial.begin(9600);
  pinMode(sensor,INPUT);
 pinMode(r, OUTPUT) ;
 pinMode( g, OUTPUT);
 pinMode (b, OUTPUT);

}

void setColor(int red, int green, int blue) {

  analogWrite(r, red );
  analogWrite(g, green );
  analogWrite(b, blue );

}

void loop()
{
  gasLevel = analogRead(sensor);

  if(gasLevel<91){
    quality = "  Perfect!";
    setColor(0,0,127);
  }
  else if (gasLevel >91 && gasLevel<115){
    quality = "  Poor!";
    setColor(0,46,63);
  }
  else if (gasLevel >115 && gasLevel<130){
    quality = "Very bad!";
    setColor(0,127,0);
  }  
    else if (gasLevel >130 && gasLevel<150){
    quality = "see ya!";
    setColor(127,30,0);
   
  }
    else if ( gasLevel >150 && gasLevel< 175  0){
    quality = " Eating nuclear waste is better";

    setColor(127,13,0);
    }  
    

    else if (gasLevel<200 ) {
      quality = "Nice knowing you";
      setColor(127,0,0);
    }


  Serial.println("Air Quality:");

  Serial.println(quality); 
  Serial.println(analogRead(0));

  delay(2000);  
}

Credits

eaglestrike66

eaglestrike66

0 projects • 0 followers

Comments