Overcoming I2C buffer size

Hello,

AVR Wire library in Arduino has an internal buffer size of 32 bytes.

This means that if you try to send more than 32 bytes to a slave over one single I2C "burst", only the 32 first Wire.write() will actually be sent. So, in the example below, only 32 bytes of the intended 130 would be sent.

Wire.beginTransmission(_i2caddr);
Wire.write(0x00); // move to first register in page
for(addr=0;addr<128;addr+=1)
    Wire.write(value); 
}
Wire.endTransmission(); // send data over I2C

This could be solved by a routine that counts the data in buffer and automatically splits it into multiple Wire.beginTransmission()-Wire.endTransmission() packets.

I am quite surprised I could not find an implementation of this directly onto the Wire library (I guess they had their reasons not to include it in the official one) or somewhere else.

Has anyone dealt with this or seen some reference?
Thanks!

I never had the need for such a functionality. I seldom to never used transfers for more than 10 bytes. Do you know any sensor that uses burst transfers of more than 10 bytes?

If you use the I2C interface as a replacement for a UART communication you might have to ask yourself if you're using the right communication channel for the job...

have a look at Eeprom24C32_64 library
It was used in save alarm time post #24 to write a 302 byte structure to EEPROM

the libraray deals with limitations such as I2C buffer size and EEPROM page size which may help in your application

rea104:
Hello,

Where is the opening { of your code snippet?