CCS811/BME280 (Qwiic) Environmental Combo Breakout problem

I’m using the code exactly as described in the hookup guide, but after a few minutes I start getting “255” as shown below. A reset will get it working again, but just for a few minutes. Is this a bad breakout board?

CO2[423]ppm TVOC[3]ppb temp[74.1]F pressure[101255.23]Paaltitude[19.06]ft humidity[32]%

Applying new values (deg F, %): 74.14,32.27

CO2[408]ppm TVOC[1]ppb temp[74.1]F pressure[101256.89]Paaltitude[18.61]ft humidity[33]%

Applying new values (deg F, %): 74.14,32.62

CO2[413]ppm TVOC[1]ppb temp[74.1]F pressure[101254.91]Paaltitude[19.15]ft humidity[32]%

Applying new values (deg F, %): 74.14,31.96

255

255

255

255

Hi rfrancis97,

When it starts printing “255” endlessly, that means the CCS811 is reporting “data not ready” and usually points to a connection problem. The CCS811 might be defective but let’s try and eliminate a connection problem before we reach that conclusion.

I have a few quick questions to help provide some more information about your circuit with the Environmental Combo board and its behavior. First, what type of microcontroller are you connecting it to? Are you using the Qwiic connectors or the header pins on the Combo Board? Do you have any other I2C devices on the same bus? If so, does removing them help/hurt the behavior? Is the timing consistent between when you start up the code and when it starts printing “255” endlessly? Does the CCS811 start printing 255 regardless of which example you use (either [BasicReadings or [CombinedReading)? Finally, can you please take a few photos of your board and circuit and attach them to your reply (or if that does not work, host them on another site and link to it)?

With a little more information about your circuit and the behavior you are seeing we’ll be able to troubleshoot this issue further to identify what is causing it.](Qwiic_BME280_CCS811_Combo/Firmware/Example2-CombinedReading at master · sparkfun/Qwiic_BME280_CCS811_Combo · GitHub)](Qwiic_BME280_CCS811_Combo/Firmware/Example1-BasicReadings at master · sparkfun/Qwiic_BME280_CCS811_Combo · GitHub)

Thanks for getting back to me.

-I’m using a NodeMCU ESP8266.

-I’m using Qwiic on the CCS811 and male pins to a breadboard. I’ve tried both Qwiic connectors and have tried re-seating the male pins.

-No other I2C devices.

-The time varies a little bit, but usually fails around 5-20 mins.

-Yes, I tried both examples and got same results.

-I’ve attached photos.

I wont mind hard-wiring the connections if you think that will help.

IMG_0799.jpg

Hi again,

Thanks for taking those photos and sharing the information about the error and your setup. I believe the issue is due to how the ESP8266 core handles I2C timing with the Wire library. The 255 error comes up when the master device is expecting a response from the slave and it does not get it in time and then prints out 255. It’s not a particularly helpful error code but I did some quick digging and found [this post on the Adafruit forums discussing the problem in detail. Feel free to read through that post as there is a lot of good info and tips there but the best solution is probably to adjust the clock stretching for the ESP8266 core.

As the original poster mentions, the workaround they were using is to just toggle the RESET pin on a regular basis with a digital pin on your NodeMCU, but if you are trying to get very accurate data from the CCS811 that will affect your readings so you may need to filter out “bad” data or try adjusting that clock stretching limit in the core files. If you want to try adjusting that clock stretch limit and if you are using Windows, you’ll find the file you want to change at a file path similar to this: ```
C:\Users\mark\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266\core_esp8266_si2c.cpp


<B>**Note**</B>: You may need to enable viewing Hidden Files. If you are not sure how to do this, search something like "View Hidden Files for Windows" or whichever operating system you are using. 

If you are using another OS, the file path will be similar but not exactly the same. You can try searching your computer for Arduino15 and that may help. Otherwise, there are a couple of replies in the Adafruit forum topic I linked that mention the specific file path. After you have located the I2C file, either do a search in that file for "ClockStretchLimit" or navigate to [[this line](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/core_esp8266_si2c.cpp#L161) (it may vary depending on which code/text editor you open the file with) and adjust the limit from 230 to 460. Just keep in mind that any time you update the ESP8266 core, you will need to adjust this file again to lengthen it.

That *should* fix the problem but it's not guaranteed since the library has not been tested with ESP8266 boards (for this exact issue, actually). Hopefully, this helps resolve the issue for you but if not, you may just need to trigger a reset on the CCS811 every ~5 mins or so using a digital pin going LOW. 

Let us know if you continue to have problems or have any other questions about this or other SparkFun products in your project and we would be happy to help as much as we can.](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/core_esp8266_si2c.cpp#L161)](https://forums.adafruit.com/viewtopic.php?f=19&t=121816)

Thanks for the tips. Unfortunately, the stretching didn’t work. I’ll just go with an ESP32 or Arduino and see it it works better.

Hi, I have the non-QWIIC sparkfun CCS811 board and am encountering a problem with I2C and therefore the code stops at the mySensor.begin() statement, I’ve tried a couple of other libraries as well and have run in to the same issue. Ive used an I2C scanner code and confirmed that address of the sensor (0x5B) therefore I know there isnt anything wrong with my wiring. I am using an ESP32s the pin out for which can been seen in the link below. I’ve used GPIO21 as SDA and GPIO 22 as SCL. Initializing the pins in Wire.begin(21,22); has not worked either. Would appreciate some tips on how to debug this issue. thanks :slight_smile:

(pin out as seen here https://www.google.com/url?sa=i&source= … 0269915180)

The CCS811 is using clock stretching which is NOT supported on the standard I2C of an ESP32. On an Arduino clock stretching is not an issue and with an ESP8266 one can set the clock stretch with Wire.setClockStretchLimit(limit) where limit is in us. This is already included in the SparkFun driver software.

As part of a different project, where I needed clock-stretching on an ESP32, I have created a SoftWire library for the ESP32 based on the ESP8266 I2C library. Just for the fun of it, I have now included and tested that with the most recent SparkFun CCS811 library, changed the cpp file, the .h file and the examples. I have attached this version and it should be used instead of the standard SparkFun CCS811 Library.

For a user there should be no difference, just use pin 22 SDA, 21 SCL and make sure to set the right I2C address in the sketch (often this is forgotten) and if necessary the external pull-up resistors (depending on your CCS811 module). I have run the basic test for 5 hours with any problems.

P.s. if you plan other I2C devices at the same time see the README file

SparkFun_CCS811_Arduino_Library-master_esp32.zip (141 KB)

paulvha:
The CCS811 is using clock stretching which is NOT supported on the standard I2C of an ESP32. On an Arduino clock stretching is not an issue and with an ESP8266 one can set the clock stretch with Wire.setClockStretchLimit(limit) where limit is in us. This is already included in the SparkFun driver software.

As part of a different project, where I needed clock-stretching on an ESP32, I have created a SoftWire library for the ESP32 based on the ESP8266 I2C library. Just for the fun of it, I have now included and tested that with the most recent SparkFun CCS811 library, changed the cpp file, the .h file and the examples. I have attached this version and it should be used instead of the standard SparkFun CCS811 Library.

For a user there should be no difference, just use pin 22 SDA, 21 SCL and make sure to set the right I2C address in the sketch (often this is forgotten) and if necessary the external pull-up resistors (depending on your CCS811 module). I have run the basic test for 5 hours with any problems.

P.s. if you plan other I2C devices at the same time see the README file

I have reworked the SparkFun CCS811 library to work around the clock stretch limitations by adding delays at appropriate places.

This rework also adds error detection and retries to all operations.

Conditionally enabled DEBUG_ERROR cases are added to report program flow and errors to the user.

SparkFunCCS811.cpp (40.5 KB)

SparkFunCCS811.h (4.86 KB)