The Ångström Linux distribution that comes with the Beaglebone includes the I2C tools (such as i2cdetect). You will, however, need to install the python-smbus module. Be sure to run opkg update first, and then run the following command to install the python-smbus package: opkg install python-smbus.
TCS34725 Beaglebone Black
SDA P9 20
SCL P9 19
3V3 P9 3
GND P9 1
The only difference in the code is that the Beaglebone Black uses I2C bus 1 for the SCL and SDA pins -
bus = smbus.SMBus(1) # Beaglebone Black uses bus 1
# I2C address 0x29
# Register 0x12 has device ver.
# Register addresses must be OR'ed with 0x80
ver = bus.read_byte(0x29)
# version # should be 0x44
if ver == 0x44:
print "Device found\n"
bus.write_byte(0x29, 0x80|0x00) # 0x00 = ENABLE register
bus.write_byte(0x29, 0x01|0x02) # 0x01 = Power on, 0x02 RGB sensors enabled
bus.write_byte(0x29, 0x80|0x14) # Reading results start register 14, LSB then MSB
data = bus.read_i2c_block_data(0x29, 0)
clear = clear = data << 8 | data
red = data << 8 | data
green = data << 8 | data
blue = data << 8 | data
crgb = "C: %s, R: %s, G: %s, B: %s\n" % (clear, red, green, blue)
print "Device not found\n"
To keep this example simple, I have left the timing/power consumption for the analog to digital converters on the sensor board and sensor gain at their default values. For more information about these (and other settings) see the datasheet.
Note that if you want to use the i2cdetect utility on the Beaglebone Black to check the address of the connected I2C device, you need to run the command i2cdetect -r -y 1.