Problem sending byte array to Arduino over serial

Hi there. I am trying to send a byte array to an arduino via serial. the array represents a jpeg image.i generated it by converting the image to hex values separated by commas.I chose this because this is what the arduino sketch is using.(I am writing data to a TFT screen) My first problem is that when i try to paste in the array of hex into the byte array there are certain values which are rejected. this i believe is because processing wont allow anything above 128(it is signed rather than unsigned). i thought i could get around this by storing the data as an int array initially and then converting them into bytes before i send them. unfortunately this wont work because i get the error “The code of constructor sketch_210206b() is exceeding the 65535 bytes limit”.This i assume is because its a large array. So I am stuck! Any help would be much appreciated, thanks.

Hi i solved it in the end using the loadBytes() function as per:
byte[] data = loadBytes("data.dat");
where data.dat is in a folder ‘data’ in the sketch folder

1 Like

I recently struggled with a similar thing. I tried sending a byte array of length 80 over the Serial bus, but the Arduino would only pick up on the first 63 bytes, so I had to split the array into two parts with length 40 each, and send both seperately. Converting the jpeg image into a byte array should be possible, but you need to get clever to somehow chop it up into byte arrays that don’t exceed some maximum length (try different threshholds like 64, 128, 256, 2048, 65536) that you send over individually. I recommend you make the first 1-2 bytes of the array an index to denote which part of the the complete image this byte array represtends, so the arduino can but it all back together. Note however that an Arduino doesn’t exactly have a lot of RAM.

I hope this could help you,
Simon