SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Environment category should be posted in this forum. Includes Air Quality, Altitude, Atmospheric & barometric pressure, Combo boards & other, Temperature & humidity, etc.
#208240
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
..........................
#208267
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.
#208275
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.
You do not have the required permissions to view the files attached to this post.
#208368
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:
Code: Select all
C:\Users\mark\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266\core_esp8266_si2c.cpp
Note: 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 (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.