Esp32-wroom-32d + iic

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.

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

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

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.

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.