Using TCS34725 Color RGB Sensor(s) with U3-LV | LabJack
 

Using TCS34725 Color RGB Sensor(s) with U3-LV

2 posts / 0 new
Last post
mischir
mischir's picture
Using TCS34725 Color RGB Sensor(s) with U3-LV

I like to use three RGB Sensors TCS34725 on U3-LV for measuring the change of colors in liquids. (similar to a photometer).

Is it possible to connect them to the I2C Bus and read data of three sensors ?

Are there any examples in Delphi, how to code the I2C bus?

Best regards, Mike

LabJack Support
labjack support's picture
The U3-LV can be connected to

The U3-LV can be connected to the TCS34725 RGB sensor, we suggest connecting digital sensors to the EIOx or CIOx lines of the U3 to allow for slightly better signal quality of the logic levels at higher clock speeds.

We don't have any I2C example code specifically for the TCS34725 currently written in Delphi however we do have a lot of resources that you can reference as you try to get off the ground.

  1. I2C (App Note): This describes the basic UD driver function calls that you will need to call to configure the U3's I2C capabilities and has some logic analyzer screen shots that describe what some of the configuration options are.
  2. We have a working Lua Script example that works for the T4 and T7 series devices that documents some of the basic I2C read and write operations you will need to perform to configure and control the sensor.  It looks like this sensor only requires the use of I2C read and write commands and not a more combined writeRead command.
  3. We have some matlab example code that is oriented towards the UD driver that is well documented and documents what the I2C config, read, and write functions are doing in the Lua Script example in the context of the UD driver and should be easy for users to translate into their own language.  The example code summary is here, and the code is available here.

For this sensor I suggest you start by making 3 basic functions, and after getting basic communication going you can make others as required:

  1. configure (starts at line 22): Call the LJUD "ePut" function several times to configure the slave address, SDA/SCL pin numbers, the U3-LV's I2C options, and clock speed.
  2. readAndGetAcks (starts at line 95): Calls the LJUD "AddRequestPtr", "AddRequest", "GoOne", and "GetResult" functions to perform an I2C read command allowing you to address an I2C slave and then read several bytes of data from a slave device.  The num-acks variable allows you to see if the I2C slave sensor responded to the addressing sequence of the I2C protocol.
  3. writeAndGetAcks (starts at line 155): Calls the LJUD "AddRequestPtr", "AddRequest", "GoOne", and "GetResult" functions to perform an I2C write command sequence to write an array of data to the connected slave device.  The num-acks variable allows you to see if the I2C slave sensor responded to the addressing sequence of the I2C protocol.

If you are having issues with getting started, I suggest double checking that you have properly installed pull-up resistors, check to make sure you are configuring the UD library with a 7-bit slave address and not an 8-bit slave address (the UD driver automatically reserves the last bit to indicate read vs write I2C operations), and that you are correctly powering the sensor.  After that you may need to pick up a logic analyzer or an oscilloscope to see if you are transmitting the data correctly.  Our I2C simulator page is oriented towards the T4 and T7, however some customers have found it useful to help understand the I2C protocol itself.