Sending an array of bytes over I2C with Wire.h

I am using the Wire library to talk to another device, and I need to send 8 bytes of data (including any nulls) over the bus. I can't send them separately in sequence because of timing. I can't send them together because send() thinks that an array defined with char is a string and stops at the first null. If I define the array with byte, it says that "error: call of overloaded 'send(byte [8])' is ambiguous". However, the docs say that send() will accept:

Parameters

value: a byte to send (byte)

string: a string to send (char *)

data: an array of data to send (byte *)

quantity: the number of bytes of data to transmit (byte)

How do I get it to send an array of bytes or not stop at nulls? Thanks!

byte test[] = {1,2,3,4};
Wire.send(test,4);

? :slight_smile:

Works perfectly. Thanks!

How hard would it be to get that section of the docs clarified? The solution was not obvious after reading them through several times...