Hi everyone! I’m a first year coder on my FRC team and we’re dealing with an issue regarding I2C buses. For some background, we are using REV Color Sensors v2, which all have the I2C address of 0x39 (can’t be changed). Because we only have a single I2C address on the RoboRIO (and on the Arduino which we considered), we bought an Adafruit TCA9548A 1-to-8 I2C multiplexer. The issue came up in coding the multiplexer, because we are unsure how to tell the I2C to tell another I2C bus to read/write to the sensor. We are working on the following solutions:
Using Java, tell the RoboRIO’s I2C bus to tell the Adafruit’s buses to read/write from the sensors
Using C++, do the same as above, but with an Arduino which will send data to the RoboRIO
Use analog/digital pins on the Arduino to simulate extra I2C buses
The issue with each of these solutions is that we’re finding limited documentation/example code, and the few things we do find are not working.
Any help that can be provided would be appreciated! Thanks!
What doc or example code did you find and follow so far?
Did you look at the example code on adafruit’s site?
If you did, then post a link to your java code if you have it somewhere like github. Or attach a copy of it here.
Option 2 sounds like alot of extra work. I’m not sure what option 3 means. Post links to the docs/examples you did find so far if you want help with those options.
Just as a clarification, you can actually use the I2C on the MXP port as a second separate I2C bus. This can help if you are only using 2 of these sensors.
@Will_Toth
Just as a clarification, you can actually use the I2C on the MXP port as a second separate I2C bus. This can help if you are only using 2 of these sensors.
Unfortunately, we are using 3 color sensors, so that wouldn’t work. Thanks though!
Yes, I used that as the example code, and it helped in testing that the multiplexer did, in fact, create multiple buses. However, I can’t find a class for the REV sensors, the way they did for the magnetometers in the example, so I have no idea how to talk to the sensors after selecting the I2C bus.
As for the Java code, it treats the buses on the multiplexer as sensors, which is causing the issue because as far as I know, I2C.write() only sends hex values, so I do not know where to go from there. I will try to add a link to the code later, if possible.