Serial communication between 2 arduinos

I need to create a serial communication between 2 arduinos (Uno).

The first arduino will receive data from the pc and will transfer it to the second arduino. The second arduino will sent it back to the first arduino. Finally the first arduino will transfer the data (from the second arduino) to pc.

I have a little confuse.

Firstly is needed to use software serial (i am using Arduino UNO) ?
Second for the first step (transfer data from pc to first arduino) what is the best format of the data? for example to connect it as string is a good way? can i sent strings from first arduino to the second ?

Use SoftwareSerial on both Arduinos to keep Serial (pins 0 and 1) free for communication with the PC.

The 3rd example in Serial Input Basics will be a reliable way to receive the data.

...R

If one of the Arduinos is performing a two-way transfer with a PC, plus a two-way transfer with another Arduino, you have no choice but to use SoftwareSerial (or equivalent). The Uno only has one hardware serial port and you should keep it free for debugging and downloading. The Uno that "talks" to the PC and "talks" to the other Arduino should use SoftwareSerial (or equivalent) for both of these communications, but SoftwareSerial can only listen to one at a time. I hope that your protocol takes this into consideration.

An alternative would be for an Uno to use hardware serial to "talk" to one device (say, the PC) and use SoftwareSerial to "talk" to the other device (say, the other Uno), but this will really complicate your life when you want to download or debug.

An alternative would be for an Uno to use hardware serial to "talk" to one device (say, the PC) and use SoftwareSerial to "talk" to the other device (say, the other Uno), but this will really complicate your life when you want to download or debug.

How?

If SoftwareSerial is being used to talk to the other Arduino, that can't interfere with uploading a new sketch.

It's difficult to use SoftwareSerial to talk to the PC, since it uses TTL levels, which the USB to serial converter, used by the hardware serial instance, manages. So, the only reasonable way to talk to the PC is using the hardware serial port and USB cable.

That communication can't interfere with uploading code.

It will mean that whatever application is listening to the serial port will have to be able to display debug messages, and to distinguish debug messages from other messages meant for the application. But that's a fact of life.

You can use I2C to achieve the communication of 2 Arduinos. The connect to PC could use Ethernet or Serial. Serial is easy,in my mind.

I used softwareserial and the code is working when i tried to sent integer numbers from the first arduino to the other arduino.

I need to sent data (as string) for this i need to change the code line bellow:

int data = mySerial.parseInt();

how to change it, so the variable data will be able collect as string ??

how to change it, so the variable data will be able collect as string ??

Perhaps using the readString() method? Just a guess, as I'm smart enough to write the code myself.

Interesting reading: https://forum.arduino.cc/index.php?topic=288234.0