Andrey Ovcharov

Professional Software Engineer and hobbyist Hardware enthusiast

Andrey Ovcharov

Carbon Dioxide Sensor CCS811

Recently I have purchased one more carbon dioxide sensor module - CJMCU-811. The module is built on a chip CCS811 by company ams.

According to the description, it can measure the concentration of carbon dioxide and volatile organics and intended to measure air quality indoors.

Of course, I am interested in comparison of this sensor to the MH-Z19B I have used before.

Modules MH-Z19B and CJMCJ-811
Modules MH-Z19B and CJMCJ-811

The CJMCU-811 costs about 8 euro which is about two times cheaper than MH-Z19B.


The connection is rather trivial. I connect the module to the WeMos with only five wires:

The datasheet says the new module should work for 48 hours to burn-in some internals allowing it to work stable.

As well the module can be used together with temperature and humidity sensor to improve the measurement quality.


There are a bunch of libraries for Arduino and PlatformIO. The firmware is very simple, taken from one of the examples:

#include <Arduino.h>
#include <Wire.h> // I2C library
#include "ccs811.h" // CCS811 library

// Wiring for ESP8266 NodeMCU boards: VDD to 3V3, GND to GND, SDA to D2, SCL to D1, nWAKE to D3 (or GND)
CCS811 ccs811(D3); // nWAKE on D3

void setup()
    // Enable serial

    // Enable I2C


    // Enable CCS811
    ccs811.set_i2cdelay(50); // Needed for ESP8266 because it doesn't handle I2C clock stretch correctly
    bool ok = ccs811.begin();
    if (!ok)
        Serial.println("setup: CCS811 begin FAILED");

    // Start measuring
    ok = ccs811.start(CCS811_MODE_1SEC);
    if (!ok)
        Serial.println("setup: CCS811 start FAILED");

void loop()
    // Read
    uint16_t eco2, etvoc, errstat, raw;, &etvoc, &errstat, &raw);

    // Print measurement results based on status
    if (errstat == CCS811_ERRSTAT_OK)
        Serial.print("CCS811: ");
    else if (errstat == CCS811_ERRSTAT_OK_NODATA)
        Serial.println("CCS811: waiting for (new) data");
    else if (errstat & CCS811_ERRSTAT_I2CFAIL)
        Serial.println("CCS811: I2C error");
    else if (errstat & CCS811_ERRSTAT_ERRORS)
        Serial.print("CCS811: errstat=");
        Serial.print(errstat, HEX);

    // Wait

First experiments show that sensor really returns some numbers and these numbers change when I breathe on it. As well this sensor reacts way faster than MH-Z19B.

Now I want to put both sensors aside and stream the data to a single graph. It’s very interesting how accurate it is.


At the moment I see the following pros of the CJMCU-811 module:

  • Small size
  • 3.3V power supply
  • Relatively cheap
  • Communicates through the I2C interface

The cons I have found so far - one of two purchased modules did not work. I don’t know if is it just coincidence or the overall quality of these modules is quite low.