User Tools

Site Tools


amc2021:groupl:code:carbon_dioxide_measuring

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
amc2021:groupl:code:carbon_dioxide_measuring [2021/09/05 05:08] kshama001amc2021:groupl:code:carbon_dioxide_measuring [2023/01/05 14:38] (current) – external edit 127.0.0.1
Line 9: Line 9:
 <file c++ CO2Sensor.ino> <file c++ CO2Sensor.ino>
                                                              
-#include "MQ135.h"+#include "MQ135.h" //Main library that contains functions to get the ppm values
 #include <Wire.h>  #include <Wire.h> 
 #include <LiquidCrystal_I2C.h>  //Header file for LCD #include <LiquidCrystal_I2C.h>  //Header file for LCD
Line 15: Line 15:
 LiquidCrystal_I2C lcd(0x27,16,2);//set the LCD address to x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27,16,2);//set the LCD address to x27 for a 16 chars and 2 line display
  
-#define led          9                       //led on pin 9 +#define led          9                  //led on pin 9 
-const int gas_pin = A0;                      //analog feed from MQ135 +const int gas_pin = A0;                 //analog feed from MQ135 
-MQ135 gasSensor = MQ135(gas_pin);+MQ135 gasSensor = MQ135(gas_pin);       //Define the gas pin in the function mq135 gas sensor as per the mq135 library 
  
 void setup(){ void setup(){
  
   lcd.init();                      // initialize the lcd    lcd.init();                      // initialize the lcd 
-  lcd.begin(16,2);                  // consider 16 chars + 2 lines lcd+  lcd.begin(16,2);                 // consider 16 chars + 2 lines lcd
   lcd.backlight();                 // illuminate to produce visible reading   lcd.backlight();                 // illuminate to produce visible reading
   lcd.clear();                     // clear lcd   lcd.clear();                     // clear lcd
   lcd.setCursor(4,0);              //set cursor of lcd to 1st row and 5th column   lcd.setCursor(4,0);              //set cursor of lcd to 1st row and 5th column
-  lcd.print("Group L");          // print as a sentence on lcd+  lcd.print("Group L");            // print as a sentence on lcd
  
   pinMode(gas_pin,INPUT);     //MQ135 analog feed set for input   pinMode(gas_pin,INPUT);     //MQ135 analog feed set for input
Line 35: Line 35:
  
 void loop(){ void loop(){
- float ppm = gasSensor.getPPM();+ float ppm = gasSensor.getPPM(); //function to get ppm value based on the MQ135.h library
  Serial.println(ppm);            // print ppm on serial monitor  Serial.println(ppm);            // print ppm on serial monitor
  delay(1000);                      delay(1000);                    
    lcd.clear();                  // clear lcd    lcd.clear();                  // clear lcd
-   lcd.setCursor(0,0);          // set cursor of lcd to 1st row and 1st column +   lcd.setCursor(0,0);           // set cursor of lcd to 1st row and 1st column 
-   lcd.print("Air Quality: ");  // print as a sentence on lcd +   lcd.print("Air Quality: ");   // print as a sentence on lcd 
-   lcd.print(ppm);             // print value of MQ135 +   lcd.print(ppm);               // print value of MQ135 
- if(ppm>999){                  //if co2 ppm > 1000 + if(ppm>999){                    //if co2 ppm > 1000 
-    digitalWrite(led,HIGH);    //turn on led +    digitalWrite(led,HIGH);      //turn on led 
-    lcd.setCursor(2,1);        // set cursor of lcd to 2nd row and 3rd column +    lcd.setCursor(2,1);          // set cursor of lcd to 2nd row and 3rd column 
-    lcd.print("AQ Level BAD");  //print as a sentence on lcd+    lcd.print("AQ Level BAD");   //print as a sentence on lcd
    }    }
  else{                else{              
-    digitalWrite(led,LOW);         //turn off led +    digitalWrite(led,LOW);       //turn off led 
-    lcd.setCursor(1,1);            // set cursor of lcd to 2nd row and 2nd column +    lcd.setCursor(1,1);          // set cursor of lcd to 2nd row and 2nd column 
-    lcd.print ("AQ Level Good");   // print as a sentence on lcd+    lcd.print ("AQ Level Good"); // print as a sentence on lcd
   }   }
  
amc2021/groupl/code/carbon_dioxide_measuring.1630811318.txt.gz · Last modified: 2023/01/05 14:38 (external edit)