String is all messed up

Hi,

I'm using OpenMV to send some data(String) to Tennsy 3.2(Using UART). Tennsy receives a string just fine but when I want to read a single variable. It just reads a single digit, not a number as whole.
Arduino Code:

void updateCam(){
 
  if(Serial3.available()){
    String s;
    s = Serial3.readStringUntil('\n');

  
}
}

If I, for example, print a single part of String like this

Serial.println(s[0]);

I get this:

3

Instead of this:

34

And if I just print a string I get this:

Serial.println(s);
34 45 1

Can I somehow get the whole number with this:

Serial.println(s[0]);

Output

34

Robin2 has a great serial topic that talks about this sort of thing.

when I want to read a single variable. It just reads a single digit, not a number as whole.
s = Serial3.readStringUntil('\n');
If I, for example, print a single part of String like this

Serial.println(s[0]);

I get this: 3
Instead of 34
And if I just print a string I get: 34 45 1

Sorry, but all of those examples look like correct behavior. ReadStringUntil() reads a String, not "individual variables." indexing a String gets you an individual element, a char.

Ok, but is there any way of converting it to some thing useful

Well, lots of ways.
Easiest (but with some other problems) is to use the Serial.parseXXX() functions
https://www.arduino.cc/reference/en/language/functions/communication/serial/parseint/

You already got a pointer to a more power (and alas more complex) "Serial Input Basics" tutorial.

Thanks for the help, but can you help me a bit with that. Write some kind of example, of something like that. I'm not really into strings and that sort of things.

Anyway thanks for your time!!! :slight_smile: :slight_smile: :slight_smile: :slight_smile:

could this work??

String tmpS="";
tmpS= s.readStringUntil(' ');
Serial.println(tmpS);