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

Allow changingI2C address of the sensor #10

Open
jeffding45 opened this issue Feb 5, 2020 · 3 comments
Open

Allow changingI2C address of the sensor #10

jeffding45 opened this issue Feb 5, 2020 · 3 comments

Comments

@jeffding45
Copy link

Hello. Can we add a parameter to the constructor of the Rev2mDistanceSensor class to to override the I2C address? We figured out a way to change the address of the device at power-up so this would be useful to enable multiple devices on the same I2C bus.

@willtoth
Copy link
Contributor

willtoth commented Feb 7, 2020

Are you planning on using a multiplexer? If so you probably don't actually need to set the address at all since the mux takes care of that.

@jeffding45
Copy link
Author

We experimented with a multiplexer, but have since ruled it out due to the way the distance sensor code works. Since it spins up a thread to communicate with the sensors behind the scenes, it isn't going to be happy if it loses ability to talk with the sensors as the mux switches between sensors.

We have since modified the Rev2mDistanceSensor class and added functionality to the constructor to pass in an I2C address. If the address is different from the default, we call the function to change the address. This approach is working well. We're now bread boarding our hardware solution to power up the sensors one at a time in order to initialize and change the address of each sensor individually.

Once we have a solid solution we can upload our changes to the code and you can merge as you see fit.

@nimrod46
Copy link

@jeffding45 Have you finished working on the code? Are you able to share it with us?

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