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