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

Wire.xxxx in library #19

Open
michapr opened this issue May 27, 2019 · 1 comment
Open

Wire.xxxx in library #19

michapr opened this issue May 27, 2019 · 1 comment

Comments

@michapr
Copy link

michapr commented May 27, 2019

Hi,
how to use the lib with an ESP32 (as sample) with two I2C interfaces?

Because of using the predefined Wire functions it is not possible to redefine the interface.

bool CCS811::i2cwrite(int regaddr, int count, const uint8_t * buf) {
Wire.beginTransmission(_slaveaddr);              // START, SLAVEADDR
Wire.write(regaddr); // Register address

Using following code (as sample) - it will not work:

TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);
...
I2Cone.begin(SDA1,SCL1,400000); // SDA pin 21, SCL pin 22 
I2Ctwo.begin(SDA2,SCL2,400000); // SDA pin 5, SCL pin 4 builtin OLED
...

As sample in CCS811Core was realized better:

CCS811Core::status CCS811Core::beginCore(TwoWire &wirePort)
{
	CCS811Core::status returnError = SENSOR_SUCCESS;
	
	_i2cPort = &wirePort; //Pull in user's choice of I2C hardware

	//Wire.begin(); //See issue 13 https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/issues/13
...

Maybe you could adapt it?

Thanks!

@maarten-pennings
Copy link
Owner

Like the idea, did not yet have the time.

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

No branches or pull requests

2 participants