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





[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(,,;
var range = Math.max(,, - min;
var rgb = [ // values between 0 and 255
( - min)*255/range,
( - min)*255/range,
( - min)*255/range,

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


>red 1024 green 768 blue 512
rgb = 255,127.5,0
CJMCU-34725 TCS34725 Color Sensor RGB color sensor development board module

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