# Esp32-wroom-32d + iic

**URL:** <https://forums.freertos.org/t/esp32-wroom-32d-iic/14876>\
**Category:** Libraries\
**Created:** [April 16, 2022, 8:56pm UTC](https://forums.freertos.org/t/esp32-wroom-32d-iic/14876 "2022-04-16T20:56:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill-richards](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/bill-richards/32/1521_2.png) [@bill-richards](https://forums.freertos.org/u/bill-richards)\
**Post date:** [April 16, 2022, 8:56pm UTC](https://forums.freertos.org/t/esp32-wroom-32d-iic/14876/1 "2022-04-16T20:56:32Z")

</div>

Hi thee, I don’t know if this is the right place to be asking about this really, because the code I’m writing is dependent upon the _espressif32_ port and the _ESP32 I2C Slave_ library.

So the _espressif32_ port declares `#define I2C_BUFFER_LENGTH 1024` in Wire.h, which leads me to conclude that the maximum size for the IIC buffer is 1024 bytes.

The _ESP32 I2C Slave_ library redefines that `#define I2C_BUFFER_LENGTH 128` in WireSlave.h

I’ve rooted around the source for the library and can find no discernable reason why it has been redefined thus.

The net effect of this is that the iic message size is somewhat limited (to 128 bytes).

I’ve played around with the values (because it really does appear to be voodoo to me rather than something obviously mathematical), and I’ve settled on a redefinition of `#define I2C_BUFFER_LENGTH 1024` to match the underlying iic implementation.

The issue comes however when using this library and attempting to send a large amount of data. In fact, it cuts off at 251 bytes … which I cannot understand. I don’t know if I’m missing something really simple or if there are some specifics required at the OS level for large data packets.

I know it’s possible to send large data packeets over IIC since we use a NEO-8M GPS/GNSS module which communicates over IIC, and the data from that is I think in excess of 1024 bytes.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 16, 2022, 11:01pm UTC](https://forums.freertos.org/t/esp32-wroom-32d-iic/14876/2 "2022-04-16T23:01:06Z")

</div>

This doesn’t lol like a FreeRTOS question. I would recommend asking on the Espressif forum.

---

<div class="post-metadata">

**Author:** ![bill-richards](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/bill-richards/32/1521_2.png) [@bill-richards](https://forums.freertos.org/u/bill-richards)\
**Post date:** [April 17, 2022, 12:27am UTC](https://forums.freertos.org/t/esp32-wroom-32d-iic/14876/3 "2022-04-17T00:27:02Z")

</div>

You’re right @rtel, it was totally an Espressif question 😀

I went back to the MCU’s data sheet and found that the IIC module’s RAM is 32x8 bytes, and therein lies the hardware limitation, the strange value of 251 bytes accounts for the CRC.

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/a/acbb6e23dad48ea8206d3ca275f81cdd77731e9a.png)

I can only assume then that the library we use for controlling the NEO-M8 GNSS chip is doing some message reconstruction internally in order to give us messages larger than the 256 byte limit.

Thanks for pointing me in the right direction.
