I bought CSS811+BNE280 and run them on Arduino Uno.
I downloaded the source code and tried to make a little change to read tVOC and sensor resistance values.
But I have no idea how to get the value to print out and the CCS811 cpp file does not have any function to retrieve the resistance value.
Thanks very much for your advice in advance.
here is the code
#include <SparkFunCCS811.h>
#include <SparkFunBME280.h>
#include <Wire.h>
#define CCS811_ADDR 0x5B //Default I2C Address
#define PIN_NOT_WAKE 5
//Global sensor objects
CCS811 myCCS811(CCS811_ADDR);
BME280 myBME280;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println();
Serial.println(“Apply BME280 data to CCS811 for compensation.”);
Wire.begin();
//This begins the CCS811 sensor and prints error status of .begin()
CCS811Core::status returnCode = myCCS811.begin();
if (returnCode != CCS811Core::SENSOR_SUCCESS)
{
//Pass the error code to a function to print the results
Serial.println(“Problem with CCS811”);
printDriverError( returnCode );
}
else
{
Serial.println(“CCS811 online”);
}
//For I2C, enable the following and disable the SPI section
myBME280.settings.commInterface = I2C_MODE;
myBME280.settings.I2CAddress = 0x77;
//Initialize BME280
//For I2C, enable the following and disable the SPI section
myBME280.settings.commInterface = I2C_MODE;
myBME280.settings.I2CAddress = 0x77;
myBME280.settings.runMode = 3; //Normal mode
myBME280.settings.tStandby = 0;
myBME280.settings.filter = 4;
myBME280.settings.tempOverSample = 5;
myBME280.settings.pressOverSample = 5;
myBME280.settings.humidOverSample = 5;
//Calling .begin() causes the settings to be loaded
delay(10); //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
byte id = myBME280.begin(); //Returns ID of 0x60 if successful
if (id != 0x60)
{
Serial.println(“Problem with BME280”);
}
else
{
Serial.println(“BME280 online”);
}
}
void loop() {
// put your main code here, to run repeatedly:
// put your main code here, to run repeatedly:
// Check to see if data is available
if (myCCS811.dataAvailable())
{
//Calling this function updates the global tVOC and eCO2 variables
myCCS811.readAlgorithmResults();
//printData fetches the values of tVOC and eCO2
Serial.print(" time[ms] ");
Serial.print(millis());
Serial.print(" TVOC[ppb] ");
Serial.print(myCCS811.getTVOC());
float BMEtempC = myBME280.readTempC();
float BMEhumid = myBME280.readFloatHumidity();
Serial.print(" temp
");
Serial.print(BMEtempC, 1);
Serial.print(" humidity[%] ");
Serial.print(BMEhumid, 0);
Serial.println();
//This sends the temperature data to the CCS811
myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);
}
else if (myCCS811.checkForStatusError())
{
Serial.println(myCCS811.getErrorRegister()); //Prints whatever CSS811 error flags are detected
}
delay(1000); //Wait for next reading
}
// printDriverError decodes the CCS811Core::status type and prints the
// type of error to the serial terminal.
// Save the return value of any function of type CCS811Core::status, then pass
// to this function to see what the output was.
void printDriverError( CCS811Core::status errorCode )
{
switch ( errorCode )
{
case CCS811Core::SENSOR_SUCCESS:
Serial.print("SUCCESS");
break;
case CCS811Core::SENSOR_ID_ERROR:
Serial.print("ID_ERROR");
break;
case CCS811Core::SENSOR_I2C_ERROR:
Serial.print("I2C_ERROR");
break;
case CCS811Core::SENSOR_INTERNAL_ERROR:
Serial.print("INTERNAL_ERROR");
break;
case CCS811Core::SENSOR_GENERIC_ERROR:
Serial.print("GENERIC_ERROR");
break;
default:
Serial.print("Unspecified error.");
}
}