Serial communication between two arduinos

I am trying to establish communication between two arduino using UART, boud rate is set to 115200 bps. But sometimes data is lost, what are the odds that data gets lost using UART with boud rate 115200bps?

So plan is to send char array (#1, #2, #3 ...) from one arduino to second arduino.

I am using folowing code lines for communciation

first arduino -> Serial1.print("#");
Serial1.print(purchaseNum);

second arduino -> if(Serial1.available()>0)
{
if(Serial1.read()=='#')
{
delay(1);
Number=Serial1.read()-48;
}
}
One of 20 bytes will get lost!
Are there some error cheching happening in Serial.read and Serial.print protocol or i have to write it by my self?

what are the odds that data gets lost using UART with boud rate 115200bps?

In what environment? At what temperature? Over what distance? The odds can range from nearly 0% to nearly 100%.

Are there some error cheching happening in Serial.read and Serial.print protocol

What error checking is appropriate in putting data in the outgoing buffer? What error checking is appropriate in copying a value from the incoming buffer?

No, those two functions do not do the kind of error checking that you think you need. There is error checking, but it happens in the interrupt that gets the data from the serial port and puts it in the incoming buffer.

I am using two MEGA2560 on PCB, room temperature and environment. Distance between them is 10cm, but RX and TX lines ar not same lenght on PCB, i thought it won't be a problem.

I was thinking to use parity bit, but parity bit is checking in hardware or i have to do cheking in software?

flippy1995:
I am using two MEGA2560 on PCB, room temperature and environment. Distance between them is 10cm, but RX and TX lines ar not same lenght on PCB, i thought it won't be a problem.

At that distance, or at 5 times that distance there should be 100% reliability. I presume your Tx and Rx wires are NOT twisted together - they should not be, but parallel should be fine.

Have you a GND connection between the two Megas?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R