So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Andi1802
#93922 Hello,
I am currently doing a project where I try to messure the CO2 and VOC. However I always get this error:

18:36:18.319 -> setup: CCS811 begin FAILED
18:36:18.319 -> setup: hardware version: FFFFFFFF
18:36:18.319 -> setup: bootloader version: FFFFFFFF
18:36:18.319 -> setup: application version: FFFFFFFF
18:36:18.319 -> setup: CCS811 start FAILED
18:36:18.319 -> CCS811: I2C error

I connected 3V3 with VCC, GND with GND, D1 with SCL, D2 with SDA and D3 with WAKE

This is the code I used. It is the same as Maarten Pennings code from the github CCS811 libary:
Code: Select all#include <Wire.h> // I2C library
#include "ccs811.h" // CCS811 library

// Wiring for ESP8266 NodeMCU boards: VDD to 3V3, GND to GND, SDA to D2, SCL to D1, nWAKE to D3 (or GND)

CCS811 ccs811(D3); // nWAKE on D3

void setup() {
// Enable serial
Serial.begin(115200);
Serial.println("");
Serial.println("setup: Starting CCS811 basic demo");
Serial.print("setup: ccs811 lib version: "); Serial.println(CCS811_VERSION);

// Enable I2C
Wire.begin();

// Enable CCS811
ccs811.set_i2cdelay(50); // Needed for ESP8266 because it doesn't handle I2C clock stretch correctly
bool ok= ccs811.begin();
if( !ok ) Serial.println("setup: CCS811 begin FAILED");

// Print CCS811 versions
Serial.print("setup: hardware version: "); Serial.println(ccs811.hardware_version(),HEX);
Serial.print("setup: bootloader version: "); Serial.println(ccs811.bootloader_version(),HEX);
Serial.print("setup: application version: "); Serial.println(ccs811.application_version(),HEX);

// Start measuring
ok= ccs811.start(CCS811_MODE_1SEC);
if( !ok ) Serial.println("setup: CCS811 start FAILED");
}

void loop() {
// Read
uint16_t eco2, etvoc, errstat, raw;
ccs811.read(&eco2,&etvoc,&errstat,&raw);

// Print measurement results based on status
if( errstat==CCS811_ERRSTAT_OK ) {
Serial.print("CCS811: ");
Serial.print("eco2="); Serial.print(eco2); Serial.print(" ppm ");
Serial.print("etvoc="); Serial.print(etvoc); Serial.print(" ppb ");

Serial.println();
} else if( errstat==CCS811_ERRSTAT_OK_NODATA ) {
Serial.println("CCS811: waiting for (new) data");
} else if( errstat & CCS811_ERRSTAT_I2CFAIL ) {
Serial.println("CCS811: I2C error");
} else {
Serial.print("CCS811: errstat="); Serial.print(errstat,HEX);
Serial.print("="); Serial.println( ccs811.errstat_str(errstat) );
}

// Wait
delay(1000);
}

I also tried to switch D3 and GND and therefor edit this line: CCS811 ccs811(D3);
to CCS811 ccs811(-1);
It also doesn't work.

Does anyone knows how to solve this problem or is it even possible that the CCS811 sensor is broken? If you have further questions there is an article where the same issue got discussed:
https://github.com/maarten-pennings/CCS811/issues/7