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

User avatar
By QuickFix
#78834 Are you sure this is the sketch that corresponds to the output?

I don't see the "CCS811 Basic Example [...] .begin() returned with an error." error string in the sketch, nor do I see the very first "CCS811 test" message in the sketch printed on serial. :?
And if this sketch were the right one: there are (at least) two while-loops in setup() that will choke your watchdog if the sensor isn't found or can't be calibrated. :idea:
Code: Select allwhile(1);
[...]
while(!ccs.available());


To me it looks like you're trying to use an Arduino sketch, which in itself is fine most of the time, but you do have to verify the code and make it compatible for the ESP8266, since there are some (minor) differences in both hardware- as software-properties.
User avatar
By Rerode
#78840 Thanks for the reply's
I made a mistake in the OP. Had the wrong error output in it( tryed twoarduino codes and the output whas from a other) i fixed this, but the error is almost the same.

I tryed adding delays but don't no if i did it correctly.
But then i receive the same error message

The Arduino scats i use is from Adafruit examples.


Code: Select all#include "Adafruit_CCS811.h"

Adafruit_CCS811 ccs;

void setup() {
  delay(5000);
  Serial.begin(9600);
  delay(5000);
  Serial.println("CCS811 test");
  delay(5000);
  if(!ccs.begin()){
    delay(5000);
    Serial.println("Failed to start sensor! Please check your wiring.");
    while(1);
    delay(5000);
  }

  //calibrate temperature sensor
  while(!ccs.available());
  float temp = ccs.calculateTemperature();
  ccs.setTempOffset(temp - 25.0);
  delay(5000);
}

void loop() {
  if(ccs.available()){
    delay(5000);
    float temp = ccs.calculateTemperature();
    delay(5000);
    if(!ccs.readData()){
      Serial.print("CO2: ");
      delay(5000);
      Serial.print(ccs.geteCO2());
      delay(5000);
      Serial.print("ppm, TVOC: ");
      delay(5000);
      Serial.print(ccs.getTVOC());
      delay(5000);
      Serial.print("ppb   Temp:");
      delay(5000);
      Serial.println(temp);
      delay(5000);
    }
    else{
      Serial.println("ERROR!");
      while(1);
    }
  }
  delay(500);
}
User avatar
By QuickFix
#78842 Okay, some background theory here.

The ESP is (at least in hardware) NOT the same as an ATMEL (as used in an Arduino).
Where the ATMEL controller only has 1 flow of code to worry about, the ESP has to keep two flows (or "Processes") of code running "At the same time".
One "Process" is responsible for the WiFi-stack (everything related to communicating over WiFi) and this process is "Hidden", while the other "Process" is available to you, the programmer: in here your sketch is stored.

The WiFi process has a timer (the "Watchdog Timer") built in that will be set to 0 when the process is given time to execute.
However every clock-tick the WiFi process is not running, this timer gets incremented.
As long as the timer doesn't reach a certain value (the "Time-out value"), the WiFi-stack is happy and everything is fine.
But... if the timer does reach the time-out value, the watchdog timer will trip and a watchdog timer reset (WDT) will occur (the message you see in the log).

Since the Arduino core for the ESP isn't a pre-emptive multitasker (and thus not able to automagically run both the WiFi-process as the process of your sketch at the same time), help from your code is needed to keep both processes running simultaneously.

This is done by regularly handing control over to the WiFi-process from within your sketch, by issuing a "yield()" command.

Since (from a µC's perspective) pausing your own code is a waste of time (which can be also used to let the WiFi-process do its thing), you can also use the delay() command.
Effectively even delay(0) would be okay, but since delay() is often used in "Standard" code to pause for a while, behind the scenes it's (kind of) transposed over the yield() command, to give the WiFi-stack as much "Air to breathe" as possible.


So, back to your sketch:
  • It's not necessary to issue 5 second delays.
  • Be sure that the ports defined in your sketch actually reflect reality (i.e. double-check that a sensor, motor, LED or display is actually correctly connected to said port and working).
  • Don't use tight loops (like while(1);) without giving processing time to the WiFi stack (instead use while(1) { yield() };)
  • Always copy and paste the exact sketch and resulting log to this forum; do not report back with "Y results into almost the same as X", since it really doesn't.
    Please see my signature about assuming things. :idea:
  • Last but not least: read, read, try and try again and when in doubt: just ask
User avatar
By Rerode
#78849 Really thanks for the explanation. I will go read up on that end get some more understanding of it
Next time i will dubble check before i post the code..