# Stream large array to I2C slave

**URL:** <https://forum.arduino.cc/t/stream-large-array-to-i2c-slave/659405>\
**Category:** Zero\
**Created:** [June 8, 2020, 4:26am UTC](https://forum.arduino.cc/t/stream-large-array-to-i2c-slave/659405 "2020-06-08T04:26:46Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pharaohamps](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@pharaohamps](https://forum.arduino.cc/u/pharaohamps)\
**Post date:** [June 10, 2020, 2:14am UTC](https://forum.arduino.cc/t/stream-large-array-to-i2c-slave/659405/4 "2020-06-10T02:14:15Z")

</div>

Here's tested and working code to send a large I2C transfer without allocating a larger transmit buffer. This code assumes that you have included Wire.h and called Wire.begin() in setup() to initialize the SERCOM and set up the pins. It also assumes that you're using SERCOM3 for I2C / Wire, which is default for the Zero. It doesn't do any kind of error checking or any of that, but it certainly could be adapted to do so.

```cpp
void writeLargeArray(byte deviceaddress, unsigned int datasize, uint8_t* data) {

 // uses raw I2C writes, rather than use the txbuffer
 sercom3.startTransmissionWIRE(0x30, WIRE_WRITE_FLAG);

 for (unsigned int i = 0; i < datasize; i++) {

// send one byte at a time from the array to the I2C device
   sercom3.sendDataMasterWIRE((byte) data[i]);
 }

// stop sending the data
 sercom3.prepareCommandBitsWire(WIRE_MASTER_ACT_STOP);

}

```

---

_[View the full topic](https://forum.arduino.cc/t/stream-large-array-to-i2c-slave/659405)._
