I2C/Wire read buffer size after changing TWI_BUFFER_MAX


after changing TWI_BUFFER_MAX in (C:\Users\user\AppData\Local\Arduino15\packages\rak_rui\hardware\apollo3\4.0.0\cores\apollo3\component\rui_v3_api) Wire.h I still continued to receive only 32 Bytes on RAK11720

Using: RAKwireless RUI Apollo3 Boards V. 4.0.0


#define DEVICE_ADDRESS 0x10


#define DATA_LENGTH 64

/** Packet buffer for sending */

uint8_t collected_data[64] = { 0 };

void setup() {

  Serial.begin(115200, RAK_AT_MODE);


  Serial.println("Test I2C");


  // Start BLE UART advertisement for ever



  Wire.begin();                // join i2c bus (address optional for master)


 // Initialize the I2C communication



void requestdata() {





  Wire.requestFrom(DEVICE_ADDRESS, DATA_LENGTH); // Request 54 bytes from the device

  int i = 0;

  while (Wire.available()) {

    collected_data[i] = Wire.read(); // Read each byte and store it in the array



  Serial.printf("number of data: %d ", i);

   Serial.println("Data Packet:");

    for (int i = 0; i < DATA_LENGTH; i++) {

        Serial.printf("0x%02X ", collected_data[i]);




void loop() {




Hi @wilgaced ,

I have to check with our team about our low level implementation of Wire library.

Adding these two macros will not increase the size of I2C read.

#define BUFFER_LENGTH 64
#define TWI_BUFFER_MAX 64

I will get back to you if I get any info.

However, as a work around, maybe you can just split the memory locations like instead of reading 1 chunk of 64bytes, you can do two 32bytes.

Although we see online that people change the definition of BUFFER_LENGTH, this is not a scalable approach unless you create a new implementation of Wire library. The idea here is that once you send your code to someone else or use a different PC/laptop, the Wire library of that machine will be the default size and will not match your modified Wire library with bigger BUFFER LENGTH. I’ve experienced this before and really a painful one which consume troubleshooting time (well in fact it is caused by the undocumented library change).

Hi Carl

Unfortunately the device we are using sends 54 bytes in a read, so I need help to make this change in the library.

Best regards.

Hi Wilgaced,

I already created a ticket for this for our team to look at.

Have you tried reading locations 0 to 31 then 32 to 53 (total of 54 bytes).

Hi Carl

any news from the team?

The buffer will be changed to 64 bytes in the next release.
As parts of RUI3 are pre-combiled files, a change of the #define has actually no effect on the current RUI32 version.

Release of the next version is planned in the next weeks, we are still testing.