Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Wire library BUFFER_LENGTH - is there a good way to change it?

  1. #1
    Junior Member
    Join Date
    Nov 2012

    Wire library BUFFER_LENGTH - is there a good way to change it?

    The wire library (Wire.h) hard codes the buffer length to 32.

    I can edit wire.h but my code is hard for others to use (they have to know to edit it too). Is there some "project specific" way to change the I2C buffer length?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    I don't see any obvious ways. It is interesting that with the i2c_t3 library the default sizes are 259 bytes and wire it is 32...

    Wonder if maybe we should make the default in wire maybe depend on which processor...

  3. #3
    Junior Member
    Join Date
    Jun 2019
    I recently encountered this same issue. We use a LOT of Teensy devices at my company in custom dev-kits to help our customers learn how to interface to our devices. Now that we need I2C transactions that exceed 32 bytes, there is no good way to share solutions with our customers without having them go into \Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\ and change Wire.h and twi.h directly. We have already had customer-service issues arise when they overlooked this obscure step.

    If there isn't already a solution that is constrained to the sketch's source code, I would suggest writing an overload to Wire.begin() (or adding a new Wire.assignBuffer() method) that takes a pointer to a buffer and a length parameter. Then the user can allocate their own buffer and configure Wire.h for their special cases.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts