Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Mega2560 compatibility #1

Open
augisbud opened this issue Jan 29, 2020 · 5 comments
Open

Arduino Mega2560 compatibility #1

augisbud opened this issue Jan 29, 2020 · 5 comments
Assignees

Comments

@augisbud
Copy link

Hello, the

Wire.setClockStretchLimit(500);

command doesn't work on an Arduino Mega2560. It just isn't defined in the Wire library probably?

@LucAce
Copy link
Owner

LucAce commented Jan 30, 2020

The call to setClockStretchLimit should only be required for ESP8266 and ESP32 devices and is part of the Arduino ESP8266 Wire library.

In CCS811.cpp there is a pre-compiler ifdef statement which should only call it for ESP8266 devices and in the example, you should just be able to remove the Wire.setClockStretchLimit(500); line.

@LucAce LucAce self-assigned this Jan 30, 2020
@augisbud
Copy link
Author

it doesn't seem to read values on an arduino mega

@augisbud
Copy link
Author

Reading CCS811 Sensor
ERROR: CCS811 Error Flag Set
CCS811 Error Register = 24

this is what I get on an Arduino without clock strechting, the same with esp8266(Wemos D1 Mini)

@LucAce
Copy link
Owner

LucAce commented Feb 3, 2020

An error code of 24 (decimal)/0x18 (hex) is reporting:
Bit 4: HEATER_FAULT - The Heater current in the CCS811 is not in range
Bit 3: MAX_RESISTANCE - The sensor resistance measurement has reached or exceeded the maximum
range

Both of those things seem unlikely. What CCS811 breakout are you using?

Some things to check, make sure there are pull ups to 3.3v (for the Wemos D1) on the SDA and SCL signals somewhere. The Wemos D1 and NodeMCU do not have them on their boards (on the standard pins) so the pull ups either need to be on the CCS811 breakout (like in the case of the Adafruit breakout) or in between the board and sensor. As for clock stretching, it is a function of the slave device and not something the master has to enable, the master either supports it or it doesn't. The ESP8266 devices support it and the call to setClockStretchLimit is just increasing an existing timeout. The default value is too short for the CCS811. Another thing to try is add an output which asserts then negates the active low reset of the CCS811 in the setup() function before setting it up. When I started using the CCS811 I had a lot of issues that were caused by resetting the ESP8266 and not asserting the CCS811 reset before trying to reconfigure it. It appeared the CCS811 wasn't behaving well when the ESP8266 was reset in the middle of an operation which then caused the sensor to not respond or behave poorly.

I will try to find some time to retest with a Wemos D1 and the latest version of the ESP8266 Arduino library and see if anything changed. I have had the Adafruit CCS811 sensor running with a Wemos D1 for a long time with no issues. Though it was not the easiest device to deal with.

@augisbud
Copy link
Author

augisbud commented Feb 3, 2020

I use a cjmcu-8128 board, will check for pull ups, thank you for you knowledge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants