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 under https://github.com/projectcuracao/PC_BM017CS 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.
The example code to test the library and the TCS34725 is below:
#!/usr/bin/python# example driver for BM017 and TCS34725import timeimport smbusfrom Adafruit_I2C import Adafruit_I2Cfrom PC_BM017CS import BM017bm017 = BM017(True)bm017.debug = Truebm017.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_LEDbm017.setInterrupt(True)time.sleep(5.0)bm017.setInterrupt(False)And the results:pi@projectCur ~/PC_BM107CS $ sudo python example.pyBM017 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 OnInterrupt OffWe pointed the sensor at a spool of red wire. That's why the "red_color" is higher than the green and blue.
No comments:
Post a Comment