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

Sensors on different I2C channels #39

Closed
TorbenSchreiter opened this issue Mar 12, 2020 · 2 comments
Closed

Sensors on different I2C channels #39

TorbenSchreiter opened this issue Mar 12, 2020 · 2 comments

Comments

@TorbenSchreiter
Copy link

Hi there,

for an ESP32-based project, we needed a way to distribute sensors on the two separate hardware wires (Wire. and Wire1.). The modified version of the lib is attached (VL53L0X-2xI2C.zip).

@kevin-pololu Changes are straight forward. Would be great if this could be integrated into the master branch at some point.

How to use:

#include <Wire.h>
#include "VL53L0X-2xI2C.h"

VL53L0X sensor;
VL53L0X sensor2;

Wire.begin(GPIOSDA,GPIOSCL); // initialize I2C w/ I2C pins from config
present = sensor.init(true, &Wire);

Wire1.begin(GPIOSDA2,GPIOSCL2); // initialize I2C w/ I2C pins from config
present2 = sensor2.init(true, &Wire1);

Cheers,
Torben

@KurtE
Copy link
Contributor

KurtE commented Aug 1, 2020

For what it is worth, I made a similar change, the main difference was I put the option Wire object on the constructor instead of on the init. Either is fine.

I went ahead and made a Pull Request (#45) to see if they are receptive to this.

There are some other features I am going to play with as well. Trying to decide to do it here or with the Adafruit_VL5310X library, which supports this, and is made up the the ST SDK, and mainly only has a single Range function exported as part of the main .h/cpp files.

@kevin-pololu
Copy link
Member

Hi, Torben.

We just merged KurtE's pull request, although we ended up changing it so selecting a different I2C bus is done with separate functions (setBus() and getBus()) instead of through the constructor or init(). Thanks for your contribution though!

Kevin

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

3 participants