How to display text sent via RX TX serial line?

I'm sending data (over 9600) from one arduino to another and I can't retrieve everything that Arduino sends. However, I only send one line and I need to display it.

This will print me some numbers in a row, instead of the text and the characters I send one of them.

Can you handle functional script?

void loop()
{
  if (Serial.available() > 0)
  {

   String readString=Serial.read();

   Serial.println(readString);
  }
}

(deleted)

How about posting the ending and receiving programs in full together with a sample of what is being sent and what is being displayed ? A description of the connections between the two Arduinos, or even better, a circuit diagram, would be interesting too.

The serial input basics tutorial may be informative.

How can I do that? I don't know much :frowning:
I found this on the internet:

while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the String readString
delay(2); //slow looping to allow buffer to fill with next character
}

spycatcher2k:
So you wait for 1 byte, grab it and print it with a line feed!

Read and store until you get an end of line, THEN print.

How can I do that?

How can you do what?

If you have control over the sender, then Robin2's tutorial (see reply #3) is a great place to start.

This will print me some numbers in a row, instead of the text and the characters I send one of them.

It would be in your best interest to learn what read() returns. It would be in your best interest to learn what String does with an int, vs. what it does with a character.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

…R

cevepe:
I'm sending data (over 9600) from one arduino to another and I can't retrieve everything that Arduino sends. However, I only send one line and I need to display it.

Let us try to send this alphanumeric string: "141-142 Love Road" from Arduino UNO-1 to Arduino UNO-2 at 1-sec interval using Software UART Ports (SUART) as hardware UART Ports (UART) are permanently engaged with Serial Monitors and IDEs for 'program debugging' and 'program uploading' activities.

1. Connection diagram between UNO-1 (the sender) and UNO-2 (the receiver)
uartUnoUno-23.png
Figure-1: SUART Port based connection between two UNos

2. Upload the following sketches into UNO-1 and UNO-2.
(1) Sender's Sketch

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX = DPin-2; STX = DPin-3

char myMsg[] = "141-142 Love Road";
void setup() 
{
  Serial.begin(9600);
  SUART.begin(9600);
}

void loop() 
{
  Serial.print("Sending to UNO-2 this string: ");
  Serial.println(myMsg);   //show on SM1 of Fig-1 what you are sending to UNO-2
  //--------------------
  SUART.println(myMsg);   //send ASCII coded string to UNO-2 via SUART Port; goes 1 char at a time
  delay(1000);          //1-sec test interval
}

(2) Receiver's Sketch

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX = DPin-2; STX = DPin-3

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);
}

void loop()
{
  byte n = SUART.available(); //check if a character has arrived via SUART Port
  if (n != 0) //a charctaer has arrived; it has been auto saved in FIFO; say 1 as 0x31
  {
    char x = SUART.read(); //read arrived character from FIFO (say 1) and put into x as 0x31 
    Serial.print(x);  //send 0x31 to Serial Monitor to show 1 via UART Port
  }
}

3. Screenshots
(1) Sender's
sm127.png

(2) Receiver's
sm128.png

BTW:
1. Try to repeat the above communication process using the following instruction at the receiver sketch:

SUART.readBytesUntil('\n', rcvMsg, 50);

2. Try to repeat the above communication process by receiving the string from the InputBox of the Serial Monitor of Sender rather than having the string coded in the sketch. Do not forget to select 'Newline' option in the 'Line ending tab' of the Serial Monitor to mark the end of the string.
SerialMonitor.png

uartUNO-2.png

sm127.png

sm128.png

SerialMonitor.png