Coder Social home page Coder Social logo

Comments (15)

maarten-pennings avatar maarten-pennings commented on July 23, 2024

Hmm, not sure what is going on.
I do know the CCS811 requires clock stretching, and that not all controllers (I2C masters) support that.
For example, I used an ESP8266, and some extra waits are required (built-in in the lib).

What I do see is that your controller (which MCU is that by the way) does see the CCS811.
We do get the correct hardware version fro example.
So that is good.

But the first status lines are bad. You get
errstat=0=--vhxmrwf--ad-ie
but you should get something like
errstat=90=--vhxmrwF--Ad-ie
The "A" flag must be 1, it means that the internal memory contains a valid application.
That flag can never be 0 (it would mean you erased the memory, and no operation is possible).
The "F" flag must be 1 at this point in time. It means there is a valid application, and the the bootloader started it. A 0 means the chip is still in bootloader mode.

Since the next line is ok, and you even get data sometimes, I think the chip has a valid app A-hi and that app is running F-hi, but the (I2C) communication has errors.

  • what MCU are you using
  • do you have I2C pull-ups
  • are you using set_i2cdelay()
  • what I2C bus speed are you using
  • do you have an I2C analyzer (like Saleae) to check the I2C traffic?
  • what is the link to the Adafruit library you are using?
  • I do not have the CCS811 board you have.. . could you send me one?

from ccs811.

taunoe avatar taunoe commented on July 23, 2024

I have this MCU: https://www.aliexpress.com/item/1PCS-Wireless-module-CH340-NodeMcu-V3-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/32665100123.html

I do not have i2C pull-ups. I assumed they are on board. All other things are working: i2c display and HTU21D sensor. But i can add them and see does they change something.

I used library default example sketch. Nothing changed.

I can use oscilloscope. If needed.

Adafruit library: https://github.com/adafruit/Adafruit_CCS811/

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

That is strange - I have (at least at first sight) exactly the same board as you.
The bad news is that ESP8266 is bad a clock stretching - but for me the lib is working on ESP8266.

I believe the ESP8266 has internal pull-ups, but weak ones, and they only become active when wire.begin() is called, which causes some "bus spikes" during startup. Adding pull-ups has helped me in the past in some cases. You might try, but I don't think it is the cause of your problems.

Because you do get some sensible output now and then but nonsens in other cases, I still suspect the I2C communication (hence a bus trace would be nice).

You said the Adafruit lib does work with CCS811, but you have other problems with it. What does that mean precisely? CCS811 is always working with that lib, but you have problems elsewhere (humidity sensor/oled). Or does the Adafruit lib also cause problems with CCS811? I see the Adafruit lib is using Wire.setClockStretchLimit(500); maybe that helps.

from ccs811.

taunoe avatar taunoe commented on July 23, 2024

When I use CCS811 Adafruit library it works for some time: 30m or 3h. Then i get eCO2 reading 39040ppm and in next loop i will lost connection with CCS811.
I added your I2C bus clear library. All other i2C devices will keep working. CCS811 will not respond and recovers only when i manually restart MCU.

I have now second similar CCS811 + 10K pull-ups. Your library works same way like before.
I will test now does pull-ups fix my problem or does one CCS811 is just bad.

btw. From one of your example i learned how to use thingspeak.com. Thank You!

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

from ccs811.

taunoe avatar taunoe commented on July 23, 2024

1.After i added pull-ups it seems to be more stable but not error free. For long time it was always same number (39040) but now i am not sure anymore.

One recorded error: https://imgur.com/a/nRB0H6Y

My reset is now this:

else{
Serial.println("CCS811 reading ERROR!");
I2Cbus_clear(SDA,SCL);
Wire.begin();
delay(100);
digitalWrite(CCSRESET, LOW);
delay(300);
digitalWrite(CCSRESET, HIGH);
if(!ccs.begin()){
Serial.println("Failed to restart CCS811!");
while(1) delay(1);
}
}

After that CCS811 works again. And its resolves the problem for me.

  1. I'm testing now your library with Nano (Atmega328p Old Bootloader).
    2.1 There seems to be some typos:
    file:ccs811.h line 64 and 65
    ccs811.cpp line 278 and 289
    Should be uint16_t not uint16

2.2 First it worked the same way. Lot of waiting before i get data:

Starting CCS811 basic demo
init: hardware version: 12
init: bootloader version: 1000
init: application version: 1100
CCS811: errstat=0=--vhxmrwf--ad-ie
CCS811: errstat=0=--vhxmrwf--ad-ie
CCS811: waiting for (new) data
CCS811: waiting for (new) data

After i added delay(500) on beginning. I get more data. 1000 is waiting free (+1000 at the end).

CCS811: eco2=400 ppm etvoc=0 ppb
CCS811: eco2=403 ppm etvoc=0 ppb
CCS811: waiting for (new) data
CCS811: eco2=400 ppm etvoc=0 ppb
CCS811: waiting for (new) data
CCS811: eco2=400 ppm etvoc=0 ppb
CCS811: eco2=400 ppm etvoc=0 ppb
CCS811: waiting for (new) data
CCS811: eco2=400 ppm etvoc=0 ppb
CCS811: eco2=409 ppm etvoc=1 ppb

My testing is been to short to say does CCS811 error appears or not.

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

(1a) The problem of a CCS811 reset, is that you loose the internally maintained baseline.
(1b) With Serial.printf("setup: I2C bus: %s\n", I2Cbus_statusstr(I2Cbus_clear(SDA,SCL))) you can see what bus clear actually did.
(2) I fixed the typos (and some warnings)

I would like to play with your board myself...

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

I would like to play with your board myself...

I ordered one chinese clone

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

After quite some research, I found a bug in the ESP8266 core libraries, which caused problems when an I2C devices stretches the clock - just as CCS811 does.

See the last paragraph of the ESP8266 section in the readme. You might want to try that! Solved all my problems in the CCS811 driver.

from ccs811.

taunoe avatar taunoe commented on July 23, 2024

Thank You. I will try it.

from ccs811.

taunoe avatar taunoe commented on July 23, 2024

I've been testing this for a few days now and I think this will fix the problem with CCS811!

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

It seems my proposed change for the i2c library is accepted, so when there is a new release of the esp8266 library or should work.

Are you happy, can I close this issue?

from ccs811.

taunoe avatar taunoe commented on July 23, 2024

Yes i am happy!

from ccs811.

maarten-pennings avatar maarten-pennings commented on July 23, 2024

closing

from ccs811.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.