REV Color Sensor V3
Configure the sensor, read its color values, and test a simple decision
The REV Color V3 is a small I²C sensor for nearby objects. It measures red, green, blue, and clear-light values and also has an infrared proximity detector. It is not a camera: its useful color range is very short. REV recommends collecting color data within about 2 cm of the target for the strongest differentiation. Its proximity reading is rough and depends on target reflectivity and lighting; it is not a precise distance sensor.
Display the sensor values first. Once you have measured how your sensor responds to the objects, add code that labels them “red,” “blue,” or another color.
Sensor configuration
Connect the sensor to a Hub I²C port. In the configuration, add REV Color Sensor V3 to that port and name it color. Do not select the older “REV Color/Range Sensor” configuration for a V3.
The V3 and REV's 2m Distance Sensor share an I²C address; REV says they cannot share the same I²C bus. Check bus assignments if the reports an address conflict.
Hardware mapping
For color readings, ask the SDK for a NormalizedColorSensor:
private NormalizedColorSensor colorSensor;
@Override
public void init() {
colorSensor = hardwareMap.get(NormalizedColorSensor.class, "color");
}private lateinit var colorSensor: NormalizedColorSensor
override fun init() {
colorSensor = hardwareMap.get(NormalizedColorSensor::class.java, "color")
}hardwareMap.get connects your variable to the device with configuration name color. If the name or configured device type differs, initialization fails.
You do not need three separate hardware objects just to read three color channels. One normalized sensor object gives you red, green, blue, and driver-derived alpha/brightness measurements.
Sensor readings
Read a sample and show each channel in telemetry:
NormalizedRGBA sample = colorSensor.getNormalizedColors();
telemetry.addData("Red", "%.3f", sample.red);
telemetry.addData("Green", "%.3f", sample.green);
telemetry.addData("Blue", "%.3f", sample.blue);
telemetry.addData("Alpha / brightness", "%.3f", sample.alpha);
telemetry.update();val sample = colorSensor.normalizedColors
telemetry.addData("Red", "%.3f", sample.red)
telemetry.addData("Green", "%.3f", sample.green)
telemetry.addData("Blue", "%.3f", sample.blue)
telemetry.addData("Alpha / brightness", "%.3f", sample.alpha)
telemetry.update()The channels are normalized values, not calibrated physical color coordinates. Hold a matte red, green, blue, white, and black object at the same close distance. Record how the four readings change. Keep the sensor orientation and built-in LED switch in the same state during your tests.
Color classification
A first rule can compare which channel is largest, but that rule is only a starting exercise. It can mislabel white, gray, reflections, or colors that produce similar channel values.
String colorGuess = "uncertain";
if (sample.red > sample.green && sample.red > sample.blue) {
colorGuess = "red-like reading";
} else if (sample.green > sample.red && sample.green > sample.blue) {
colorGuess = "green-like reading";
} else if (sample.blue > sample.red && sample.blue > sample.green) {
colorGuess = "blue-like reading";
}
telemetry.addData("Simple channel comparison", colorGuess);var colorGuess = "uncertain"
if (sample.red > sample.green && sample.red > sample.blue) {
colorGuess = "red-like reading"
} else if (sample.green > sample.red && sample.green > sample.blue) {
colorGuess = "green-like reading"
} else if (sample.blue > sample.red && sample.blue > sample.green) {
colorGuess = "blue-like reading"
}
telemetry.addData("Simple channel comparison", colorGuess)The labels say “-like reading” on purpose: this is not a reliable general-purpose color classifier. Improve it only after logging samples from the actual game objects, target distance, room lighting, and LED setting. Add thresholds and an “unknown” case for overlapping or dim readings. Never assume thresholds from another transfer to yours.
Proximity readings
If the SDK exposes this configured device as a DistanceSensor, you can display its rough proximity estimate:
DistanceSensor proximity = hardwareMap.get(DistanceSensor.class, "color");
double estimatedDistanceCm = proximity.getDistance(DistanceUnit.CM);
telemetry.addData("Rough proximity (cm)", "%.1f", estimatedDistanceCm);val proximity = hardwareMap.get(DistanceSensor::class.java, "color")
val estimatedDistanceCm = proximity.getDistance(DistanceUnit.CM)
telemetry.addData("Rough proximity (cm)", "%.1f", estimatedDistanceCm)Treat this as a rough proximity cue, not a precision measurement. REV notes that reflectivity affects the result and recommends a separate distance sensor for accurate range. Test the actual object and mounting distance before using a threshold.
Classification testing
- Place one known object at the sensor's intended distance.
- Record several readings without moving the robot.
- Repeat with each object color your robot needs to distinguish.
- Repeat under the lighting expected on the field.
- Try a gap, a dark object, and a shiny object. Decide when the program should return “unknown.”
- Only then connect the classified result to a or decision.
This process shows whether the sensor can answer your robot's question at all. The V3's short color range may make a camera or a different sensor a better fit for a farther-away object.
Troubleshooting
| What happens | What to check |
|---|---|
Hardware map cannot find color | Configured name, I²C port, configured device type, and wiring. |
| Readings are similar for every object | Move the target closer, aim the sensor squarely, and check LED state and reflections. |
| Color changes when the object moves slightly | Fix the sensor and target distance; test a larger area of the object. |
| Proximity varies between objects | Reflectivity affects the estimate; use it only as a rough nearby cue. |
| V3 values differ from V1/V2 values | V3 uses a different sensor chip; recalibrate instead of reusing old thresholds. |
The FTC SDK 12 Broadcom driver derives normalized alpha from RGB brightness; it is not an independent clear-channel measurement. Use it as a brightness indication and calibrate thresholds on the actual surface.
A passing piece is missed
Compare a held object with an object moving through the . If held readings work, measure how long the moving object remains in the sensing region and compare that with the actual interval between sensor samples. A piece can pass between readings; averaging or requiring several matching samples cannot recover an event the sensor never observed.
Log timestamps with the raw proximity and colour values, then repeat at a slower intake speed. Improve the sensor's view or increase the object's visible dwell time if necessary. Treat reflectivity-dependent proximity as one cue, and consider a beam-break or suitable presence sensor when detecting passage is more important than measuring colour. Count one event on entry and require a clear exit before counting another.