amc2021:groupl:code:carbon_dioxide_measuring
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
amc2021:groupl:code:carbon_dioxide_measuring [2021/09/05 03:18] – kabir001 | amc2021:groupl:code:carbon_dioxide_measuring [2023/01/05 14:38] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
This code communicates with the MQ135 air quality sensor with the help of the [[amc2021: | This code communicates with the MQ135 air quality sensor with the help of the [[amc2021: | ||
Once the code runs, it prints out the concentration of detected gases in ppm on a serial monitor, and the results are displayed on an LCD screen. | Once the code runs, it prints out the concentration of detected gases in ppm on a serial monitor, and the results are displayed on an LCD screen. | ||
- | An alarm system (LED light) is also set to glow if the CO< | + | An alarm system (LED light) is also set to glow if the CO< |
Detailed explanation is given in the [[amc2021: | Detailed explanation is given in the [[amc2021: | ||
Line 9: | Line 9: | ||
<file c++ CO2Sensor.ino> | <file c++ CO2Sensor.ino> | ||
| | ||
- | #include " | + | #include " |
#include < | #include < | ||
#include < | #include < | ||
Line 15: | Line 15: | ||
LiquidCrystal_I2C lcd(0x27, | LiquidCrystal_I2C lcd(0x27, | ||
- | #define led 9 | + | #define led 9 //led on pin 9 |
- | const int gas_pin = A0; //analog feed from MQ135 | + | const int gas_pin = A0; |
- | MQ135 gasSensor = MQ135(gas_pin); | + | MQ135 gasSensor = MQ135(gas_pin); |
void setup(){ | void setup(){ | ||
lcd.init(); | lcd.init(); | ||
- | lcd.begin(16, | + | lcd.begin(16, |
lcd.backlight(); | lcd.backlight(); | ||
lcd.clear(); | lcd.clear(); | ||
lcd.setCursor(4, | lcd.setCursor(4, | ||
- | lcd.print(" | + | lcd.print(" |
pinMode(gas_pin, | pinMode(gas_pin, | ||
Line 35: | Line 35: | ||
void loop(){ | void loop(){ | ||
- | float ppm = gasSensor.getPPM(); | + | float ppm = gasSensor.getPPM(); |
| | ||
| | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | digitalWrite(led, | + | digitalWrite(led, |
- | lcd.setCursor(2, | + | lcd.setCursor(2, |
- | lcd.print(" | + | lcd.print(" |
} | } | ||
| | ||
- | digitalWrite(led, | + | digitalWrite(led, |
- | lcd.setCursor(1, | + | lcd.setCursor(1, |
- | lcd.print ("AQ Level Good" | + | lcd.print ("AQ Level Good" |
} | } | ||
amc2021/groupl/code/carbon_dioxide_measuring.1630804707.txt.gz · Last modified: 2023/01/05 14:38 (external edit)