Arduino CCS811 - CO2 & tVOC - Air Quality Monitor

Arduino CCS811 - CO2 & tVOC - Air Quality Monitor

Read CO2 and tVOC data using CCS811 I2C sensor breakout by itbrainpower.net. Temperature and humidity read compensation notes.

  • 1,745 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

CCS811 manufactured by AMS is an digital CO2 and tVoC air quality sensor. Main measurement characteristics:

  • equivalent carbon dioxide range is 400ppm up to 29206ppm;
  • equivalent Total Volatile Organic Compounds output range is from 0ppb up to 32768ppb;
  • internal compensation algorithm using external ambient temperature and humidity data source;
  • temperature range for operation -40C to +80C.

More info on: CCS811 datasheet.

In June 2019 we've released 6 new environmental and air quality sensors, including CCS811 I2C sensor breakout and HDC2010 + CCS811 I2C combo sensors breakout, all being part of the s-Sense I2C sensor breakout family.

PN: SS-CCS811#I2C SKU: ITBP-6004 CCS811 I2C sensor breakout info

PN: SS-HDC2010+CCS811#I2C SKU: ITBP-6006 HDC2010+CCS811 I2C combo sensor breakout info

Next, let's kickstart using CCS811 sensor I2C breakout - around 10-15 minutes. Same hardware and software approach may be used for CCS811 + HDC2010 bundle sensors I2C breakout.

Arduino CCS811 sensor hardware integration (basic wiring)

First, identify if your Arduino it's 5V or 3.3V compliant! The CCS811 I2C sensor breakout it's shipped in default auto 3.3-5V compliant configuration. Just wire as bellow:

** PAD 6 - CCS811 WAKE signal [placed on PCB bottom side]

  • when connected directly to GND, the CCS811 will avoid enter into SLEEP mode [sensor it's always ACTIVE].
  • when connected to D5, the MCU host software must be able to control SLEEP/ACTIVE mode switching [implemented in library, see bellow].

Whatever PAD6 [CCS811 WAKE] wiring used, the software will be able to handle sensor data initializing and environmental data readings.

HINT, for some ARDUINO boards:

  • SDA (Serial Data) --> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro
  • SCK (Serial Clock) --> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro

Bellow, sensor wiring examples, left to right, with Arduino UNO and xyz-mIoT

Arduino CCS811 read sensor data software

  • a. download CCS811 Arduino library from: here.
  • b. unzip the library and install in Arduino libraries folder. Restart Arduino.
  • c. Make a folder named "ssense_CCS811_example". Download and save the code bellow (right click & save as) - use ssense_CCS811_example.ino as name: CCS811 - read sensor data Arduino code or, use the ssense_CCS811_example from Arduino "File-> Examples", under "ssense-CCS811" library.
  • d. Compile and upload the code to your Arduino shield. The sensor data may be seen on Arduino Serial Monitor (set to 19200bps).

Advanced CCS811 feature [compensate sensor data - using external temperature and humidity data source]

CCS811 have some interesting features (read datasheet) like temperature and humidity drift / non-liniarity compensation. In a nut shell, the CCS811 firmware have the ability to use external THS data source for reading compensation algorithm.

To use this feature, in previous Arduino code, just use in line 59 real data supplied by an external THS sensor [I suppose you may like to have our CCS811+HDC2010 combo sensor to add our HDC2010 sensor breakout - HDC2010 sensor integration notes here ;)].

.

TUTORIAL PROVIDED WITHOUT ANY WARRANTY!!!USE IT AT YOUR OWN RISK!!!

Code

ssense_CCS811_example.inoArduino
Read and print CCS811 [carbon dioxide and total Volatile Organic Compounds] sensor data - pulling rate ~ 2 second.

Just wire the sensor with your Arduino board. Select your board, compile and upload code. Set Serial Monitor at 19200bps.
/* s-Sense CCS811 I2C sensor breakout example - v1.0/20190524. 
 * 
 * Compatible with:
 *		s-Sense CCS811 I2C sensor breakout [PN: SS-CCS811#I2C, SKU: ITBP-6004], info https://itbrainpower.net/sensors/CCS811-CO2-TVOC-I2C-sensor-breakout 
 *		s-Sense CCS811 + HDC2010 I2C sensor breakout [PN: SS-HDC2010+CCS811#I2C, SKU: ITBP-6006], info https://itbrainpower.net/sensors/CCS811-HDC2010-CO2-TVOC-TEMPERATURE-HUMIDITY-I2C-sensor-breakout
 *
 * Reading CO2 and tVOC values example (pulling at 2sec) - based on test software (Beerware license) written by Nathan Seidle from SparkFun Electronics. 
 * Thank you Nathan! Great job! 
 * 
 * We've ported Nathan's functions into a class, add some variables, functions and fuctionalities.
 * 
 * 
 * Mandatory wiring:
 *    Common for 3.3V and 5V Arduino boards:
 *        sensor I2C SDA  <------> Arduino I2C SDA
 *        sensor I2C SCL  <------> Arduino I2C SCL
 *        sensor GND      <------> Arduino GND
 *        sensor PAD6     <------> Arduino D5 or Arduino GND [connecting to GND the CCS811 sensor will be always ON]
 *    For Arduino 3.3V compatible:
 *        sensor Vin      <------> Arduino 3.3V
 *    For Arduino 5V compatible:
 *        sensor Vin      <------> Arduino 5V
 * 
 * Leave other sensor PADS not connected.
 * 
 * SPECIAL note for some ARDUINO boards:
 *        SDA (Serial Data)   ->  A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro
 *        SCK (Serial Clock)  ->  A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro
 * 
 * WIRING WARNING: wrong wiring may damage your Arduino board MCU or your sensor! Double check what you've done.
 * 
 * New CCS811 sensors requires at 48-burn in. Once burned in a sensor requires 20 minutes of run in before readings are considered good.
 * READ CCS811 documentation! https://itbrainpower.net/downloadables/CCS811_DS000459_5-00.pdf
 * 
 * You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH s-Sense CCS811 I2C sensors DEVICES USAGE. Modifications, derivates and redistribution 
 * of this software must include unmodified this COPYRIGHT NOTICE. You can redistribute this SOFTWARE and/or modify it under the terms 
 * of this COPYRIGHT NOTICE. Any other usage may be permited only after written notice of Dragos Iosub / R&D Software Solutions srl.
 * 
 * This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE.
 *  
 * Dragos Iosub, Bucharest 2019.
 * https://itbrainpower.net
 */

#define SERIAL_SPEED  19200

#include <sSense-CCS811.h>

CCS811 ssenseCCS811;


void setup()
{
  DebugPort.begin(SERIAL_SPEED);
  delay(5000);
  DebugPort.println("s-Sense CCS811 I2C sensor.");
  if(!ssenseCCS811.begin(uint8_t(I2C_CCS811_ADDRESS), uint8_t(CCS811_WAKE_PIN), driveMode_1sec))
    DebugPort.println("Initialization failed.");
}

void loop()
{ 
  ssenseCCS811.setEnvironmentalData((float)(21.102), (float)(57.73));  // replace with temperature and humidity values from HDC2010 sensor
  /*if (ssenseCCS811.dataAvailable()){
  {
    ssenseCCS811.readAlgorithmResults(); //Calling this function updates the global tVOC and CO2 variables

    .....DebugPort.print("CO2[");
    DebugPort.print(ssenseCCS811.getCO2());
    DebugPort.print("] tVOC[");
    DebugPort.print(ssenseCCS811.gettVOC());
    DebugPort.print("] millis[");
    DebugPort.print(millis());
    DebugPort.print("]");
    DebugPort.println();
  }
  */
  if (ssenseCCS811.checkDataAndUpdate())
  {
    DebugPort.print("CO2[");
    DebugPort.print(ssenseCCS811.getCO2());
    DebugPort.print("] tVOC[");
    DebugPort.print(ssenseCCS811.gettVOC());
    DebugPort.print("] millis[");
    DebugPort.print(millis());
    DebugPort.print("]");
    DebugPort.println();
  }
  else if (ssenseCCS811.checkForError())
  {
    ssenseCCS811.printError();
  }

  delay(2000);
}
Arduino CCS811 libraryC/C++
Arduino library to access AMS CCS811 [carbon dioxide and total Volatile Organic Componds] air quality sensor data - adapted for itbrainpower.net s-Sense CCS811 sensor I2C breakout and itbrainpower.net s-Sense HDC2010 + CCS811 bundled sensor I2C breakout; both compatible with 3.3V - 5V Arduino shields.

This code it's based on CCS811 test software (Beerware license) written by Nathan Seidle from SparkFun Electronics. Thank you Nathan! Great job! We've ported Nathan's functions into a class, add some variables, functions and functionalities. Read credits in example code and inside the class. We've just add add some variables, functions and functionalities.

Extract and copy the class in Arduino Library folder - 'libraries' folder found in your Arduino Sketchbook. Take a look at "readme.md" and/or "readme.md" files.

Example it's available in Arduino "File-> Examples", under "ssense-CCS811" library.

HINT: you may like to inject real THS data in ssenseCCS811.setEnvironmentalData((float)temp, (float)hum) call [line 59]!
No preview (download only).

Schematics

CCS811 sensor wiring example with Arduino UNO
5V compliant Arduino board - wire as shown in the image.
For 3.3V compliant Arduino board, wire Vin to Arduino 3.3V pad NOT to 5V!!!
Ccs811 arduino wiring uno j3cpcs4g74
CCS811 sensor wiring example with xyz-mIoT shield [AT SAMD21G, 3.3V compliant]
3.3V compliant Arduino board - wire as shown in the image.
For 5V compliant Arduino board, wire Vin to Arduino 5V pad NOT to 3.3V!!!
Ccs811 arduino wiring xyz miot gdgeue8lpt
CCS811+HDC2010 breakout datasheet
s-Sense CCS811+HDC2010 I2C sensor breakout datasheet
CCS811 breakout datasheet
s-Sense CCS811 I2C sensor breakout datasheet

Comments

Similar projects you might like

Measuring CO2 Levels aka "The Sleepiness Multiplier"

Project tutorial by Brian Carbonette

  • 6,622 views
  • 8 comments
  • 19 respects

Water Waste Monitor

Project tutorial by MD R. Islam

  • 1,150 views
  • 1 comment
  • 4 respects

How to Measure Air Quality on OpenSensors

Project tutorial by OpenSensors.io

  • 13,862 views
  • 8 comments
  • 60 respects

Air Quality Monitor

Project showcase by Mustafa Hesham

  • 5,860 views
  • 9 comments
  • 36 respects

Education with IoT- LoRa+Arduino - Some Assembly Required #2

Project tutorial by Bryn Lewis

  • 2,566 views
  • 0 comments
  • 14 respects
Add projectSign up / Login