AKstudios / CCS811-library

This is a library for the CCS811 digital TVOC/eCO2 Sensor by CCMOSS/AMS
Apache License 2.0
24 stars 10 forks source link

Thank you #3

Open mshaz opened 7 years ago

mshaz commented 7 years ago

Tq for the great library. Does it gives only 2 values CO2 and TVOC? CO2 concentration : 16848 ppm TVOC concentration : 1075897647 ppb

I think something wrong it keeps giving this value. How many pins do i have to connect? I am using WEMOS D1 Mini

xxlukas42 commented 7 years ago

Hello mshaz, I had the same problem - I use Wemos D1 Pro and it seems this problem is related to usage of this sensor together with ESP8266, I use this basic sketch from Sparkfun link - I was able to detect I2C device fine, read values from registers such as STATUS, HW_ID, HW_VERSION fine but problem starts when I try switch the CCS811 state from boot to application mode (APP_START). My Wemos crash to soft-reset and I2C connected devices were not detected anymore.

I found out this discussion link and it seems ESP8266 is very sensitive to power and this sensor takes up to 30mA during measuring (application mode). See datasheet here: link

Please let me know if you solved this issue somehow. Right now I'm using Arduino Uno just to test the sensor and it seems the sensor is working fine.

mshaz commented 7 years ago

Thank you for your reply. I guess it won't work on nodemcu too?

xxlukas42 commented 7 years ago

Probably not but test it, I will let you know if it is working fine with ESP32 (now I'm waiting for the new Lolin32 board) I can also test it with Raspberry Pi 3. Definitely it is working fine with Arduino Uno and Mega (but I need something with wifi...)

What sensor board are you using? I have this combo one: link

mshaz commented 7 years ago

CFSUNBIRD CCS811 same thing with you. Would be nice if it works on WEMOS D1 coz i nd something small with WIFI too. I m waiting for my Raspberry pi Zero to arrive thru mail . Not sure how to make it work with a Pi. Seems difficult to get Pi Zero and Zero W here in my country.

xxlukas42 commented 7 years ago

Where are you from? I'm also thinking about RPi Zero.

mshaz commented 7 years ago

I am from Malaysia. I found one local supplier for this but i can only buy a unit as it is limited. Do you know where i can get more of RPi Zero and Zero W cheaply. Do let me know your progress with CCS811, I was thinking of making wearables with this that's why i chose Wemos D1 . I tried other codes from other sources also but not working. Almost given up on this.

xxlukas42 commented 7 years ago

I bought RPi 3 from local distributor for 44 USD and I see Zero for 15.3 USD here in Czechia. But maybe try some cheap chinese shops (Aliexpress, Banggood...)

That would be cool to have it as wearable! I was working on static air quality detector for meeting room. I'll try to solve it somehow...don't give up yet :) It seems the sensors returns HEATER_SUPPLY error which could confirm the reason. Qustion is if this problem couldn't be solved by adding of capacitor or switching of measurement cycle...I'll let you know if I discover something.

xxlukas42 commented 7 years ago

Hi there, I think I've just solved it...at least my own sketch returns promising data... I made sketch for Wemos D1 Pro and script for RPi (Python). Let me know if you want to test it.

ccs811

mshaz commented 7 years ago

Cool. Can i test it for Wemos D1 and RPi too. I just got my RPi Zero. I will update you with the results. Can you give the wiring diagram too. Thank you.

mshaz commented 7 years ago

I made this using MAX30100 and Wemos D1 Mini. Readings are not consistent. Could it be same issues with current like CCS811. I would like to have both runs together actually using Wemos D1 Mini. oxymeter

xxlukas42 commented 7 years ago

cool :-) actually the problem was with initiating I2C communication...where do you want to post the scripts? e-mail?

mshaz commented 7 years ago

yes please at brainersplace@gmail.com. Thank you.

digiservice2001 commented 7 years ago

xxlukas42! Please send me too the sketch for wemos d1. Thank You very much!! email: digiservice2001@gmail.com

ahmedriazku commented 7 years ago

Hi, I am also struggling with LGAQS-HT01 a combination of CCS811 and SI7021, typically the same as yours xxlukas42. I can run it on Arduino, I can get values for Humidity and Temp from SI7021 on Wemos but I cannot run CS811 on Wemos. Please help or send the code to me at ahmedriazku@yahoo.com. Thanks

xxlukas42 commented 7 years ago

Hello guys, I'm sending you to your emails latest version of my source-just note this is only beta version and I'm still testing it (that is the reason why the code is not public yet) so please let me know your observations. Thank you.

dielume commented 7 years ago

Hello Lukas, i recently bought wemos D1 pro and CCS811. I have the same problems with the i2c. Can you send me your code, i will really appreciate it. My email is diego.lume.a@gmail.com. Thanks

djdehaan commented 7 years ago

I use the CCS811 with an ESP8266 (Wemos D1), get perfect values, eg reacting to breathing very quickly.

I found out that after WAKE is brought LOW, it needs about 50us before you can do I2C transaction. So in the Lib I changed all calls to digitalWrite in digWriteWait and added this:

void CCS811::digWriteWait(uint8_t WAKE_PIN, bool VAL) {
  digitalWrite(WAKE_PIN, VAL);
  delayMicroseconds(60);
}

Now it works like a charm.

DJ

digiservice2001 commented 7 years ago

Hi DJ!

Could You share the working library?

Thank You!

Peter

----- Original Message ----- From: djdehaan To: AKstudios/CCS811-library Cc: digiservice2001 ; Comment Sent: Thursday, June 15, 2017 8:28 PM Subject: Re: [AKstudios/CCS811-library] Thank you (#3)

I use the CCS811 with an ESP8266 get perfect values, reacting to breathing very quickly.

I found out that after WAKE is brought LOW, it needs about 50us before you can do I2C transaction. So in the Lib I changed all calls to digitalWrite in digWriteWait and added this:

void CCS811::digWriteWait(uint8_t WAKE_PIN, bool VAL) { digitalWrite(WAKE_PIN, VAL); delayMicroseconds(60); } Now it works like a charm.

DJ

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

djdehaan commented 7 years ago

Attached: CCS811-library-update-DJ.zip

What I also changed is I removed the wire.begin() statement from the lib, so that I can do that myself and assign the right pins.

digiservice2001 commented 7 years ago

Still can not read right values... Please help me with the sketch what U use, and wire connections.

Thank You!!!

----- Original Message ----- From: djdehaan To: AKstudios/CCS811-library Cc: digiservice2001 ; Comment Sent: Thursday, June 15, 2017 10:07 PM Subject: Re: [AKstudios/CCS811-library] Thank you (#3)

Attached: CCS811-library-update-DJ.zip

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

digiservice2001 commented 7 years ago

Sorry, I don't reset the sensor after use your modified library. I can read correct values now... It's working well!!!

Thank You!!

----- Original Message ----- From: djdehaan To: AKstudios/CCS811-library Cc: digiservice2001 ; Comment Sent: Thursday, June 15, 2017 10:07 PM Subject: Re: [AKstudios/CCS811-library] Thank you (#3)

Attached: CCS811-library-update-DJ.zip

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

djdehaan commented 7 years ago

First I checked if it found the I2C address of the CCS811. Attached .ino does search and found mine only after I connected WAKE to D0 of the Wemos.

I2CScanner.zip

ahmedriazku commented 7 years ago

Hi DJ, I used your code with the CCS811_test.ino and get some very high values of CO2 in 6000 and VOC in millions. Where could i go wrong? I deleted the earlier master library of CCS811 and added your new library as well. Please help. 

On Friday, June 16, 2017 1:38 AM, djdehaan <notifications@github.com> wrote:

First I checked if it found the I2C address of the CCS811. Attached .ino does search and found mine only after I connected WAKE to D0 of the Wemos.I2CScanner.zip— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

djdehaan commented 7 years ago

Did you run the I2CScanner script and did it find the CCS811? With what address?

ahmedriazku commented 7 years ago

Thanks. I have now run the I2C Scanner and its giving many errors. I tested it about a week ago and it was giving me 0x40 and 0x5A as addresses. Now its all errors, I checked the connections and they are fine. Where could i go wrong?

On Friday, June 16, 2017 2:22 AM, djdehaan <notifications@github.com> wrote:

Did you run the I2CScanner script and did it find the CSS811? With what address?— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ahmedriazku commented 7 years ago

Sorry, I just checked, the ground pin was not connected and now i get this  I2C device found at address 0x40I2C device found at address 0x5a Am testing the CCS811 text ino and will get back.

On Friday, June 16, 2017 2:35 AM, riaz ahmed <ahmedriazku@yahoo.com> wrote:

Thanks. I have now run the I2C Scanner and its giving many errors. I tested it about a week ago and it was giving me 0x40 and 0x5A as addresses. Now its all errors, I checked the connections and they are fine. Where could i go wrong?

On Friday, June 16, 2017 2:22 AM, djdehaan <notifications@github.com> wrote:

Did you run the I2CScanner script and did it find the CSS811? With what address?— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

xxlukas42 commented 7 years ago

Hi there, i've just read the forum and saw you manage it somehow. I had the same issue with not responding sensor on I2C scanner and it helps me simply disconnect VCC from the sensor and connect it again.

ahmedriazku commented 7 years ago

Hi, again. I got the I2C scanner to give 0x40 and 0x5A as addresses. But when I run CCS811 text .ino i get these results: Error: Incorrect Hardware ID detected.Initialization failed.CO2 concentration : 65028 ppmTVOC concentration : 1075911796 ppb pl help.

On Friday, June 16, 2017 1:38 AM, djdehaan <notifications@github.com> wrote:

First I checked if it found the I2C address of the CCS811. Attached .ino does search and found mine only after I connected WAKE to D0 of the Wemos.I2CScanner.zip— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

djdehaan commented 7 years ago

Like xxlukas42 says: reset or power-off/on the device. I found that trick too. Am now looking into a routine that will do an automated hardware reset if the hardware ID is 0xFF.

ahmedriazku commented 7 years ago

HI, I guess your code wants the CCS811 WAK pin to be as shown here https://learn.sparkfun.com/tutorials/ccs811-air-quality-breakout-hookup-guide However my CCS811 is from Logoele called LGAQS-HT01 and it has 10 pins as here http://www.sereslink.com/UpFiles/image/20160826172927_9272.jpg Can you please identify which one is WAKE?

On Friday, June 16, 2017 11:36 AM, djdehaan <notifications@github.com> wrote:

Like xxlukas42 says: reset or power-off/on the device. I found that trick too. Am now looking into a routine that will do an automated hardware reset if the hardware ID is 0xFF.— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

djdehaan commented 7 years ago

Through elimination I would say C2D, but I cannot think a meaning of C2D like WAKE. Please check the documentation. The WAKE pin puts the CCS811 in sleep with very low power consumption. It is a pin directly on the CCS811 itself.

ahmedriazku commented 7 years ago

Hi, I read at an Arduino forum where martinayotte  explains in a discussion on some I2C sensors that you need to add Wire.begin(sda_pin, sclp_in) in order "To make it working on ESP8266, it needs to provide the pin numbers you are using " and I did that and bingo! it works straight away. So for people like me I am quoting the modified code here: /**/#include

include

define ADDR      0x5A//#define ADDR      0x5B#define WAKE_PIN  4

CCS811 sensor; void setup(){  Wire.begin(D2, D1);   Serial.begin(115200);  Serial.println("CCS811 test");  if(!sensor.begin(uint8_t(ADDR), uint8_t(WAKE_PIN)))    Serial.println("Initialization failed.");} void loop(){   //sensor.compensate(22.56, 30.73);  // replace with t and rh values from sensor  sensor.getData();  Serial.print("CO2 concentration : "); Serial.print(sensor.readCO2()); Serial.println(" ppm");  Serial.print("TVOC concentration : "); Serial.print(sensor.readTVOC()); Serial.println(" ppb");  Serial.println();  delay(2000);}

On Friday, June 16, 2017 3:55 PM, djdehaan <notifications@github.com> wrote:

Through elimination I would say C2D, but I cannot think a meaning of C2D like WAKE. Please check the documentation. The WAKE pin puts the CCS811 in sleep with very low power consumption. It is a pin directly on the CCS811 itself.— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

AKstudios commented 7 years ago

@djdehaan thanks for sharing the fix! I've now updated the library with a slight modification to your code. Hopefully it should work well for more people now.

ahmedriazku commented 7 years ago

Thanks AK, one issue remains and i hope you can fix it. The Logoele LGAQS-HT01 has two sensors, CCS811 and SI7021, the later for temp and humidity. When I write a code using the CCS811 test ino with one for SI7021 it seems there is a cinflict. SI7021 uses Wire.begin() while CCS811 uses Wire.begin(Sda,Scl). It gets compiled but gives odd values for SI7021. Can u help?

Get Outlook for Android

On Sat, Jun 17, 2017 at 10:53 AM +0500, "Akram Ali" notifications@github.com wrote:

@djdehaan thanks for sharing the fix! I've now updated the library with a slight modification to your code. Hopefully it should work well for more people now.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

AKstudios commented 7 years ago

@ahmedriazku I left the call to Wire.begin() in the code as this library is intended to be easily used with Arduino boards and the CCS811 sensor. Any other board or sensor would require modification of the code.

As suggested above, you can comment out the call to Wire.begin() in the library and add your own calls in the main code to make it compatible with other devices. I've not tried the sensor you mentioned, but I tested the code with breakouts for CCS811 and Si7021 on the same circuit and it runs fine.

ahmedriazku commented 7 years ago

Hi, I have now written a code that does not use the CCS811 library. It runs fine until I unplug the Wemos and when I replug and reload the code it gives odd values for CO2 and TVOC. Can you suggest what could be wrong. It appears that unplugging causes the SDA to be high and could not be brought to low until one uses another program, like yours, to make the SDA low. The attached code is:

include #define CCS811ADDR 0x5A  //#define ADDR      0x5B  CCS811 I2C address is 0x5A or 0x5B#define SI7021ADDR 0x40 // SI7021 I2C address is 0x40(64)

float humidity = 0;float temp = 0;float CO2 = 0;float TVOC = 0;#define WAKE_PIN D0 void setup()  {    Wire.begin(D2, D1); //define the SDA (D2) and SCL(D1) pins for Wemos/Nodemcu/Esp8266 setup     Serial.begin(9600);    pinMode(WAKE_PIN, OUTPUT);     digitalWrite(WAKE_PIN, 0);    delay(70);  Wire.beginTransmission(0x5A); // least significant bit indicates write (0) or read (1)  Wire.write(0xF4);  Wire.endTransmission();  digitalWrite(WAKE_PIN, HIGH);delay(60);    // sensor.begin(uint8_t(ADDR), uint8_t(WAKE_PIN));//    Serial.println("Initialization failed.");  } void loop()  {  delay(70);

  // temp and humidity part of loop     // Code for data access from SI7021     unsigned int data[4];    digitalWrite(WAKE_PIN, 0);    delay(60);    Wire.beginTransmission(SI7021ADDR);    Wire.write(0xF5); // Trigger humidity measurement command to register 0xF5 , its 2 byte register    Wire.endTransmission();    delay(500);       Wire.requestFrom(SI7021ADDR, 2); // Request 2 bytes of humidity data      if(Wire.available() == 2)       {        data[0] = Wire.read();        data[1] = Wire.read();      }      // Convert the humidity data      float humidity  = ((data[0] 256.0) + data[1]);      humidity = ((125 humidity) / 65536.0) - 6;     Wire.beginTransmission(SI7021ADDR);    Wire.write(0xF3); // Trigger temperature measurement command to 0xF3    Wire.endTransmission();    delay(500);     Wire.requestFrom(SI7021ADDR, 2); // Request 2 bytes of temp data      if(Wire.available() == 2)      {      data[0] = Wire.read();      data[1] = Wire.read();      }     // Convert the temp data        float temp  = ((data[0] 256.0) + data[1]);        float celsTemp = ((175.72 temp) / 65536.0) - 46.85;        float fahrTemp = celsTemp * 1.8 + 32;     // Output temp and humidity data to serial monitor      Serial.print("Humidity : ");      Serial.print(humidity);      Serial.println(" % RH");      Serial.print("Temperature : ");      Serial.print(celsTemp);      Serial.println(" C");       digitalWrite(WAKE_PIN, 1);  delay(60);    // Code for CCS811 to get CO2 and TVOC values      digitalWrite(WAKE_PIN, 0);      delay(60);      Wire.beginTransmission(CCS811ADDR);      Wire.write(0x02);   // Trigger CO2 and TVOC measurement command  0x02 , its a 4 byte register      Wire.endTransmission();           Wire.requestFrom(CCS811ADDR, 4); // Request 4 bytes of CO2 and TVOC data        if(Wire.available() == 4)        {        data[0] = Wire.read();        data[1] = Wire.read();        data[2] = Wire.read();        data[3] = Wire.read();        }        // Convert the data by shifting the registers 8 bit        float CO2 = (data[0]<<8) + data[1];        float TVOC = (data[2]<<8) + data[3];      // Output temp and humidity data to serial monitor      Serial.print("CO2 : ");      Serial.print(CO2);      Serial.println(" ppm ");      Serial.print("TVOC : ");      Serial.print(TVOC);      Serial.println(" ppb");      digitalWrite(WAKE_PIN, 1); delay(60);}

On Saturday, June 17, 2017 11:03 AM, riaz ahmed <ahmedriazku@yahoo.com> wrote:

Thanks AK, one issue remains and i hope you can fix it. The Logoele LGAQS-HT01 has two sensors, CCS811 and SI7021, the later for temp and humidity. When I write a code using the CCS811 test ino with one for SI7021 it seems there is a cinflict. SI7021 uses Wire.begin() while CCS811 uses Wire.begin(Sda,Scl). It gets compiled but gives odd values for SI7021. Can u help?

Get Outlook for Android

On Sat, Jun 17, 2017 at 10:53 AM +0500, "Akram Ali" notifications@github.com wrote:

@djdehaan thanks for sharing the fix! I've now updated the library with a slight modification to your code. Hopefully it should work well for more people now.— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ahmedriazku commented 7 years ago

Finally got the LGAQS-HT01 to work with Wemos ESP826 12E ! Last confusion about the odd values on replugging Wemos was removed after we looked into CCS811 library of AKStudios and added in Setup to reset 0xF4 and 0x01 registers of CCS811. 

/***  June 18 2017  This is an example that uses Wemos ESP8266 12E as   microcontroller and sensor Logoele LGAQS-HT01   (a combination of CCS811 digital TVOC/eCO2 sensor   by CCMOSS/AMS and SI7021 by Silicon Instruments).   The code is largely based on Wire and SI7021   Readsensor.ino example that gives Temp and Humidity values.  The code was further modified to get CO2 and TVOC   values from the same architecture of SI7021 Readsensor.ino  It uses Wire.begin library so as to indicate   to microcontroller the pins of sda and scl. The CCS811  library was not used in this code.     VDD -- 3.3V  GND -- G  SDA -- D2  SCL -- D1  WAK/C2D -- D0  ****/

include #define CCS811ADDR 0x5A  //#define ADDR      0x5B  CCS811 I2C address is 0x5A or 0x5B#define SI7021ADDR 0x40 // SI7021 I2C address is 0x40(64)#define WAKE_PIN D0

float humidity = 0;float temp = 0;float CO2 = 0;float TVOC = 0;

void setup()  {    Wire.begin(D2, D1); //define the SDA (D2) and SCL(D1) pins for Wemos/Nodemcu/Esp8266 setup     Serial.begin(9600);    pinMode(WAKE_PIN, OUTPUT);     digitalWrite(WAKE_PIN, 0);      delay(70);    Wire.beginTransmission(0x5A); // this resets the SDA    Wire.write(0xF4);    Wire.endTransmission();    digitalWrite(WAKE_PIN, HIGH);      delay(60);     digitalWrite(WAKE_PIN, LOW);      delay(60);    Wire.beginTransmission(0x5A);    Wire.write(0x01);    Wire.write(0x10);  // constant power mode, IAQ measurement every second    Wire.endTransmission();    digitalWrite(WAKE_PIN, HIGH);      delay(60); } void loop()  {  // Temp and humidity part of loop for SI7021     unsigned int data[4];    digitalWrite(WAKE_PIN, 0);      delay(60);    Wire.beginTransmission(SI7021ADDR);    Wire.write(0xF5); // Trigger humidity measurement command to register 0xF5 , its 2 byte register    Wire.endTransmission();      delay(60);       Wire.requestFrom(SI7021ADDR, 2); // Request 2 bytes of humidity data      if(Wire.available() == 2)       {        data[0] = Wire.read();        data[1] = Wire.read();      }      // Convert the humidity data      float humidity  = ((data[0] 256.0) + data[1]);      humidity = ((125 humidity) / 65536.0) - 6;     Wire.beginTransmission(SI7021ADDR);    Wire.write(0xF3); // Trigger temperature measurement command to 0xF3    Wire.endTransmission();    delay(60);     Wire.requestFrom(SI7021ADDR, 2); // Request 2 bytes of temp data      if(Wire.available() == 2)      {      data[0] = Wire.read();      data[1] = Wire.read();      }     // Convert the temp data        float temp  = ((data[0] 256.0) + data[1]);        float celsTemp = ((175.72 temp) / 65536.0) - 46.85;        float fahrTemp = celsTemp * 1.8 + 32;     // Output temp and humidity data to serial monitor      Serial.print("Humidity : ");      Serial.print(humidity);      Serial.println(" % RH");      Serial.print("Temperature : ");      Serial.print(celsTemp);      Serial.println(" C");      digitalWrite(WAKE_PIN, 1); // make SDA high        delay(600);  // CO2 and TVOC part of loop for CCS811       digitalWrite(WAKE_PIN, 0); //make SDA low         delay(60);      Wire.beginTransmission(CCS811ADDR);      Wire.write(0x02);   // Trigger CO2 and TVOC measurement command  0x02 , its a 4 byte register      Wire.endTransmission();           Wire.requestFrom(CCS811ADDR, 4); // Request 4 bytes of CO2 and TVOC data        if(Wire.available() == 4)        {        data[0] = Wire.read();        data[1] = Wire.read();        data[2] = Wire.read();        data[3] = Wire.read();        }        // Convert the data by shifting the registers 8 bit        float CO2 = (data[0]<<8) + data[1];        float TVOC = (data[2]<<8) + data[3];      // Output temp and humidity data to serial monitor      Serial.print("CO2 : ");      Serial.print(CO2);      Serial.println(" ppm ");      Serial.print("TVOC : ");      Serial.print(TVOC);      Serial.println(" ppb");      digitalWrite(WAKE_PIN, 1); // make SDA high        delay(600);}

On Saturday, June 17, 2017 11:25 AM, Akram Ali <notifications@github.com> wrote:

@ahmedriazku I left the call to Wire.begin() in the code as this library is intended to be easily used with Arduino boards and the CCS811 sensor. Any other board or sensor would require modification of the code.As suggested above, you can comment out the call to Wire.begin() in the library and add your own calls in the main code to make it compatible with other devices. I've not tried the sensor you mentioned, but I tested the code with breakouts for CCS811 and Si7021 on the same circuit and it runs fine.— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

maddhin commented 7 years ago

Hi,

I'm trying to get the CJMCU-811 CCS811 board to work but something is wrong:

Usually, after I flashed the Wemos, the sensor works. But after a while, I get an odd reading which is frozen (does not change anymore) like CO2 concentration : 1021 ppm TVOC concentration : 65021 ppb or CO2 concentration : 253 ppm TVOC concentration : 65021 ppb

or it goes straight to CO2 concentration : 1140914176 ppm TVOC concentration : 1103106867 ppb

After reset/restart I get: Error: Firmware still in boot mode. Error ID: 3 Initialization failed.

It looks like something crashed. The only thing to fix this seems to be to re-flash.

Does anybody have an idea how to fix this or point me into a direction as to how the problem could be solved? THANKS!

dielume commented 7 years ago

Hi @maddhin,

I also had that problem, i found a lot in many blogs pages like Sparkfun, Adafruit. I can solve the problem adding a Clock Stretch Limit , with this change the sensor is working normally for more than 2 months. Make sure that only start the I2C once and then insert the Clock Stretch like:

Wire.begin(); Wire.setClockStretchLimit(2000);

I hope I've helped :)

maddhin commented 7 years ago

@dielume Thanks a lot - I'm not quite sure how to apply this. I add the code and run it for a short while and then remove the Clock stretch and flash again?

I found something like this in a Chinese forum (Google translation):

"chip sends 0XF4 instructions have to wait extra 180uS to access it, and I2C time between each byte that is sent to more than 50US"

So it seems to be somehow related to "timing" (I'm a noob, so not sure what that really means).

On https://download.ams.com/ENVIRONMENTAL-SENSORS they have all the datasheets etc for the sensor. Especially the CC-000619-DS document should be useful (https://cdn.sparkfun.com/datasheets/BreakoutBoards/CCS811_Programming_Guide.pdf), or? Shouldn't that give any hint as how to solve this? Did anybody try to contact AMS re this?

maddhin commented 7 years ago

@dielume I added your 2 lines in the setup and removed it after one run. This seems to work! THANK YOU! I already thought my sensor broke...

I found this line Wire.begin(TWI_PINS_20_21); // set master mode using pins 20 (SDA) and 21 (SCL) Wire.setClock(400000); // I2C frequency at 400 kHz delay(1000);

at https://github.com/kriswiner/CCS811 - which seems to be a C++ written library for the CCS811. I do not know whether this is helpful to make this library "perfect" so noobs like me can handle the CCS811 :)

maddhin commented 7 years ago

Hm, sadly, after ~20-60min the CCS811 showed the same problems again. Only after reflashing a few(!) times with the Wire.setClockStretchLimit(2000); in the setup(); fixes the problem again. I still think the library is not ready for production;)

EDIT: even with reflashing, I cannot get the CCS811 to work again now :(

pushpa66 commented 7 years ago

I have corrected some issues with editing library. Check it here https://github.com/pushpa66/CCS811

maddhin commented 7 years ago

I got this library here working after I moved the WAK pin from D0 to D3 on the Wemos. There seem to have been some startup issues. Practically, the main issue I have with this library here is that it always seems to need a reset after giving the Wemos power. Without reset, the CCS811 goes to 65000. Is this fixed in the new @pushpa66 library? The new library is no fork, or?

maddhin commented 7 years ago

PS: this library here I only got working with changing the twi_setClockStretchLimit(230). Does the new library fix this? I would love to change the twi_setClockStretchLimit(460) back to 230 just to make sure other library or what not are not influenced.

pushpa66 commented 7 years ago

Actually modified library should be used according to my example.. Try it.. I test it properly with ESP32. Only library cannot handle this problem. I will try to fix it in library itself. Practically usage of D0 is not good. It is used to handle special tasks . Try with another pin.

maddhin commented 7 years ago

@pushpa66 : just to make sure to understand: so the twi_setClockStretchLimit(460) is still necessary?

Ya, also found this out about D0 but somebody, somewhere recommended it... I guess that was a noob like me... :)

Will give your library a try over the weekend. Thanks for the work anyway!!!

pushpa66 commented 7 years ago

actually I have not studied about twi_setClockStretchLimit(460) thing. I can test my example with wemos D1. It works fine. DO NOT defend on the library. We have to add some trick on program. Follow my code itself. You will be able to understand.. https://github.com/pushpa66/CCS811/tree/master/CCS811_Example_WeMos_D1

martin072 commented 7 years ago

Hi,

Sadly to say I am experiencing the same issues with a WeMos D1 R2. I have a CCS811 combined with a HDC1080, and the CCS811 seems to show the same behaviours as described after a few minutes of running.. @pushpa66 I tried your library, but after a while I get strange values and need to power off the unit.. I also tried the clock settings, but no joy... Any other solutions?

pushpa66 commented 7 years ago

Did you use my example code?

On Oct 25, 2017 3:20 AM, "martin072" notifications@github.com wrote:

Hi,

Sadly to say I am experiencing the same issues with a WeMos D1 R2. I have a CCS811 combined with a HDC1080, and the CCS811 seems to show the same behaviours as described after a few minutes of running.. @pushpa66 https://github.com/pushpa66 I tried your library, but after a while I get strange values and need to power off the unit.. I also tried the clock settings, but no joy... Any other solutions?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AKstudios/CCS811-library/issues/3#issuecomment-339143731, or mute the thread https://github.com/notifications/unsubscribe-auth/AQyrmwLJq_sgGvTLY3soX-0D3AO4X4Tvks5svluJgaJpZM4NKkah .