Gravity__Infrared_CO2_Sensor_For_Arduino_SKU__SEN0219-DFRobot

SEN0219 Analog Infrared CO2 Sensor For Arduino

Introduction

DFRobot released its latest high-precision infrared arduino CO2 sensor. The effectively measuring range is from 400 to 5000ppm. This sensor is based on non-dispersive infrared (NDIR) technology and has good selectivity and oxygen-free dependency. Besides, its service life could up to 5 years! It integrates temperature compensation and support DAC output. The current CO2 concentration can be read with only one digital port. Most importantly, the product is easy to use and is compatible with all types of microcontrollers and sensors.
In addition, this product is a high-performance sensor that combines the technology of mature infrared absorption gas detection with precision optical circuit design, as well as sophisticated circuit design. It has characteristics such as high sensitivity, high resolution, low power consumption, fast response, anti-water vapor interference, no poisoning, high stability and long life.
This sensor is directly compatible with the DFRobot Arduino IO expansion board thanks to its external DFRobot Gravity interface. This simplifies the use of the sensor as it is plug-and-play and no additional wiring required. This product could be widely used in HVAC, indoor air quality monitoring, industrial process and security protection monitoring, agriculture and animal husbandry production process monitoring, etc.

Feature

Specification

Board Overview

SEN0219 Analog Infrared CO2 Sensor For Arduino Board Overview
Num Label Description
1 Signal Signal Output (0.4-2V)
2 VCC +
3 GND -

Zero Calibration

Tutorial

This tutorial is designed for you to learn how to use the infrared CO2 sensor to measure the current CO2 concentration in the air in 5 minutes.

Requirements

Connection Diagram

SEN0219 Analog Infrared CO2 Sensor For Arduino Manual Connection Diagram

Sample Code

Download the Arduino code, and open the window monitor in the upper right corner to view the data.

/***************************************************
   Infrared CO2 Sensor range : 400-4980ppm
 * ****************************************************
   This example The sensors detect CO2

   @author qsjhyy(qsj.huang@dfrobot.com)
   @version  V2.0
   @date  2021-8-17

   GNU Lesser General Public License.
   See <http://www.gnu.org/licenses/> for details.
   All above must be included in any redistribution
 * ****************************************************/
/*
  This example uses UNO to demonstrate.
  If you want to use other master controls, please configure the following two lines
*/
#define  sensorIn  3   // Sensor PWM interface
#define  interruptNumber  0   // interrupt number

unsigned long pwm_high_start_ticks=0, pwm_high_end_ticks=0;
float pwm_high_val=0, pwm_low_val=0;
volatile uint8_t flag=0;


void interrupt_rising()
{
  pwm_high_start_ticks = micros();    // store the current micros() value
  if(2 == flag){
    flag = 4;
    pwm_low_val = pwm_high_start_ticks - pwm_high_end_ticks;
  }else{
    flag = 1;
  }

  attachInterrupt(interruptNumber, interrupt_falling, FALLING);
}

void interrupt_falling()
{
  pwm_high_end_ticks = micros();    // store the current micros() value
  if(1 == flag){
    flag = 2;
    pwm_high_val = pwm_high_end_ticks - pwm_high_start_ticks;
  }

  attachInterrupt(interruptNumber, interrupt_rising, RISING);
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(sensorIn, INPUT);
  attachInterrupt(interruptNumber, interrupt_rising, RISING);
}

void loop() {
  if(flag == 4){
    flag = 1;
    float pwm_high_val_ms = (pwm_high_val * 1000) / (pwm_low_val + pwm_high_val);

    if (pwm_high_val_ms < 0.01){
      Serial.println("Fault");
    }
    else if (pwm_high_val_ms < 80.00){
      Serial.println("preheat");
    }
    else if (pwm_high_val_ms < 998.00){
      float concentration = (pwm_high_val_ms - 2) * 5;
      // Print pwm_high_val_ms
      Serial.print("pwm_high_val_ms:");
      Serial.print(pwm_high_val_ms);
      Serial.println("ms");
      //Print CO2 concentration
      Serial.print(concentration);
      Serial.println("ppm");
    }
    else{
      Serial.println("Beyond the maximum range :398~4980ppm");
    }
    Serial.println();
  }
}

Result

Please wait at least 3 minutes (preheat process) until the data is stable. At this time, the sensor can display the CO2 concentration.

FAQ

Q. Can I use the CO2 sensor with 3.3V microcontroller?
A. Yes, but you need to power the CO2 sensor with a 5V power supply separately, and change the conversion formula in the code float voltage = sensorValue*(3300/1024.0);
Q. Why is the reading of the CO2 sensor unstable?
A. The high sensitivity of the CO2 sensor may lead to relatively large fluctuations in the reading. The deviation of the reading can be reduced by taking the average of several values.

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Shopping from Gravity: Infrared CO2 Sensor For Arduino or DFRobot Distributor.

Turn to the Top