Firstly, I'm not sure if this is the right SE to ask this question. Please feel free to direct me somewhere else if needed.

I am observing large spikes in CO2 and TVOC measurements using the CJMCU-811 sensor. When plotted it looks like this:

enter image description here

Nothing particular is happening around the sensor at those moments of spikes, I'm not breathing on the sensor etc.

I use Arduino Uno with the following code:

  Read CO2 and TVOCs from CJMCU-811 sensor

  Arduino connection:
  3.3V to 3.3V
  ACC to 3.3V
  GND to GND
  WAK to GND
  SDA to A4
  SCL to A5

#include <Wire.h>

#include "SparkFunCCS811.h"
#define CCS811_ADDR 0x5B

CCS811 mySensor(CCS811_ADDR);

void setup()
  Serial.println("CCS811 Basic Example");


  CCS811Core::status returnCode = mySensor.begin();
  if (returnCode != CCS811Core::SENSOR_SUCCESS)
    Serial.println(".begin() returned with an error.");
    while (1);

void loop()

  if (mySensor.dataAvailable())



    Serial.print("CO2 ");

    Serial.print(", tVOC ");



Of course I can filter and not worry about them, but I'm nevertheless curious what is causing it. Any suggestions what could be the reason for that?

  • 1
    Two suggestions ... do you have a second sensor? If you run two sensors close to each other and the spikes coincide, then something IS happening around the sensor. Or ... seal the sensor inside a container ... do the spikes still happen? – Jaromanda X Oct 23 '19 at 22:05
  • @Jaromanda X, good point, I have two of them so that will be easy to see. – kamilazdybal Oct 25 '19 at 14:38
  • If the "spikes" are due to some "internal" error, as per the answer, you could always take 5 or so readings in as short a time as the sensor will allow, remove any outliers then average the rest - the code for doing that isn't too difficult – Jaromanda X Oct 25 '19 at 23:36

I have two of those sensors in a long term setup and I know those spikes very well. I once put lots of effort in debugging and I personally gave up on the ccs811 and use a different sensor now.

Back then I have already tried what Jaromanda suggests in his comment. Both of my sensos showed the same behaviour while the spikes on both sensors did not correlate in any form. Also, if I remember it right, those erronous readings appeared to be at dedicated values. I tried several pullups, which also didn't make any difference and on the oscilloscope everything looked fine. Printing the output of the I2C related functions revealed that communication was always stable. If it was I2C related I would expect those erronous readings to be completely random anyway (which they aren't from my experience).

My final (vague) theory was that maybe there exist race conditions between the computation and the I2C interface or maybe the adc and the approximation algorithm (that's all "inside" of the sensor). I once produced such a bug myself which resulted in a similar behaviour.

At least I'm pretty sure that there is nothing you can do in your sketch to fix this problem, because for the mentioned reasons it is very unlikely related to communication problems. You might want to work-around it or look for an updated firmware. Or (my prefered solution) choose a sensor which does a true CO2 measurement (the ccs811 only returns a pseudo, calculated CO2-equivalent approximation). Those higher-class sensors use NDIR technique and are only a bit more expensive (still under 50$) but you'll probably have much more reliable readings, less problems and a wider measurement range (up to 0-40000ppm vs 400-8192ppm).

Ps: did you follow the guidelines concerning the "burn-in time"? Because honestly, that was a mistake I did: I simply plugged it in of curiosity to test communication and read about this step afterwards. But I don't believe it has something to do with this problem, because there are physical reasons why one should do so, but those artifacts seem to be of digital nature.

  • 1
    Which CO2 sensor did you end up going with? – Dave W. Smith May 24 '20 at 19:05
  • @DaveW.Smith I personally like the SCD30 by sensirion, but there are other NDIR-CO2 sensors (this is not meant to be a product recommendstion). – Sim Son Oct 19 '20 at 20:58

There is a CCS811 library which supports querying the internal firmware version of the sensor, and flashing a new firmware (latest is 2.0.1). Older firmware versions used to have burn-in compensation which apparently caused more harm than good (instead, new firmware requires sensors to be burned-in during 48 hours), and also relied on an external sensor for temperature compensation, which is simply missing on most cheap breakout boards. Ironically many cheap boards come with CCS811 flashed with an older firmware, which periodically samples the voltage on a floating pin and uses that value to correct CO2/TVOC calculations.

Unless your board features a thermistor, consider upgrading the sensor firmware to 2.0.1. Even or boards with a thermistor (e.g. original Adafruit), new firmware might give better results.


I saw similar behavior from 3 CJMCU-811 sensors that I bought (in one order, so probably the same manufacturing lot) in mid 2019. Two gave readings with steady, spikey, but uncorrelated upward growth. The third periodically spiked into the 2000-3000 ppm zone and then popped back to ~450 ppm (in an empty room with decent airflow). A logic analyzer on the I2C lines didn't show issues (or I missed them).

I went as far as adding a line to reset the sensors every few minutes. Replacing the sensors with what I assume was a different manufacturing lot resolved the issue.

I'm using the AdaFruit ccs811 library on ESP8266s (Wemos D1 minis).

Months later: The replacements have gone haywire, occasionally giving readings in the 3000ppm range until reset, at which point they're back to the 400-600ppm range for a while until drifting higher. I recommend avoiding the ccs811.

  • Values dropping after a reset is something you should expect. The datasheet says "After writing to MEAS_MODE to configure the sensor in mode 1-4, run CCS811 for 20 minutes, before accurate readings are generated", so whatever you read right after a reset is garbage. – Dmitry Grigoryev Oct 19 '20 at 14:39
  • I expect the drop, but not from 3000 to 400, then drifting slowly to 800, then spiking back to 3000 and hanging out there until reset. This n a room with a window open, and the sensor placed so that it gets breeze. – Dave W. Smith Oct 19 '20 at 16:53
  • Observed the same behavior on CJMCU-811, CO2 value drifting upwards until reset. – user70125 Jan 3 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.