How to read 4800 byte from Serial1 Rx on Arduino Leonardo?

Hi there,

In my project I use a ttl camera to take a RAW images and then i need to send the image via bluetooth to an Android device.
The problem is that the data i should read from the camera on serial1 rx are 4800 bytes and the rx buffer is 256 bytes, so I only can read 256 bytes max. Any one can lead me to some idea to send the all 4800 bytes?

Thans for help,

The problem is that the data i should read from the camera on serial1 rx are 4800 bytes and the rx buffer is 256 bytes

What RX buffer is 256 bytes?

The serial buffers are 64 bytes for incoming and outgoing serial data. Data can be read far faster than it arrives, so the buffer should never get full.

Hi PaulS,

Thanks for your respons, I allready changed the buffer size in HardwareSerial.cpp from 64 to 256 . Can you just tell me how to read data faster than its arrives?

I do like that:
int byteCnt=0;
byte data[4800];
while (Serial1.available() > 0){
data[byteCnt]= Serial1.read();
byteCnt++;
}

Can you just tell me how to read data faster than its arrives?

Tardis?

The first question to answer is do you need to buffer the image on the Arduino (i.e. will you throw away the image if there is no Bluetooth connection?). The next question to answer is can you send over Bluetooth as fast as you are receiving from the camera? If so, then just read some data from the camera and send to Bluetooth, repeat until entire image is sent. If not, does the camera support flow control so you can slow it down? If not then you will need to buffer the entire image on Arduino. You can't buffer in Arduino's memory so you will need to use some external device (SRAM, EEPROM , Flash etc.).

Thank you guys,
Now its working ... I was reading slow so the buffer get full.

byte data[4800];

On a Leonardo with 2.5K of SRAM? I don't theenk so.