Caspar,
I've been working on using a Pi to control my led fish tank light. The light came with a remote control, and with a little tinkering I made the LIRC transmitter to send commands from the Pi to the led light. After getting everything setup, I noticed that sometimes the light would not act upon the sent signals. After some experimenting, I discovered that this was a fault in the light's controller and not with the Pi sending the IR signals. I started searching for a way to monitor light levels to ensure that the tank light was operating in the mode that I told it.
Here is my solution.
I bought a TS2561 sensor from adafruit. Adafruit has a nice tutorial on this sensor, however it is written for the Arduino. I used the this page
https://learn.adafruit.com/tsl2561/wiring as a guide to hook up to the Pi. You only have to connect the four pins (Power, Ground, SDA, and SCL).
You must turn on I2C. Here's a link
https://learn.adafruit.com/adafruits-ra ... guring-i2c.
After looking at several solutions on how to read the TS2561 with the Pi, I decided to use this code
http://dino.ciuffetti.info/2014/03/tsl2 ... y-pi-in-c/.
I mounted the lux sensor under the led light to always get the brightest reading possible.
Here's how my script works for the light.
1. Issue remote command using LIRC
2. Poll sensor and get lux reading
3. If reading is not within established lux range, repeat steps 1 and 2 until reading is within established range.
My tank light has several different modes (white, red, green, blue) and varying degrees of brightness depending on the setting. Your lux reading will fluctuate depending on the placement of the sensor from the light, type of buld, etc, etc). In order to absolutely know what setting my light is on, I needed to know the lux range depending on mode. To collect this data, I wrote a little bash script to read the sensor X amount of times and save the data. I set the mode on the tank (ie. max white light), ran the script, and put the output in a spreadsheet. From there it's a simple matter of getting the Min and Max values for the current mode.
Hope this helps,
Winter