In this project, we’ll use an Arduino to connect with a Gravity Infrared CO2 Sensor to calculate CO2 concentration in PPM.
HARDWARE :
Arduino Nano R3
Gravity Infrared CO2 Sensor V1.1
Jumper wires (generic)
0.96’ SPI OLED Display Module
Virtual Breadboard VBBMicro ‘Arduino UNO Avatar’
SOFTWARE :
Arduino IDE
The current high-precision analogue CO2 sensor is the Gravity Infrared CO2 Sensor. A 3-pin connection is used to connect the Infrared CO2 Sensor to the rest of the system. This sensor uses non-dispersive infrared (NDIR) technology to improve selectivity and eliminate oxygen dependence. Temperature correction and DAC output assistance are combined in this device.
This sensor has an effective measurement range of 0 to 5000ppm and an accuracy of 50ppm + 3%. This infrared CO2 sensor may be used in HVAC, indoor air quality monitoring, industrial process and security monitoring, agricultural, and animal husbandry production process monitoring.
OLED stands for organic light-emitting diodes, and it is made by sandwiching a sequence of organic thin films between two conductors.
Code :
int sensorIn = A4;
#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);
void setup(){
Serial.begin(9600);
// Set the default voltage of the reference voltage
analogReference(DEFAULT);
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
display.display();
}
void loop(){
//Read voltage
int sensorValue = analogRead(sensorIn);
// The analog signal is converted to a voltage
float voltage = sensorValue*(5000/1024.0);
if(voltage == 0)
{
Serial.println("Fault");
}
else if(voltage < 400)
{
Serial.println("preheating");
}
else
{
int voltage_diference=voltage-400;
float concentration=voltage_diference*50.0/16.0;
// Print Voltage
Serial.print("voltage: ");
Serial.print(voltage);
Serial.println("mv");
//Print CO2 concentration
Serial.print("CO2 Concentration: ");
Serial.print(concentration);
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(concentration);
display.display();
display.clearDisplay();
}
delay(2000);
}
“Plant trees as much as you can, It’s best help you can do to yourself and nature.” – KP
Helping Hands.