Environmental Combo CCS811/BME280 with the bug from Guthub

Can you guys help the bug from the code? I can’t run from Arduino IDE.

/*

Read both CCS811 and BME280 sensors at same time

By: Nathan Seidle

SparkFun Electronics

Date: April 6th, 2017

License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

Works with SparkFun combo board https://www.sparkfun.com/products/14241

Enjoy this code? Buy a board and help support SparkFun!

Let’s read both sensors at the same time!

Outputs CO2, TVOC, temperature, humidty, and pressure.

Hardware Connections (Breakoutboard to Arduino):

Attach a Qwiic Shield to your RedBoard, Photon, or ESP32.

Plug the Qwiic Air Quality Combo board into one of the connectors

Serial.print it out at 9600 baud to serial monitor.

*/

#include <Wire.h>

#include “SparkFunBME280.h” //Library for BME280 from library manager or https://github.com/sparkfun/SparkFun_BM … no_Library

#include “SparkFunCCS811.h”

#define CCS811_ADDR 0x5B

CCS811 myCCS811(CCS811_ADDR);

BME280 myBME280; //Global sensor object for BME280

//Global variables obtained from the two sensors

unsigned int tVOC = 0;

unsigned int CO2 = 0;

float tempf = 0;

float humidity = 0;

float pressureInHg = 0;

void setup()

{

Serial.begin(9600);

Serial.println(“CCS811+BME280 Read Example”);

Wire.begin();//initialize I2C bus

CCS811Core::status returnCode = myCCS811.begin();

if (returnCode != CCS811Core::SENSOR_SUCCESS)

{

Serial.println(“Problem with CCS811”);

printDriverError(returnCode);

}

else

{

Serial.println(“CCS811 online”);

}

//Setup the BME280 for basic readings

myBME280.settings.commInterface = I2C_MODE;

myBME280.settings.I2CAddress = 0x77;

myBME280.settings.runMode = 3; // 3, Normal mode

myBME280.settings.tStandby = 0; // 0, 0.5ms

myBME280.settings.filter = 0; // 0, filter off

myBME280.settings.tempOverSample = 1;

myBME280.settings.pressOverSample = 1;

myBME280.settings.humidOverSample = 1;

delay(10); //Give BME280 time to come on

//Calling .begin() causes the settings to be loaded

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()

{

if (myCCS811.dataAvailable()) //Check to see if CCS811 has new data (it’s the slowest sensor)

{

myCCS811.readAlgorithmResults(); //Read latest from CCS811 and update tVOC and CO2 variables

//getWeather(); //Get latest humidity/pressure/temp data from BME280

printData(); //Pretty print all the data

}

else if (myCCS811.checkForStatusError()) //Check to see if CCS811 has thrown an error

{

Serial.println(myCCS811.getErrorRegister()); //Prints whatever CSS811 error flags are detected

}

delay(2000); //Wait for next reading

}

//Print CO2, TVOC, Humidity, Pressure and Temp

void printData()

{

Serial.print(" CO2[");

Serial.print(myCCS811.getCO2());

Serial.print(“]ppm”);

Serial.print(" TVOC[");

Serial.print(myCCS811.getTVOC());

Serial.print(“]ppb”);

Serial.print(" temp[");

Serial.print(myBME280.readTempC(), 1);

Serial.print(“]C”);

//Serial.print(" temp[");

//Serial.print(myBME280.readTempF(), 1);

//Serial.print(“]F”);

Serial.print(" pressure[");

Serial.print(myBME280.readFloatPressure(), 2);

Serial.print(“]Pa”);

//Serial.print(" pressure[");

//Serial.print((myBME280.readFloatPressure() * 0.0002953), 2);

//Serial.print(“]InHg”);

//Serial.print(“altitude[”);

//Serial.print(myBME280.readFloatAltitudeMeters(), 2);

//Serial.print(“]m”);

//Serial.print(“altitude[”);

//Serial.print(myBME280.readFloatAltitudeFeet(), 2);

//Serial.print(“]ft”);

Serial.print(" humidity[");

Serial.print(myBME280.readFloatHumidity(), 0);

Serial.print(“]%”);

Serial.println();

}

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.”);

}

}

Without more information about what goes wrong, when does it go wrong, what are error messages (if any) what have you tried… we can’t help.

Sorry about that. Last line of the error received is:

variable or field ‘printDriverError’ declared void

Tried it… no error.

For which board do you compile? Just try to compile for another board (even if you don’t have it) compiling should work.

May i see your code? A lot of people got the same bug. i also tried with different board(Arduino Uon, Nano 33 iot, mini)

I have used your code, copy /paste NO change. Tried different boards… no error. ArduinoIDE 1.8.16. Looks there is a problem in your IDE environment. Try to reinstall different parts.

P.s.

Next time posting make sure to select ’ full editor / preview’ and put </> around your code. The markup will stay the same and readable

Could you send your screenshot, I tried with Arduino 1.8.16 but it’s the same bug

attached used sketch

and results

Linking everything together…

/home/paul/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,–gc-sections -mmcu=atmega328p -o /tmp/arduino_build_625203/sketch_may15a.ino.elf /tmp/arduino_build_625203/sketch/sketch_may15a.ino.cpp.o /tmp/arduino_build_625203/libraries/Wire/Wire.cpp.o /tmp/arduino_build_625203/libraries/Wire/utility/twi.c.o /tmp/arduino_build_625203/libraries/SparkFun_BME280/SparkFunBME280.cpp.o /tmp/arduino_build_625203/libraries/SPI/SPI.cpp.o /tmp/arduino_build_625203/libraries/SparkFun_CCS811_Arduino_Library-master_esp32/SparkFunCCS811.cpp.o /tmp/arduino_build_625203/libraries/SparkFun_CCS811_Arduino_Library-master_esp32/SoftWire/twi.c.o /tmp/arduino_build_625203/libraries/SparkFun_CCS811_Arduino_Library-master_esp32/SoftWire/SoftWire.cpp.o /tmp/arduino_build_625203/core/core.a -L/tmp/arduino_build_625203 -lm

/home/paul/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_625203/sketch_may15a.ino.elf /tmp/arduino_build_625203/sketch_may15a.ino.eep

/home/paul/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_625203/sketch_may15a.ino.elf /tmp/arduino_build_625203/sketch_may15a.ino.hex

Using library Wire at version 1.0 in folder: /home/paul/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire

Using library SparkFun_BME280 at version 2.0.9 in folder: /home/paul/Arduino/libraries/SparkFun_BME280

Using library SPI at version 1.0 in folder: /home/paul/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/SPI

Using library SparkFun_CCS811_Arduino_Library-master_esp32 at version 1.0.7 in folder: /home/paul/Arduino/libraries/SparkFun_CCS811_Arduino_Library-master_esp32

/home/paul/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /tmp/arduino_build_625203/sketch_may15a.ino.elf

Sketch uses 11762 bytes (36%) of program storage space. Maximum is 32256 bytes.

Global variables use 743 bytes (36%) of dynamic memory, leaving 1305 bytes for local variables. Maximum is 2048 bytes.

sketch_may15a.zip (1.59 KB)

May i know which borad were you used for tesing

Arduino Uno…

this is what i got same borad and same version of the system:

///// /private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:95:36: error: variable or field ‘printDriverError’ declared void

void printDriverError( CCS811Core::status errorCode )

^~~~~~

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:95:36: error: ‘status’ is not a member of ‘CCS811Core’

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino: In function ‘void setup()’:

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:18:13: error: ‘status’ is not a member of ‘CCS811Core’

CCS811Core::status returnCode = myCCS811.begin();

^~~~~~

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:19:5: error: ‘returnCode’ was not declared in this scope

if (returnCode != CCS811Core::SENSOR_SUCCESS)

^~~~~~~~~~

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:19:31: error: ‘SENSOR_SUCCESS’ is not a member of ‘CCS811Core’

if (returnCode != CCS811Core::SENSOR_SUCCESS)

^~~~~~~~~~~~~~

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:22:1: error: ‘printDriverError’ was not declared in this scope

printDriverError(returnCode);

^~~~~~~~~~~~~~~~

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino: At global scope:

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:95:36: error: variable or field ‘printDriverError’ declared void

void printDriverError( CCS811Core::status errorCode )

^~~~~~

/private/var/folders/rj/1zgtr70j3lb03hztfp7t7tlc0000gn/T/.arduinoIDE-unsaved2023415-61488-onzwri.kjc7/sketch_may15c/sketch_may15c.ino:95:36: error: ‘status’ is not a member of ‘CCS811Core’

exit status 1

Compilation error: variable or field ‘printDriverError’ declared void

So the problem is in the Sparkfun CCS811 driver, uninstall the Sparkfun CCS811 driver and re-install it.

In the file SparkFunCCS811.h around line 70 the return values are defined:

    // Return values
    typedef enum
    {
        SENSOR_SUCCESS,
        SENSOR_ID_ERROR,
        SENSOR_I2C_ERROR,
        SENSOR_INTERNAL_ERROR,
        SENSOR_GENERIC_ERROR
        //...
    } status;

Either this is missing or corrupt in your driver.