Home > Projects > Sensor – Transducer – Detector Projects > TVOC and CO2 Measurement using Arduino and CCS811 Air Quality Sensor

TVOC and CO2 Measurement using Arduino and CCS811 Air Quality Sensor

Summary of TVOC and CO2 Measurement using Arduino and CCS811 Air Quality Sensor


This article details a project to monitor air quality by measuring CO2 and TVOC levels using an Arduino UNO and the CCS811 sensor. The system interfaces the sensor with a 16*2 LCD to display real-time data, including temperature. It explains the sensor's capabilities, pin configuration, and provides Arduino code to initialize the hardware, calibrate the temperature offset, and retrieve gas readings for indoor air quality assessment.

Parts used in the Air Quality Monitoring System:

  • Arduino UNO
  • CCS811 Air Quality Sensor
  • Potentiometer (10k)
  • LCD 16*2
  • Breadboard
  • Connecting Wires

Sadly, in the name of progress, we have polluted the air, water, soil and the food we eat”. So monitoring the air quality is very crucial now days because of pollution. For designing an air quality monitoring system we need durable and reliable air quality sensor. Although there are many Air Quality parameters but the most important are CO2 and TVOC. So for sensing CO2 and TVOC, we are using CCS811 Air Quality Sensor.

TVOC and CO2 Measurement using Arduino and CCS811 Air Quality Sensor

In this tutorial, we are going to show you that how to sense TVOC and CO2 using CCS811 air quality sensor with Arduino. Also, you will learn to interface CSS811 with Arduino.

Material Required

  • Arduino UNO
  • CCS811 Air Quality Sensor
  • Potentiometer (10k)
  • LCD 16*2
  • Breadboard
  • Connecting Wires

Circuit Diagram

CCS811 Air Quality Sensor

CCS811 Air Quality Sensor is an ultra-low power digital gas sensor which integrates a MOX (metal oxide) gas sensor to detect a wide range of VOCs (Volatile Organic Compounds) for indoor air quality monitoring with an integrated MCU (Micro-controller Unit). MCU consists of ADC (Analog-to-Digital Converter) and I2C interface. It’s based on an ams unique micro-hotplate technology which empowers highly reliable solutions for Gas Sensors, with low power consumption.

In our circuit, we are using this sensor for sensing TVOC and CO2 available in the environment and displaying the data on 16*2 LCD.

Pin Configuration

Pin No.

Pin Name

Description

1

Vin

Input Supply (3.3v to 5v)

2

3V3

3.3V output Pin for external use

3

Gnd

Ground

4

SDA

This is I2C clock pin

5

SCL

I2C data pin

6

WAKE

Wakeup Pin of sensor, should be connected to ground in order to communicate with the sensor

7

RST

Reset pin: When connected to ground the sensor reset itself

8

INT

This is interrupt output pin, used to detect when a new reading is ready or when a reading gets too high or low

Application

  • Smartphones
  • Wearables
  • Home and Building Automation
  • Accessories

Code and Explanation

The complete Arduino code for TVOC and CO2 Measurement using CCS811 Air Quality Sensor is given at the end.

In the below code, we are defining the libraries for 16*2 LCD and CCS811 Air Quality Sensor. For downloading the library “Adafruit_CCS811.h” for CCS811 follow this link.

#include <LiquidCrystal.h>
#include "Adafruit_CCS811.h"

Below we have defined Pins for connection of 16*2 LCD with Arduino.

LiquidCrystal lcd(12, 13, 8, 9, 10, 11); /// REGISTER SELECT PIN,ENABLE PIN,D4 PIN,D5 PIN, D6 PIN, D7 PIN
Adafruit_CCS811 ccs;

Below we have set up LCD and CCS811 air quality sensor and calibrated it for the showing correct temperature, as shown in the below code,

void setup() {
  lcd.begin(16, 2); 
  ccs.begin();
  //calibrate temperature sensor
  while(!ccs.available());
  float temp = ccs.calculateTemperature();
  ccs.setTempOffset(temp - 25.0);
}

In the below code, we used functions ccs.available()” (Function is already defined in library) to check if there is some data coming. As we get the data we are able to calculate the temperature and display it on 16*2 LCD.

TVOC and CO2 Measurement using Arduino and CCS811 Air Quality Sensor schematics

Further if CCS is available and ccs.readData() is returning false then we get the CO2 value using function ccs.geteCO2() and TVOC value using ccs.getTVOC(), as shown in the below code. Hence, we have received the value of air quality parameters using CCS811 air quality sensor.

void loop() {
  if(ccs.available()){
    float temp = ccs.calculateTemperature();

    if(!ccs.readData()){
      int co2 = ccs.geteCO2();
      int tvoc = ccs.getTVOC();
      lcd.setCursor(0, 0);
      lcd.print(String ("CO2:")+ String (co2)+String(" PPM"));
      lcd.setCursor(0, 1);
      lcd.print(String ("TVOC:")+ String (tvoc)+String(" PPB "));
      lcd.print(String("T:"+String (int(temp)))+String("C"));
      delay(3000);
      lcd.clear();     
    }

    else{
      lcd.print("ERROR");
      while(1);
    }
  }
}

Complete Arduino code is given below. Code is simple, all the work is done by its library itself and we have used functions defined in the CCS library to get the values of CO2 and TOVC.

Read more: TVOC and CO2 Measurement using Arduino and CCS811 Air Quality Sensor

Quick Solutions to Questions related to Air Quality Monitoring System:

  • What are the most important air quality parameters mentioned?
    The most important parameters identified are CO2 and TVOC.
  • How do you connect the WAKE pin on the CCS811 sensor?
    The WAKE pin should be connected to ground to communicate with the sensor.
  • Can this system measure temperature?
    Yes, the system calculates temperature using the ccs.calculateTemperature function.
  • Which library is required for the CCS811 sensor?
    The Adafruit_CCS811.h library is required for the sensor.
  • How does the code handle errors during reading?
    If ccs.readData returns false, the code prints ERROR and stops execution.
  • What technology does the CCS811 sensor use?
    The sensor uses ams unique micro-hotplate technology.
  • How often does the display update?
    The display updates every 3000 milliseconds as per the delay command.
  • What interface does the CCS811 sensor use for communication?
    The sensor uses an I2C interface consisting of SDA and SCL pins.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top