Wire.requestFrom(add, length ); needs more detail

I would like to see the documentation updated for I2C for Wire.requestFrom(address, quantity);

The documentation states:
address: the 7-bit address of the device to request bytes from
quantity: the number of bytes to request

This gives the impression that quantity could at the very least be up to 255.
Which it cannot, its max is set by #define BUFFER_LENGTH 32
So anyone trying to read or write more than BUFFER_LENGTH will have a problem.

The docs should add a note saying something to the effect of the default BUFFER_LENGTH is set at 32, should you wish to change it please see spark_wiring_i2c.h.

I fell that this can cause a possible problem for users that are not going deep into the code but rather just using the cloud IDE.

2 Likes

Hi @seulater - isn’t this the same as Arduino? https://github.com/arduino/Arduino/blob/master/libraries/Wire/Wire.h

Happy to provide better documentation, but I do notice that both our implementation and documentation are the same as Arduino’s in this respect, so I wonder if this is an issue people run into on Arduino as well.

1 Like

@Zach, Actually I have no idea. I don’t do anything with Arduino.

Actually it IS the same in Arduino - which I learned the hard way when trying to use an Omron 4x4 IR sensor. This guy sends its data as 35 Bytes so I had to patch that Wire.h file…