Estimating CO2 Concentration in Air With Arduino & MQ-135

by hIOTron IoT in Circuits > Arduino

90 Views, 0 Favorites, 0 Comments

Estimating CO2 Concentration in Air With Arduino & MQ-135

co2 concentration.jpg

In the above project, we are going to utilize an MQ-135 sensor with Arduino to estimate CO2 concentration

Supplies

Hardware Components

Arduino Nano

MQ-135 sensor

0.96’ SPI OLED Display Module

Register 22.1k ohm

About Project

0.96''OLED display.jpg
MQ 135 sensor.jpg

0.96’ OLED Display Module

OLED is basically a self light-emitting technology, designed by putting a series of organic thin films between two conductors. When an electric current is applied to these films, a bright light is generated.

OLED Specifications:

Driver IC: SSD1306

Resolution: 128 x 64

Input Voltage: 3.3V ~ 6V

Operating temperature: -30°C ~ 70°C

Preparing the MQ-135 Sensor
MQ-135 Gas Sensor is a sensor for recognizing a broad range of gases, involving NH3, benzene, smoke and CO2. It can be bought as a module or just as a sensor alone.

Know more about IoT Training

Run a Program

// The load resistance on the board #define RLOAD 22.0 #include "MQ135.h" #include #include #include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for SSD1306 display connected using software SPI (default case): #define OLED_MOSI 9 #define OLED_CLK 10 #define OLED_DC 11 #define OLED_CS 12 #define OLED_RESET 13 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); MQ135 gasSensor = MQ135(A0); int val; int sensorPin = A0; int sensorValue = 0; void setup() { Serial.begin(9600); pinMode(sensorPin, INPUT); display.begin(SSD1306_SWITCHCAPVCC); display.clearDisplay(); display.display(); } void loop() { val = analogRead(A0); Serial.print ("raw = "); Serial.println (val); // float zero = gasSensor.getRZero(); // Serial.print ("rzero: "); //Serial.println (zero); float ppm = gasSensor.getPPM(); Serial.print ("ppm: "); Serial.println (ppm); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(18,43); display.println("CO2"); display.setCursor(63,43); display.println("(PPM)"); display.setTextSize(2); display.setCursor(28,5); display.println(ppm); display.display(); display.clearDisplay(); delay(2000); }