Colour sensor TCS34725 with TinkerPie
Hold an object over it and read its colour.
| Type | Smart sensors (I2C) |
|---|---|
| Connect to | SENSOR port · 0x29 |
| Gives | colour, or 0-255 per part |
| Simulator | Yes: a control appears under the simulated board |
How it works
The TCS34725 has tiny light sensors with red, green, blue and clear filters, and a white LED that lights up the object. Comparing the red, green and blue parts tells you the colour.
How to wire it
Plug into any SENSOR 1-4 port (SDA, SCL, 3.3 V, GND). Each type has a fixed I2C address, so different types can share the bus.
Code
In blocks: Accessories category in TinkerPie Studio. As code:
// JavaScript
sensors.colourSensorColour()
sensors.colourSensor(ColourPart.Red)
// Arduino C++
sensors::colourSensorColour()
sensors::colourSensor(ColourPart::Red) Good to know
- Hold the object 3-10 mm from the sensor for steady colours.
- Uses I2C (address 0x29).
- Room light changes the readings; the built-in LED helps.
Projects with the Colour sensor TCS34725
Similar modules
- Light meter BH1750
- Temperature + humidity AHT20
- Temperature + humidity SHT31
- Motion sensor MPU6050
- IR thermometer MLX90614
- Real-time clock DS3231
- 4-channel ADC ADS1115
- Current + voltage sensor INA219
More projects to try
Questions
Can I try the Colour sensor TCS34725 without buying one?
Yes. In TinkerPie Studio the simulator shows a control for it under the board, so you can test your program before you build it.
Why does my red object look orange?
Room light and distance change the result. Keep the distance the same, shade the sensor and compare readings of your own objects.