Software

Dependencies

You'll need to download and install the following dependencies for this project's software:
Adafruit TCS34725 Color Sensor Arduino Library
If you aren't sure how to install an Arduino library, check out this tutorial.

Python

The software for this guide is written in python and should work with either python 2.7 or 3+ (although it was primarily tested against version 2.7).

Once you have python installed, follow these steps depending on your platform:

Mac OS X

Install NumPy with one of the binary packages here.

Install the PIP python package manager by executing the following commands in a terminal:
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
Finally, install the colormath and pyserial library by executing in a terminal:
pip install colormath==1.0.9 pyserial
If you plan to use the FT232H cable, download and install the X code command line tools by following the steps in the answer here. You will also want to install the homebrew package manager too. Once those are installed you can install the required libftdi and libmpsse dependencies by executing in a terminal:
brew install libftdi
brew install swig
wget https://libmpsse.googlecode.com/files/libmpsse-1.3.tar.gz
tar xvfz libmpsse-1.3.tar.gz
cd libmpsse-1.3
./configure
make
sudo make install

Linux

These steps are written for Ubuntu, but should be straightforward to adapt to other distributions. In a terminal execute the following commands:
sudo apt-get install python-numpy python-pip
pip install colormath pyserial
If you plan to use the FT232H cable, execute the following commands to install the required software:
sudo apt-get install python-dev libftdi-dev swig
wget https://libmpsse.googlecode.com/files/libmpsse-1.3.tar.gz
tar xvfz libmpsse-1.3.tar.gz
cd libmpsse-1.3
./configure
make
sudo make install

Windows

Install NumPy from one of the binary installers here.

Install PIP by downloading the get-pip.py file, opening a command window, navigating to the directory with the file, and executing:
python get-pip.py
Note you might need to add python to your path to be able to run scripts from the command line. This blog post has a simple set of instructions to add python to your path.

Now execute the following command to install the required colormath and pyserial library:
pip install colormath pyserial
At this point all the dependencies for Windows are installed. Unfortunately you won't be able to use the FT232H cable with Windows because the libmpsse library doesn't support it. Stick to using an Arduino to communicate with the color sensor on Windows.

Also note that the software for this project has only been tested on a virtual machine running Windows. Everything should work on a real machine, but if you have issues send them to the github repository for the project.

Download Project Software

Download the software for this project from its github repository by clicking this button:
Unzip the archive and you will find an Arduino sketch, AutoColorTemp_Sketch, and a collection of python scripts.

If you're using an Arduino for this project, load the sketch in Arduino and upload it to your hardware. If you open the serial monitor at 115200 baud you should be able to send a question mark character ? and see the current RGB color (in floating point, with values from 0-1.0) printed.

Software Usage

To run the software for this project, make sure you've assembled the hardware and connected it to your computer. Open a terminal and navigate to the directory with the downloaded python scripts and execute the following command:
python run.py --help
You should see a display of all the command line parameters for the program. Take note that either the --arduino or --ftdi parameters are required to run the program.

For example to run the program with Arduino hardware connected to /dev/ttyUSB0, execute:
python run.py --arduino /dev/ttyUSB0
Or to run with an Arduino connected to COM4 on Windows, execute:
python run.py --arduino COM4
To use the FTDI cable you need to specify the --ftdi option instead of the --arduino option. No port or other parameter is required when using the --ftdi option.

However, before the software is run with the --ftdi option you must disable the built in kernel driver for FTDI devices!
Unfortunately the driver built in to recent Linux and Mac OS X kernels is not compatible with the libftdi library and must be temporarily disabled. The provided run_ftdi_linux.sh and run_ftdi_macos.sh shell scripts can be run to automatically disable and re-enable the drivers when running the software. These shells scripts need to be run as root with the sudo command.

For example to run with FTDI hardware on a Mac, execute:
sudo ./run_ftdi_macos.sh --ftdi
Or on Linux execute:
sudo ./run_ftdi_linux.sh --ftdi
Be aware when the program is running the FTDI drivers will be disabled so you will not be able to program an Arduino or communicate with other FTDI-based devices!

Once the software is running it will query the color sensor every 10 seconds, compute the temperature of the measured color, and adjust the gamma of the primary display to match the measured color temperature. Make sure to disable or close programs like f.lux before running the software as they might interfere with the gamma adjustment!

Try shining different colored lights on the sensor to trick it into seeing extreme temperatures (orange, white, or light blue LEDs work best--other colors will be too extreme).

You can press Ctrl-C at any time to quit the application.
This guide was first published on Mar 28, 2014. It was last updated on Mar 28, 2014. This page (Software) was last updated on May 18, 2019.