Dual CCS811 Sensors don't work

Hello all,

Setup:
1.) Arduino UNO R3
2.) Two CCS811-Sensors (SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic) - SEN-14348 - SparkFun Electronics) connected to the Arduino iva I2C.
3.) One sensor has got address 0x5B, the other sensor hat got the address 0x5A

What does work:
1.) If I connect each single sensor to the Arduino everything is fine. I get consistent readings out of this sensor.
2.) If I connect both sensors to the Arduino at the same time, I get inconsistent readings of both sensors: The values are jumping up and down.

Could anyone please tell me, how to get consistent non jumping values using both sensors somultaniously?

Example of the output using both sensors simulaniously:

11:12:00.188 -> CCS811 Basic Example two sensors
11:12:00.188 -> CCS811 Basic Example two sensors
11:12:05.389 -> CO2[400] tVOC[0] millis[5207]
11:12:05.389 -> CO2 B[400] tVOC B[0] millis B[5219]
11:12:06.889 -> CO2[400] tVOC[0] millis[6731]
11:12:06.889 -> CO2 B[417] tVOC B[2] millis B[6744]
11:12:08.436 -> CO2[439] tVOC[5] millis[8256]
11:12:08.436 -> CO2 B[768] tVOC B[56] millis B[8268]
11:12:09.935 -> CO2[1110] tVOC[108] millis[9780]
11:12:09.935 -> CO2 B[1235] tVOC B[127] millis B[9792]
11:12:11.488 -> CO2[668] tVOC[40] millis[11304]
11:12:11.488 -> CO2 B[1191] tVOC B[120] millis B[11317]
11:12:12.988 -> CO2[572] tVOC[26] millis[12829]
11:12:12.988 -> CO2 B[972] tVOC B[87] millis B[12841]
11:12:14.535 -> CO2[589] tVOC[28] millis[14354]
11:12:14.535 -> CO2 B[560] tVOC B[24] millis B[14366]
11:12:16.035 -> CO2[1140] tVOC[112] millis[15879]
11:12:16.035 -> CO2 B[1235] tVOC B[127] millis B[15891]
11:12:17.589 -> CO2[530] tVOC[19] millis[17403]
11:12:17.589 -> CO2 B[694] tVOC B[44] millis B[17416]
11:12:19.089 -> CO2[1056] tVOC[99] millis[18927]
11:12:19.089 -> CO2 B[706] tVOC B[46] millis B[18939]
11:12:20.590 -> CO2[1099] tVOC[106] millis[20452]
11:12:20.637 -> CO2 B[927] tVOC B[80] millis B[20464]

The code I am using:

#include <Wire.h>

#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

CCS811 mySensor(CCS811_ADDR);
CCS811 mySensorB(0x5A);

void setup()
{
  Serial.begin(115200);
  Serial.println("CCS811 Basic Example two sensors");

  Wire.begin(); //Inialize I2C Hardware

  if (mySensor.begin() == false)
  {
    Serial.print("CCS811 error. Please check wiring. Freezing...");
    while (1)
      ;
  }
  if (mySensorB.begin() == false)
  {
    Serial.print("CCS811 B error. Please check wiring. Freezing...");
    while (1)
      ;
  }


}

void loop()
{
  //Check to see if data is ready with .dataAvailable()
  if (mySensor.dataAvailable())
  {
    //If so, have the sensor read and calculate the results.
    //Get them later
    mySensor.readAlgorithmResults();

    Serial.print("CO2[");
    //Returns calculated CO2 reading
    Serial.print(mySensor.getCO2());
    Serial.print("] tVOC[");
    //Returns calculated TVOC reading
    Serial.print(mySensor.getTVOC());
    Serial.print("] millis[");
    //Display the time since program start
    Serial.print(millis());
    Serial.print("]");
    Serial.println();
  }
  delay(10);
  
  if (mySensorB.dataAvailable())
  {
    //If so, have the sensor read and calculate the results.
    //Get them later
    mySensorB.readAlgorithmResults();

    Serial.print("CO2 B[");
    //Returns calculated CO2 reading
    Serial.print(mySensorB.getCO2());
    Serial.print("] tVOC B[");
    //Returns calculated TVOC reading
    Serial.print(mySensorB.getTVOC());
    Serial.print("] millis B[");
    //Display the time since program start
    Serial.print(millis());
    Serial.print("]");
    Serial.println();
  }
 
  delay(10); //Don't spam the I2C bus
  delay(1500);
}

Best reagards,

Oli

Hi
Did you close this jumper to use address 0x5A, or open it to use address 0x5B?

Hi ruilviana,

yes, the modules have different addresses.
I closed the jumper on one board to use the address 0x5A. On the other board I left the jumper open to use address 0x5B.
I've also checked with an I2C-scanner, that the modules do have the disired addresses. The addresses look good, but the values are jumping.

Best regards,

Oli

Hi,
Can you please post a circuit diagram please.

I gather the I2C scanner sees both addresses when both sensors are connected at the same time?

Do you have a DMM, have you measured the 3V3 supply when the problem is occuring?
Can I suggest a 0.1uF capacitor across the 3V3 and gnd of both sensors?

How long are the leads between the UNO and the sensors?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Hi Tom,

thank you very much for your help.

Please let me first answer your questions:

Yes, the I2C scanner sees both addresses when both sensors are connected at the same time. If I disconnect one sensor, the scanner only sees one address.

Yes, I could use a DMM to measure the 3V3 supply. But I decided to use an oscilloscope instead. Please see the pictures below.

I used an 47µF capacitor near the output of the arduino and one 6,8 µF tantalum capacitor near each sensor and additionally one 10 nF ceramic capacitor near each sensor. I now also included an additional 0,1 µF capacitor near each sensor.

The leads between the Arduino Uno and the beadboard are about 10 cm long. The leads between the "input of the beadboard and the first sensor are 10 cm long. The leads between the first sensor and the second sensor are 10 cm long.

Please find the following pictures:
1.) Schematic

Pictures 2.) - 5.) will be shown in extra Posts. I'm sorry about that.

Please let me add some more things:
1.) Running the Arduino with two sensors shows jumping values. If I pull out the wires going to the second sensor, the values of the first sensor become stable immediately.
2.) As mentioneed: Running the Arduino with two sensors shows jumping values. If I pull out the first sensor, the values of the second sensor become stable immediately.
3.) Each sensor-board has an additional BME280 on board. The values of the BME280 sensors are always stable.
4.) If I connect one additional 4x20 character LCD, the problems remains exactly the same: One single sensor works fine, two CCS811 sensors at the same time don't work.
5.) I used I2C frequencies og 100kHz and 400kHz. I didn't see any difference regarding the stability of the values.

Is there any chance, that there is a problem with the sparkfun-library? Maybe the values of one sensor are written to the same memory-address as the other sensor?

Best regads,
Oli

2.) Setup

3.) 3V3: One sensor connected to Arduino with capacitors

4.) 3V3: Two sensors conncted to Arduino with capacitors

5.) 3V3: Two sensors connected to Arduino without any capacitors

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.