Note: I have seen this same issue via Arduino IDE, and CircuitPython, on both ans 8266 Feather and an M0 Express.
At this point I have the sensor on an 8266 Feather under the Arduino IDE.
The issue is that after running for some time (minutes to hours) the sensor will hang up - and a read attempt will result in a returned status of False (255).
This indicates that during a read attempt, the DAT_READY Flag is not set but the code always polls for the DATA_READY being set before attempting the read.
To get this failure, The poll but be getting DATA_READY True then when it goes to read, somehow DATA_READY had gone back to false. I suspect that the senor has just hung entirely and is not responding.
I am able to usually get it working again by toggling the RESET line on the CSS811 and then re-initializing.
If the re-init fails, I toggle the 8266 RST line to reset the whole thing. Somethings this works...
Here is the read section of my sketch. As you can see, it polls for the data to be available before reading. Every time this fails, the status is reported as 255 which indicates the data is not ready. A real "error" reading would have a different value.
Has anyone run one of these for an extended period of time without any errors? I'll never get it to complete the 48 hour "burn" in at this rate ;-)
Is this a flaky sensor?
Code: Select all
void get_reading()
{
oled.setCursor(0,0);
if(ccs.available()){
oled.clearDisplay();
float temp = ccs.calculateTemperature();
uint8_t ccs_stat;
if(!(ccs_stat=ccs.readData())){
oled.print("eCO2: ");
Serial.print("eCO2: ");
eCO2 = ccs.geteCO2();
oled.print(eCO2);
Serial.print(eCO2);
oled.print(" ppm\nTVOC: ");
Serial.print(" ppm, TVOC: ");
float TVOC = ccs.getTVOC();
oled.print(TVOC);
Serial.print(TVOC);
Serial.print(" ppb Temp:");
oled.print(" ppb\nTemp: ");
Serial.println(temp);
oled.println(temp);
oled.display();
}
else{
Serial.println("ERROR!");
Serial.println(ccs_stat);
oled.print("ERROR!");
oled.display();
digitalWrite(RESET, LOW); // Pull RESET LOW
delay(250);
digitalWrite(RESET, HIGH); // set RESET line HIGH
delay(250);
if(!ccs.begin()){
Serial.println("sensor not responding - attempting hard reset.");
digitalWrite(RST, LOW); // Pull RST LOW
while(1);
}
}
}
delay(500);
}