Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Measure CO2 & TVOC using CCS811 Gas Sensor & Arduino
Arduino Projects

Measure CO2 & TVOC using CCS811 Gas Sensor & Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:May 29, 20238 Comments7 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
CCS811 Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this tutorial, we will interface CO2 & TVOC Gas Sensor CCS811 with Arduino & measure CO2 & TVOC in the air. The CCS811 Air Quality Breakout Board is a digital gas sensor capable of sensing a wide range of Total Volatile Organic Compounds (TVOC) & equivalent carbon dioxide (eCO2) with metal oxide (MOX) levels. We can thus use this sensor to identify the air quality whether the air is pure to breathe or not. You can also check SPG30 Air Quality Sensor which is similar to CCS811.

Earlier we did some projects like Particulate Matter Concentration (PM2.5) Measurement & Air Quality Index (AQI) using PMS5003 or MQ135 Gas Sensor. Those sensors are very good to measure the Air quality but are not capable of measuring carbon dioxide level & Total Volatile Organic Compounds level. That is why CCS811 is the best sensor available in market to measure these parameters. The CCS811 is very tiny and ultra-low power consumption device that can be used in wearables and handheld device for monitoring Indoor Air Quality.

So, this is why we should make our own CO2 & TVOC Meter using CCS811 Gas Sensor & Arduino Board. In this tutorial, we will go through the construction, working, internal architecture, and pins configuration of CCS811. Then using the CCS811 Arduino Library we will write few example codes and retrieve the value of CO2 & TVOC and display them on Serial Monitor. Using a 0.96″ I2C OLED Display, we will display the CO2 & TVOC Value on OLED Screen.




Bill of Materials

The purchase link for CCS811 Gas Sensor along with all other required component is given below. You can purchase all of them from Amazon.

S.N.Components NameQuantityPurchase Links
1Arduino Nano Board1Amazon | AliExpress
2CCS811 CO2 TVOC Sensor1Amazon | AliExpress
30.96" I2C OLED Display1Amazon | AliExpress
4Connecting Wires10Amazon | AliExpress
5Breadboard1Amazon | AliExpress

CCS811 Air Quality Gas Sensor Module

Overview

CCS811

The CCS811 Air Quality Sensor Breakout Board is a digital gas sensor that senses a wide range of Total Volatile Organic Compounds (TVOCs) along with equivalent carbon dioxide (eCO2) and metal oxide (MOX) levels. The sensor can be used for monitoring Indoor Air Quality. The system can be used with a microcontroller unit (MCU), which includes an Analog-to-Digital converter (ADC) & an I²C interface.

You can connect CCS811 to Arduino or any other microcontroller, you will get a Total Volatile Organic Compound (TVOC) reading and an equivalent carbon dioxide reading (eCO2). CCS811 supports intelligent algorithms to process raw sensor measurements to output a TVOC value or equivalent CO2 (eCO2) levels. The sensor can support multiple measurement modes like low-power consumption mode & idle mode for extending battery life in portable applications.

This sensor measure eCO2 concentration within a range of 400 to 8192 parts per million (ppm), and TVOC concentration within a range of 0 to 1187 parts per billion (ppb). Apart from these, it can also detect Alcohols, Aldehydes, Ketones, Organic Acids, Amines, Aliphatic and Aromatic Hydrocarbons. You can go through the CCS811 Datasheet for learning more about its architecture and construction.

Features of CCS811 Gas Sensor

  • Integrated MCU
  • Operating Voltage: 1.8V to 3.6V
  • On-board processing
  • A standard I²C digital interface with an I2C Address of 0x5A or 0X5B
  • Optimized low-power modes
  • 2.7mm x 4.0mm x 1.1mm LGA package
  • Low component count
  • Proven technology platform, Compact and economical
  • eCO2 Measurement range: 400 to 8192ppm
  • TVOC Measurement range: 0 to 1187ppb
  • Multiple drive modes for measurements every 1s, 10s, 60s, or every 250ms
  • Arduino and CircuitPython compatibility
  • Integrated 12-bit ADC for sensor readings and digitized conversions
  • Reset / interrupt control

CCS811 Pinout Configuration

1. VCC – This is the power pin. The sensor uses 3.3V to power the board.
2. GND – Common ground for power and logic.
3. SCL – This is the I2C clock pin pulled to VCC via a 10K resistor.
4. SDA – This is the I2C data pin pulled to VCC via a 10K resistor.
5. WAKE – This is the wake-up pin for the sensor. It needs to be pulled to the GND in order to communicate with the sensor. Pull this line high or VCC put the sensor to sleep.
6. INT – This is the interrupt-output pin. It is 3V logic and one can use it to detect when a new reading is ready or when the reading gets too high or too low.
7. RST – This is the reset pin. When it is pulled to GND the sensor resets itself.
8. ADD – Single address select bit to allow the alternate address to be selected. When ADDR is low the 7-bit I²C address is decimal 90 / hex 0x5A. When ADDR is high the 7-bit I²C address is decimal 91 / hex 0x5B.

Applications

This device can be mainly used for indoor air quality monitoring in:
1. Smart phones
2. Wearables Electronics
3. Home & Building automation
4. Hand-held Accessories< 5. Hand-held Accessories


How to use CCS811 Gas Sensor with Arduino?

Now let us interface CCS811 Air Quality Gas Sensor with Arduino and measure CO2 & TVOC. To do that, follow the following circuit diagram below.

CCS811 Arduino

Connect the Vin & GND pin of CCS811 to 3.3V & GND Pin of Arduino. Do not power the sensor with 5V as the sensor can support a maximum of 3.6V only. Connect the sensor SDA & SCL pin to Arduino A4 & A5 Pin respectively. Connect the WAKE pin of CCS811 to GND. Do not leave the WAKE pin empty as the controller won’t read the I2C Address.


CCS811 Arduino Library Installation

The CCS811 library is used for interfacing the CCS811 Sensor with Arduino. The Libray is written by both Adafruit and Sparkfun. You can use any of the library. The download link for both the libraries ais given below.

  1. Download: CCS811 Adafruit Library
  2. Download: CCS811 Sparkfun Library

You can also download these libraries from the library manager as well. Both of these libraries are available in Arduino Library Manager.

CCS811 Arduino Library


Source Code/Program CCS811 Arduino Basic Interfacing

Though you can use any of the libraries for retrieving the value of CO2 & TVOC, I used the Adafruit library. The source code is given below. The default I2C Address of CCS811 is 0x5A while some of the CCS811 has an I2C Address of 0X5B. You can modify the I2C Address in the library file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Adafruit_CCS811.h"
 
Adafruit_CCS811 ccs;
 
void setup() {
  Serial.begin(115200);
 
  Serial.println("CCS811 test");
 
  if(!ccs.begin()){
    Serial.println("Failed to start sensor! Please check your wiring.");
    while(1);
  }
 
  // Wait for the sensor to be ready
  while(!ccs.available());
}
 
void loop() {
  if(ccs.available()){
    if(!ccs.readData()){
      Serial.print("CO2: ");
      Serial.print(ccs.geteCO2());
      Serial.print("ppm, TVOC: ");
      Serial.println(ccs.getTVOC());
    }
    else{
      Serial.println("ERROR!");
      while(1);
    }
  }
  delay(500);
}

After uploading the code, open the serial monitor. If the connection is correct, then you will see the Serial Monitor displaying measured CO2 & TVOC value. In clean air and a typical indoor space your serial monitor will look something like this:

It is recommended to run CCS811 for 20 minutes every time before accurate readings are generated. In order to test the working of the sensor, you can introduce smoke or some perfume or evaporating hand sanitizer or simply blow air on the sensor. At this time, the CO2 & TVOC values both will rise high.


Displaying CO2 & TVOC Value on OLED Display

You can add an extra OLED display to the the above circuit. And using the OLED library you can display the CO2 & TVOC value on OLED Display.

The circuit diagram for connecting OLED Display with Arduino & CCS811 Sensor is given below.

CO2 TVOC Meter

The connection between the Arduino & CCS811 remains the same. Since OLED Display is the I2C Module, connect its SDA & SCL pin to the A4 & A5 of Arduino. Connect the VCC pin to 3.3V & GND to GND.



Source Code/Program

The CCS811 Arduino OLED code is given below. You need to add additional 2 libraries for OLED Display. Download the libraries from the following link & add it to the Arduino Library folder.

  1. Adafruit SSD1306 Library: Download
  2. Adafruit GFX Library: Download

Here is a complete code, you can upload it to the Arduino Board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "Adafruit_CCS811.h"
#include <Wire.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
#define OLED_RESET -1       // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
Adafruit_CCS811 ccs;
 
void setup()
{
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
  delay(500);
  display.clearDisplay();
  display.setCursor(25, 15);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println("CCS811 Sensor");
  display.setCursor(25, 35);
  display.setTextSize(1);
  display.print("Initializing");
  display.display();
 
  Serial.println("CCS811 test");
 
  if (!ccs.begin())
  {
    Serial.println("Failed to start sensor! Please check your wiring.");
    while (1);
  }
 
  // Wait for the sensor to be ready
  while (!ccs.available());
}
 
void loop()
{
  if (ccs.available())
  {
    if (!ccs.readData())
    {
      Serial.print("CO2: ");
      Serial.print(ccs.geteCO2());
      Serial.print("ppm, TVOC: ");
      Serial.println(ccs.getTVOC());
 
      display.clearDisplay();
      display.setTextSize(1);
      display.setCursor(20, 0);
      display.print("Air Quality");
      
      display.setTextSize(2);
      display.setCursor(0, 20);
      display.print("CO2:");
      display.print(ccs.geteCO2());
      display.setTextSize(1);
      display.print(" ppm");
 
      display.setTextSize(2);
      display.setCursor(0, 45);
      display.print("TVOC:");
      display.print(ccs.getTVOC());
      display.display();
    }
    else
    {
      Serial.println("ERROR!");
      display.clearDisplay();
      display.setTextSize(2);
      display.setCursor(0, 5);
      display.print("ERROR!");
      while (1);
    }
  }
  delay(1000);
}

The OLED display will start displaying the CO2 & TVOC value soon after the code is uploaded. You can introduce gas near to it to test the sensor.

CCS811 Test


Video Tutorial & Guide

CO2 & TVOC Measurement using CCS811 Air Quality Gas Sensor & Arduino
Watch this video on YouTube.

The sensor can also be interfaced with ESP8266 & ESP32. The ESP32/ESP8266 CCS811 Web Server Project is explained very briefly.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleIoT IR Thermometer using MLX90614 & ESP8266 on Blynk
Next Article DIY Soil Ph Meter using Soil Ph Sensor & Arduino

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 8 Comments

8 Comments

  1. José Léles Soares Alves on June 2, 2021 2:30 AM

    Hello! in my test the program gets stuck in void setup().

    Reply
  2. José Léles Soares Alves on June 3, 2021 7:33 PM

    Hello, in my tests it always shows message on the serial monitor “Failed to start sensor! Please check your wiring.”

    I’ve tested it several times with Arduino Uno and an ESP32, I can’t connect the sensor. Can you help me?

    Reply
    • Alex Newton on June 3, 2021 7:34 PM

      Please change the I2c address in the library. the CCS811 sensor has multiple I2C address.

      Reply
  3. Sasha on December 16, 2021 7:00 PM

    Hi, I used this code, and used the same connections for the CCS811. Basically my sensor gives me the right values ​​(~ 400 PPM) for 1/2 minutes, but after 15 minutes the values ​​are wrong (~ 2000 PPM) and out of the ordinary. I wanted to ask if anyone knew the problem, and how to fix it.
    Thank you and wait for info.

    Reply
  4. Virgis on August 7, 2022 10:59 PM

    Hello, a nice and simple project. Please tell me how you can add 5 more pieces of ws2812 led to this project so that they would change color from green – yellow to red as CO2 ppm increases . That would be really cool. How to do it? Is it very difficult?

    Reply
  5. Liao Yuping on August 29, 2022 5:16 AM

    用3個LED燈(紅黃綠),你代碼添加:氣體濃度3個檢測到CO2變化量(0~1023)值,啟動有顏色的LED///////With 3 LED lights (red, yellow and green), your code adds: gas concentration 3 detected CO2 change (0 ~ 1023) value, start the colored LED

    Reply
  6. Knowing on January 17, 2023 1:21 AM

    Hi. As stated above the Sensor need s about 15-20 Minutes to calibrate and warm up. So it is more than possible, that the readings after 15 minutes shows the right Values according your test area…

    Reply
  7. Ubeyde on April 15, 2023 5:31 AM

    hi, i don’t know what to change in the library. can you help me?

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • RS-485 Simplex Communication with Arduino & MAX485
    RS-485 Simplex Communication with Arduino & MAX485
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.