View Full Version : [FTC]: Using multiple sensors of same type
I got tired of not being able to read two color sensors or two sonic sensors, so I re-wrote the code to get them to work as expected.
In configuration, make sensor "I2C Device".
Initialization is hardware map, device name, and configured address.
color = new RedStormColorSensor(hwMap, "cb", 0x40);
range = new RedStormRangeSensor(hwMap, "rf", 0x2a);
ArtemusMaximus
21-11-2016, 08:28
I got tired of not being able to read two color sensors or two sonic sensors, so I re-wrote the code to get them to work as expected.
In configuration, make sensor "I2C Device".
Initialization is hardware map, device name, and configured address.
color = new RedStormColorSensor(hwMap, "cb", 0x40);
range = new RedStormRangeSensor(hwMap, "rf", 0x2a);
Can this be used for Adafruit Color sensor?
Here is the device I think you are talking about: https://cdn-shop.adafruit.com/datasheets/TCS34725.pdf
I have seen other libraries support it, so I would guess it could.
You would have to change RedStormColorSensor.java to match the registers in the datasheet on page 13. Let me know if you have any issues with what the code is doing.
Christopher149
21-11-2016, 12:02
Can this be used for Adafruit Color sensor?
Because the Adafruit color sensors have a fixed, non-changeable I2C address, you need to use an I2C multiplexer. This code (https://github.com/Chris857/FTC-Code/tree/master/src/main/java/org/firstinspires/ftc/teamcode) I wrote lets you use Adafruit color sensors over a multiplexer.
ArtemusMaximus
21-11-2016, 16:19
Here is the device I think you are talking about: https://cdn-shop.adafruit.com/datasheets/TCS34725.pdf
I have seen other libraries support it, so I would guess it could.
You would have to change RedStormColorSensor.java to match the registers in the datasheet on page 13. Let me know if you have any issues with what the code is doing.
Thank you . I already have multiplexer and test code (not mine) that worked. I was just asking because original post didn't specify which sensors affected and it would be cool if Adafruit Sensors with fixed I2C address can be used with just code without needing extra hardware
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.