user18574: I want to read strings from Serial.read() to send them later.
To get the data from the Serial monitor I'm doing this:
String stringOne  = "";
int  incomingByte; 

if (Serial.available() > 0) {   

  while(Serial.available() > 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }

  Serial.println(stringOne);
  stringOne = "";

The issue is that when I type:
'a'

I got:
'97'

for 
    'abc' 
I got
'979899'

so on and so forth.
What should I do in order to get the same string I type?

user16299: Instead of using: 
while(Serial.available() > 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }

Use the following to cast them to character:
while(Serial.available() > 0)
  {
     char incomingByte= Serial.read();
     stringOne.concat(incomingByte));
  }
Serial.println(stringOne);
stringOne="";


user19152: You're adding the ASCII value of each char to your string, hence you get numbers. See the various String constructors at:
https://www.arduino.cc/en/Tutorial/StringConstructors
Either cast the read byte to a char:
stringOne = String(stringOne + String((char)incomingByte));

or consider receiving characters as chars, instead of ints:
char incomingByte; 

There is a perfectly valid one-method call which does all of this hassle easier and more efficiently: https://www.arduino.cc/en/Serial/ReadStringUntil
Note that you'll sooner or later anyhow have to add a framing prototcol. For example, you're sending down text commands to Arduino, and each command is separated by a new line character. ReadStringUntil will handle that very nicely.

18574: <p>I want to read strings from <code>Serial.read()</code> to send them later.</p>

<p>To get the data from the Serial monitor I'm doing this:</p>

<pre class="lang-c prettyprint-override"><code>String stringOne  = "";
int  incomingByte; 

if (Serial.available() &gt; 0) {   

  while(Serial.available() &gt; 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }

  Serial.println(stringOne);
  stringOne = "";
</code></pre>

<p>The issue is that when I type:</p>

<pre><code>'a'
</code></pre>

<p>I got:</p>

<pre><code>'97'
</code></pre>

<p>for 
    'abc' </p>

<p>I got</p>

<pre><code>'979899'
</code></pre>

<p>so on and so forth.</p>

<p>What should I do in order to get the same string I type?</p>
 16299: <p>Instead of using: </p>

<pre><code>while(Serial.available() &gt; 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }
</code></pre>

<p>Use the following to cast them to character:</p>

<pre><code>while(Serial.available() &gt; 0)
  {
     char incomingByte= Serial.read();
     stringOne.concat(incomingByte));
  }
Serial.println(stringOne);
stringOne="";
</code></pre>
 19152: <p>You're adding the ASCII value of each char to your string, hence you get numbers. See the various String constructors at:
<a href="https://www.arduino.cc/en/Tutorial/StringConstructors">https://www.arduino.cc/en/Tutorial/StringConstructors</a></p>

<p>Either cast the read byte to a char:</p>

<pre><code>stringOne = String(stringOne + String((char)incomingByte));
</code></pre>

<p>or consider receiving characters as chars, instead of ints:</p>

<pre><code>char incomingByte; 
</code></pre>

<p>There is a perfectly valid one-method call which does all of this hassle easier and more efficiently: <a href="https://www.arduino.cc/en/Serial/ReadStringUntil">https://www.arduino.cc/en/Serial/ReadStringUntil</a></p>

<p>Note that you'll sooner or later anyhow have to add a framing prototcol. For example, you're sending down text commands to Arduino, and each command is separated by a new line character. ReadStringUntil will handle that very nicely.</p>
