problem in arduino connect with at24c128bn using i2c protocol

hi this is arul i am new to arduino i have one problem in connecting eeprom(at24c128bn) to arduino.
in eeprom is store some sensor value. i need help how to read this sensor value using ardunio with i2c protocol please any one having code and hoe two connect in hardware .
please help me … :o :o

Wire.begin(); // init TWI hardware

//write to chip

int dataAddr=address;
uint8_t buff[28];
uint8_t buflen = 28;

uint8_t dataLowAddr,dataHighAddr;

Wire.beginTransmission(I2Caddr);
dataHighAddr = dataAddr >>8;
dataLowAddr = dataAddr & 0xff;
Wire.write(dataHighAddr);
Wire.write(dataLowAddr);
for(uint8_t i=0;i<buflen;i++){
Wire.write(buff*);*
}
Wire.endTransmission();
// a potential problem, this chip has a 64byte write page buffer. if you try to write and integer(16 bit) value at dataAddr = 0x3F the MSB with be stored in address 0x3F as expected but the LSB will be stored in address 0x00 because the write wrapped around a page boundry. always check for page boundary violations in your write code.
//read
// set address to read data from
Wire.beginTransmission(I2Caddr);
dataHighAddr = dataAddr >>8;
dataLowAddr = dataAddr & 0xff;
Wire.write(dataHighAddr);
Wire.write(dataLowAddr);
Wire.endTransmission(false); // repeated-start for read
Wire.requestFrom(I2Caddr,buflen);// buflen must be less than 32 bytes, I use a max of 30 because of
//wire library buffer sizes
uint8_t i=0;
while((Wire.available()>0)&&(i<buflen)){

  • buff[i++]=Wire.read();*
    }
    buflen = i;
    Chuck.

correction:

My while loop is wrong should be:

uint8_t i=0;
if((Wire.available()>0)&&(i<buflen)){
do {
buff[i++]=Wire.read();
}while((Wire.available()>0)&&(i<buflen));
}
buflen = i;

Sorry, too late, defaulted to Pascal.

Chuck.

My latest Arduino project, a 1MB ram shield for Mega2560