Arduino SCL SDA Sensor Detection

Hello,  I've been working on a project for school and we need to use I2C sensors with an Arduino UNO.  The program that our group has written allows us to display readings from a light sensor (TCS3472) and verify that its connected.  The SCL clock and SDA are working properly although the SCL clock falling edge lines up at the SDA leading edge.  A problem has a occurred with being able to detect the I2C sensor itself.  The data is being transmitted to the device yet it won't read and the values that are being displayed in the serial monitor are all at maximum possible.  I just need some help if anybody has any ideas.  I posted the code below.

/*
BM017_Arduino_color_sensing:  This program interfaces to the AMS TCS34725 color light
to digital converter IC.  It uses the Arduino I2C interface.  

Schematics associated with the BM017 module may be used for hardware wiring information.
See the user datasheet at www.solutions-cubed.com for additional information.

[code]*/

#include <Wire.h>
#include <Math.h>

byte i2cWriteBuffer[10];
byte i2cReadBuffer[10];

#define SensorAddressWrite 0x29 //
#define SensorAddressRead 0x29 // 
#define EnableAddress 0xa0 // register address + command bits
#define ATimeAddress 0xa1 // register address + command bits
#define WTimeAddress 0xa3 // register address + command bits
#define ConfigAddress 0xad // register address + command bits
#define ControlAddress 0xaf // register address + command bits
#define IDAddress 0xb2 // register address + command bits
#define ColorAddress 0xb4 // register address + command bits

/*  
Send register address and the byte value you want to write the magnetometer and 
loads the destination register with the value you send
*/
void Writei2cRegisters(byte numberbytes, byte command)
{
    byte i = 0;

    Wire.beginTransmission(SensorAddressWrite);   // Send address with Write bit set
    Wire.write(command);                          // Send command, normally the register address 
    for (i=0;i<numberbytes;i++)                       // Send data 
      Wire.write(i2cWriteBuffer[i]);
    Wire.endTransmission();

    delayMicroseconds(100);      // allow some time for bus to settle      
}

/*  
Send register address to this function and it returns byte value
for the magnetometer register's contents 
*/
byte Readi2cRegisters(int numberbytes, byte command)
{
   byte i = 0;

    Wire.beginTransmission(SensorAddressWrite);   // Write address of read to sensor
    Wire.write(command);
    Wire.endTransmission();

    delayMicroseconds(100);      // allow some time for bus to settle      

    Wire.requestFrom(SensorAddressRead,numberbytes);   // read data
    for(i=0;i<numberbytes;i++)
      i2cReadBuffer[i] = Wire.read();
    Wire.endTransmission();   

    delayMicroseconds(100);      // allow some time for bus to settle      
}  

void init_TCS34725(void)
{
  i2cWriteBuffer[0] = 0x10;
  Writei2cRegisters(1,ATimeAddress);    // RGBC timing is 256 - contents x 2.4mS =  
  i2cWriteBuffer[0] = 0x00;
  Writei2cRegisters(1,ConfigAddress);   // Can be used to change the wait time
  i2cWriteBuffer[0] = 0x00;
  Writei2cRegisters(1,ControlAddress);  // RGBC gain control
  i2cWriteBuffer[0] = 0x03;
  Writei2cRegisters(1,EnableAddress);    // enable ADs and oscillator for sensor  
}

void get_TCS34725ID(void)
{
  Readi2cRegisters(1,IDAddress);
  if (i2cReadBuffer[0] == 0x44)
    Serial.println("TCS34725 is present");    
  else
    Serial.println("TCS34725 not responding");    
    Serial.println(i2cReadBuffer[0],DEC);
}

/*
Reads the register values for clear, red, green, and blue.
*/
void get_Colors(void)
{
  unsigned int clear_color = 0;
  unsigned int red_color = 0;
  unsigned int green_color = 0;
  unsigned int blue_color = 0;

  Readi2cRegisters(8,ColorAddress);
  clear_color = (unsigned int)(i2cReadBuffer[1]<<8) + (unsigned int)i2cReadBuffer[0];
  red_color = (unsigned int)(i2cReadBuffer[3]<<8) + (unsigned int)i2cReadBuffer[2];
  green_color = (unsigned int)(i2cReadBuffer[5]<<8) + (unsigned int)i2cReadBuffer[4];
  blue_color = (unsigned int)(i2cReadBuffer[7]<<8) + (unsigned int)i2cReadBuffer[6];

  // send register values to the serial monitor 

  Serial.print("clear color=");
  Serial.print(clear_color, DEC);    
  Serial.print(" red color=");
  Serial.print(red_color, DEC);    
  Serial.print(" green color=");
  Serial.print(green_color, DEC);    
  Serial.print(" blue color=");
  Serial.println(blue_color, DEC);
/*

 // Basic RGB color differentiation can be accomplished by comparing the values and the largest reading will be 
 // the prominent color

  if((red_color>blue_color) && (red_color>green_color))
    Serial.println("detecting red");
  else if((green_color>blue_color) && (green_color>red_color))
    Serial.println("detecting green");
  else if((blue_color>red_color) && (blue_color>green_color))
    Serial.println("detecting blue");
  else
    Serial.println("color not detectable");
*/
}  

void setup() {
  Wire.begin(); 
  TWBR =152;
  Serial.begin(9600);  // start serial for output
  init_TCS34725();
  get_TCS34725ID();     // get the device ID, this is just a test to see if we're connected
}

void loop() {
    get_Colors();
    delay(1000);
}

[/code]

Your post is a good example why code tags are important. Please edit your post and add code tags.

A problem has a occurred with being able to detect the I2C sensor itself. The data is being transmitted to the device yet it won't read and the values that are being displayed in the serial monitor are all at maximum possible.

I would expect that this sketch writes "TCS34725 not responding" to the serial interface if the sensor is not connected. What exactly do you get if you don't connect the sensor?

Sry about the code tag. Here is what the serial monitor displays.

TCS34725 not responding
255
clear color=65535 red color = 65535 green color=65535 blue color=65535
color not detectable

Its just reading nothing it seems like. The device is hooked up to the SDA and SCL through pull up resistors. It is a 3.3 volt device.

So the device is connected? That wasn't clear from your first post.

The device is hooked up to the SDA and SCL through pull up resistors.

Through? The pull-ups go to 3V3 and the device should directly connect to SDA/SCL.
Please provide a wiring diagram.

Remove the delayMicroseconds(), the bus doesn't have to settle. But you should read the return values of Wire.endTransmission() and Wire.requestFrom() because they'd tell you if the request was successful (ACK or NAK received).

alright so we tried a breakout board for this particular light sensor(TCS34725) and it works it detects the light. and reads different values for each color. The problem now is with our board design most likely. We have two of the same light sensors being selected by an I2C switch (PCA9543AD). Were only using the switch because the sensors have the same hard address.

But you don't have the switching logic in the code yet. Did you expect it to work without that? Or do you make your tests with several different versions of the hardware? I have to ask again for the wiring diagram and the sketch that is used with the hardware as described in the wiring diagram.