Since 2014, I've been on a quest to automate the lighting in my home (not shown above), and have built various prototypes for that purpose. In February of 2018, I purchased my first Philips Hue smart lights, and began to experiment.
The Philips Hue system is smarter than your average lighting, but it's no genius. Out of the box, it can control lights in multiple rooms and schedule different lighting programs for different times of the day.
What it can't do is react to ambient daylight.
My apartment doesn't have a great number of windows, and the living room and kitchen are somewhat shady in the daytime, so I set out to fix that. I was going to need some hardware, so I shopped around on eBay and did some prototyping...
The base system is a Raspberry Pi Zero W. For light sensing, I am using a TCS34725 board attached to the power and I2C pins:
The front end is based on Bootstrap:
The back-end is based on Node and Express:
The TCS34725 can sense red, green, blue and clear light, but is not calibrated to a defined colour space such as Rec. 709. All well-behaved colour spaces can be mapped to the universal CIE XYZ colour space using transformation matrices. Philips Hue lights expect CIE xy chromaticities (brightness-independent colours), which can be derived from XYZ colours with a simple equation.
As it turns out, our sensor does not have a well-behaved colour space. It has a non-linear colour space, something I discovered after I threw a perceptron (neural network) at the problem, and it produced a non-linear mapping that I could have never reproduced with matrices.
The system is now up and running and it works really well, but I'm planning to rewrite the software in something less resource-intensive than node.js.