In the above project, we are going to utilize an MQ-135 sensor with Arduino to estimate CO2 concentration.
Summary
In the above project, we are going to utilize an MQ-135 sensor with Arduino to estimate CO2 concentration
About Project
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.
- Driver IC: SSD1306
- Resolution: 128 x 64
- Input Voltage: 3.3V ~ 6V
- Operating temperature: -30°C ~ 70°C
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.
// The load resistance on the board
#define RLOAD 22.0
#include "MQ135.h"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#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);
}