[TCS34725] DIY Outdoor illuminance and colortemperature (RGB) sensor

Just finished DIY Outside Illuminance & Colour temperature sensor connected to a NodeMCU_u_ipex (not in the same housing) with external antenna connection (ipex).

For waterproof outside sensor housing, I used a Foscam camera housing (white) and covered the hole with transparent plastic cover and the TCS34725 sensor inside.

(Device on the right is not applicable)

I noticed my I2C bus gave me some problems when connecting a second sensor (BME280 Temperature+Pressure+Humidity). When searching the Internet a solution was suggested to add pull-up (connected to VCC) resistor to the SDA and SCL line, which I did (4K7), resulting in significant more stable I2C-bus.

I’m also looking for the best settings. At the moment I use (part of ESPHome config):

  sda: 21 
  scl: 22 

  - platform: tcs34725
      name: "NodeMCU_u_ipex TCS34725 Red Channel"
      name: "NodeMCU_u_ipex TCS34725 Green Channel"
      name: "NodeMCU_u_ipex TCS34725 Blue Channel"
      name: "NodeMCU_u_ipex TCS34725 Clear Channel"
      name: "NodeMCU_u_ipex TCS34725 Illuminance"
      name: "NodeMCU_u_ipex TCS34725 Color Temperature"
    gain: 1x # default
    integration_time: 2.4ms # default
    glass_attenuation_factor: 1.0 # default
    address: 0x29
    update_interval: 600s

Home Assistant:

Colour temperature vs Custom Adaptive Lighting integration (HACS)

I noticed when the clear_channel/Illuminance drop-down to zero (sunset/night/dark) or when rise from zero (sunrise) , all R,G,B readings reveal spikes…

1 - I know my config settings are not the most optimal settings. Please, can someone explain how gain, integration_time and glass_attenuation_factor are effecting the different readings?

2 - Before values drop to zero or after rise from zero always it will show spikes on the R,G.B channels (not on clear channel). Is there a way to filter that behaviour?
EDIT: Changed integration_time: to auto

Please don’t hesitate to post your comments, it’s highly appreciated!

1 Like

Hello, I am learning about this sensor because I need to use it for one of my projects. Do you know the maximum distance that it will accurately sense colors? I need to be able to sense the correct color at 14 cm from the sensor. Thanks for your help.

I don’t know, but I think you need to enable the integrated white LED to sense a surface. Maybe you can use lenses or something similar?

I don’t see any distance mentioned in the datasheet.

I made some test using ESP32 and TCS 34725 with ESPHOME.
Using a light semi-transparent screen to avoid the direct sun going on the sensor, i have to say that results have been quite good and repetitive. In this winter season, with clear days the range was between 3000K at sunrise and 5300K at noon, with a parabolic curve.
Of course before the sunrise and after sunset the numbers get inaccurate , while the light is just reflected from the sky and the sensor switches on different levels of gain to balance the reduced level of lux available. This causes random peaks in the RGB components that disappear as soon as the sun is visible at the horizon (sunrise).
Without the screen, that is shaped as an arc to follow the sun path during the day, the tcs goes immediately in full saturation ( you see the “Clear channel raw @ 65535” and color temperature dropping at nonsense levels.
I’m now fine tuning the screen to allow as much as possible the indirect light to reach the TCS but without the direct sunlight hitting it. That’s my 2 cents…