Skip to main content
added 100 characters in body
Source Link
KIIV
  • 4.8k
  • 1
  • 13
  • 21

There is no maximum length for sending/receiving in I2C. It is the Wire library BUFFER_LENGTH 32 macro, causing this limitation.

You can either copy some code from Wire library and implement your own requestFrom function which will store data directly to your cmdInStr string buffer or you can change Wire.h to have bigger BUFFER_LENGTH.

Or another way is to extend Wire.h like this:

#ifndef BUFFER_LENGTH
#define BUFFER_LENGTH 32
#endif

and in your sketch:

#define BUFFER_LENGTH 180
#include <Wire.h>

All depends on your preferences, but implementing own requestFrom and storing it directly into your cmdInStr buffer will be little bit more efficient than copying it into Wire buffer and then into your own buffer again.

And do you really need all these data in one string, isn't it possible to proceed it on the fly?

There is no maximum length for sending/receiving in I2C. It is the Wire library BUFFER_LENGTH 32 macro, causing this limitation.

You can either copy some code from Wire library and implement your own requestFrom function which will store data directly to your cmdInStr string buffer or you can change Wire.h to have bigger BUFFER_LENGTH.

Or another way is to extend Wire.h like this:

#ifndef BUFFER_LENGTH
#define BUFFER_LENGTH 32
#endif

and in your sketch:

#define BUFFER_LENGTH 180
#include <Wire.h>

All depends on your preferences, but implementing own requestFrom and storing it directly into your cmdInStr buffer will be little bit more efficient than copying it into Wire buffer and then into your own buffer again.

There is no maximum length for sending/receiving in I2C. It is the Wire library BUFFER_LENGTH 32 macro, causing this limitation.

You can either copy some code from Wire library and implement your own requestFrom function which will store data directly to your cmdInStr string buffer or you can change Wire.h to have bigger BUFFER_LENGTH.

Or another way is to extend Wire.h like this:

#ifndef BUFFER_LENGTH
#define BUFFER_LENGTH 32
#endif

and in your sketch:

#define BUFFER_LENGTH 180
#include <Wire.h>

All depends on your preferences, but implementing own requestFrom and storing it directly into your cmdInStr buffer will be little bit more efficient than copying it into Wire buffer and then into your own buffer again.

And do you really need all these data in one string, isn't it possible to proceed it on the fly?

Source Link
KIIV
  • 4.8k
  • 1
  • 13
  • 21

There is no maximum length for sending/receiving in I2C. It is the Wire library BUFFER_LENGTH 32 macro, causing this limitation.

You can either copy some code from Wire library and implement your own requestFrom function which will store data directly to your cmdInStr string buffer or you can change Wire.h to have bigger BUFFER_LENGTH.

Or another way is to extend Wire.h like this:

#ifndef BUFFER_LENGTH
#define BUFFER_LENGTH 32
#endif

and in your sketch:

#define BUFFER_LENGTH 180
#include <Wire.h>

All depends on your preferences, but implementing own requestFrom and storing it directly into your cmdInStr buffer will be little bit more efficient than copying it into Wire buffer and then into your own buffer again.