Skip to main content
2 of 2
deleted 3 characters in body
Juraj
  • 18.3k
  • 4
  • 32
  • 50

In the comment you write that the receiving end is an Arduino too. Then you can send the data in binary form.

To send the array:

Serial.write((byte*) arr, sizeof(arr));
  • (byte*) is cast of the memory location of arr to a byte array
  • sizeof returns the size of the array in bytes

To receive the binary data you must know the size. Here we read 100 16-bit integers:

Serial.readBytes((byte*) arr, 100 * sizeof(short));

Function readBytes is one of the 'timed' functions of Stream. It waits for the next byte (until timeout).

If one Arduino is 8-bit and the second is 32-bit, then use the type short instead of int, because the size of type int is different, but the type short is 16 bit long on all Arduinos.

Juraj
  • 18.3k
  • 4
  • 32
  • 50