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
: 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.
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.