Raspberry Pi Python I2C Driver for TCS34725 RGBC color sensor
The TCS34725 is another fine chip from Austria MicroSystems. We are currently using the
AM3935 Lightning detector on the WeatherPiArduino Weatherboard. The CTO of SwitchDoc Labs worked with Austrian MicroSystems and their partner AMI in the early 1980s as an IC Design Engineer.
The TCS3472 device provides a digital return of red, green, blue (RGB), and clear light sensing values. An IR blocking filter, integrated on-chip and localized to the color sensing photodiodes, allows color measurements to be made accurately. The TCS3472 an ideal color sensor solution for use under varying lighting conditions and through attenuating materials. This information can even be correlated with various types of air pollution. We read an article some months back about using light color to detect atmospheric pollutants and added the sensor to Project Curacao. We never quite got around to figuring out how to interpret the data (beyond the color) but we will in our new project, SunRover, a solar powered autonomous robot. We can’t locate the exact article, but here are a couple of links:
https://en.wikipedia.org/wiki/Atmospheric_optics
https://research.cens.ucla.edu/people/estrin/resources/conferences/2008-Nov-4-Whitesell_Kutler_Raman_System%20for%20Determining.pdf
Project Curacao
Project Curacao is back from the Caribbean for repairs. We expected that the front end of
the Arduino processors was ruined by the RF interference during a late November 2014 Ham Radio Contest (not their fault – we should have put a choke on the long sensor lines headed to the WeatherRack weather sensors – which we will do before we take the box back down in June). However, it now appears that the Raspberry Pi SD Card was corrupted, possibly by too many reboots because of the RFI. The Arduino BatteryWatchDog looks great as well as the SwitchDoc Labs WeatherPiArduino board and Dual WatchDog Timer.
TCS34725 Color Sensor Driver
SwitchDoc Labs just updated and has now released a https://github.com/switchdoclabs/SDL_BM017CS.
TCS34725 RGBC color sensor that is connected to Project Curacao. Here is the device attached to the back of the top of the box and then a picture of it peeking through (with the LED turned on for emphasis – it normally operates with the LED off).
This device was purchased from solutions-cubed.com (excellent service and documentation). Another version (compatible) can be had from Adafruit.
We wrote a Python driver for the BM017 / TCS34725 as we could not find one on the net that met our needs.
This device was purchased from solutions-cubed.com (excellent service and documentation). Another version (compatible) can be had from Adafruit.
We wrote a Python driver for the BM017 / TCS34725 as we could not find one on the net that met our needs.
It has been posted on github for anyone who needs such a driver.
We connected the INT line to the LEDON pin (and the VDD_LED to VDD) and now we can switch the interrupt on and off and turn the white LED on and off without burning another GPIO pin.
Example Code for TCS34725
The example code to test the library and the TCS34725 is below:
#!/usr/bin/python # example driver for BM017 and TCS34725 import time import smbus from Adafruit_I2C import Adafruit_I2C from PC_BM017CS import BM017 bm017 = BM017(True) bm017.debug = True bm017.readStatus() bm017.isBM017There() bm017.getColors() bm017.readStatus() bm017.disableDevice() bm017.setIntegrationTimeAndGain(0x00, 0x03) bm017.getColors() bm017.readStatus() bm017.readStatus() # this will turn on the LED if LEDON is connected to INT and LEDVDD is connected to VDD_LED bm017.setInterrupt(True) time.sleep(5.0) bm017.setInterrupt(False)
And the Results:
pi@projectCur ~/PC_BM107CS $ sudo python example.py BM017 initialized ('BM017 Status=', 17) BM017 / TCS34725 is present ('ColorList = ', [2, 0, 1, 0, 1, 0, 0, 0]) ('clear_color= ', 2) ('red_color= ', 1) ('green_color= ', 1) ('blue_color= ', 0) ('BM017 Status=', 17) ('IT set to:', 0) ('Gain set to:', 3) ('ColorList = ', [8, 15, 157, 7, 105, 5, 151, 3]) ('clear_color= ', 3848) ('red_color= ', 1949) ('green_color= ', 1385) ('blue_color= ', 919) ('BM017 Status=', 17) ('BM017 Status=', 17) Interrupt On Interrupt Off
We pointed the sensor at a spool of red wire. That’s why the “red_color” is higher than the green and blue.