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!