How to use acquireWireBuffer()

I want to read more than 32 bytes from the Wire library. In the reference I see mention of acquireWireBuffer() to create a config with a larger buffer, but I don’t see how to use that. How do I pass that struct into Wire? Or perhaps I’m not understanding this at all?

Hi,

  1. copy the entire example from here:
    acquireWireBuffer - Wire (I2C) | Reference | Particle to your sketch
  2. set constexpr size_t I2C_BUFFER_SIZE to whatever size you need e.g.: 64
  3. in setup call acquireWireBuffer(); then hal_i2c_init(HAL_I2C_INTERFACE1, &config); (if you are using Wire interface) and the last one MY_I2C_DEV.begin();
  4. Make sure that the Lib. which you are using with your I2C_dev doesn’t define somewhere in header the buffers size, if this is the case change it as well to correct size.
    Hope that will help
    Best,
2 Likes

This worked great. I used it to connect the person sensor from Sparkfun https://www.sparkfun.com/products/21231

Their supplied code does not work:

https://github.com/usefulsensors/person_sensor_arduino

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.