Espruino and TCS34725 example

The TCS3472 device provides a digital return of red, green, blue (RGB), and clear light sensing values. An IR blocking filter, integrated on-chip and localized to the color sensing photodiodes, minimizes the IR spectral component of the incoming light and allows color measurements to be made accurately.

The high sensitivity, wide dynamic range, and IR blocking filter make the TCS3472 an ideal color sensor solution for use under varying lighting conditions and through attenuating materials. This data is transferred via an I2C to the host.

 

Schematics and connection

 

 

Code

 

[codesyntax lang=”javascript”]

I2C1.setup({scl:B6, sda:B7});
var tcs=require("TCS3472x").connect(I2C1, 1 /*integration cycles*/, 1 /*gain*/);

var v = tcs.getValue();

var v = tcs.getValue();
var min = Math.min(v.red, v.green, v.blue);
var range = Math.max(v.red, v.green, v.blue) - min;
var rgb = [ // values between 0 and 255
(v.red - min)*255/range,
(v.green - min)*255/range,
(v.blue - min)*255/range,
];

console.log("red " + v.red + " green " + v.green + " blue " + v.blue);
console.log("rgb = " +rgb);

[/codesyntax]
Output

>red 1024 green 768 blue 512
rgb = 255,127.5,0
Links
https://learn.adafruit.com/adafruit-color-sensors?view=all
http://ams.com/eng/Products/Light-Sensors/Color-Sensors/TCS34725
CJMCU-34725 TCS34725 Color Sensor RGB color sensor development board module

Share
This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :