Color Sensor

Similiar to ambient light sensors, color sensors are responsive to light, however they are typically manufactured to only capture red, green, and blue light though some models are responsive to all visible light. MetaEnvironment boards come equipped with a TCS34725 color sensor, accessed through the IColorTcs34725 interface.

using MbientLab.MetaWear.Sensor;

IColorTcs34725 color = metawear.GetModule<IColorTcs34725>();

Configuration

The color sensor has 2 configurable parameters that affect the data range, resultion, and sensitivity.

Parameter Description
Gain Analog signal scale
Integration Time Amount of time spent to aggregate adc values

There is also a white illuminator LED next to the sensor that can be used to provide additional light if the surrounding area is too dark.

import com.mbientlab.metawear.module.ColorSensorTcs34725.Gain;

// set gain to 4x, integration time to 4.8ms,
// keep illuminator led off
color.Configure(gain: Gain._4x, integationTime: 4.8f);

ADC Values

The red, green, blue, and clear ADC values measured by the TCS3472 device are represented by the Adc class and is classified as a forced data producer.

using MbientLab.MetaWear.Sensor.ColorTcs34725;

await color.Adc.AddRouteAsync(source =>
    source.Stream(data => Console.WriteLine("color adc = " + data.Value<ADC>()))
);