Value = value * 1.8 and convert to string?

Hi, folks I am very new to arduino and I would like to see if anybody could help me on that...

Well. I am reading the serial and sending the info to a string variable.

I am doing this because I have learned the serial is readed char by char so I sent the values to a string variable.

This variable is comma delimited so, using strtok I can pick what I need.

One of the results is the speed(that comes in knots). I need to convert this speed in km/h so it will be...

Speed = Speed * 1. 8

My question is... How can I get the value(that is in String) , use the (* 1 . 8) and convert it again into string?

Any help will be appreciated.

Thank you guys...

To convert float to a string I use this:

char buffer[16];
String  StringVariable = dtostrf(FloatVariable,5,2,buffer);

Also look for strtof and atof

Hi. I Did and the result was kind of splitted… showing wrong values…

I just wanted to convert a String Variable into a float (because my value have decimal.)
After convert into a float, I need to do(value = value * 1.8)
After that, I need to convert into a String again because I need to print it.

---- heres the code I am using:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(6, 7); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.println("Hi there!");
  
  String info_from_gps ="2";
 // I want to multiply the "100" value that comes as String by 1.8
 // So I want to obtain 3.6 from this value
 // I think I will have to convert this value to float because there will have decimals on result , right?
 /// Well after that I need to print the result(3.6), so I think I will need to convert the result as string, right?
 
// Could you please give me an example about how to do this? 
   
}

void loop() // run over and over
{
  //
}

I need to convert the velocidade to a String variable

Any Idea?

THank you so much

The first thing that you need to clarify is if you are talking about strings or Strings. There is a world of difference between them.

heres the code I am using:

http://snippers-r-us.com might be able to help you (though I have my doubts). Here, we expect to see ALL of your code.

Hi, Paul. Thank you for asnwering me!

Here’s a code that explais what I need to do…

Thank you very much.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(6, 7); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.println("Hi there!");
  
  String info ="2";
 // I want to multiply the "2" value that comes as String by 1.8
 // So I want to obtain 3.6 from this value
 // I think I will have to convert this value to float because there will have decimals on result , right?
 /// Well after that I need to print the result(3.6), so I think I will need to convert the result as string, right?
 
// Could you please give me an example about how to do this? 
   
}

void loop() // run over and over
{
  //
}

Ditch the String class, use C strings and "atof"to convert the string to decimal.

AWOL:
Ditch the String class, use C strings and "atof"to convert the string to decimal.

Hi. AWOL. Thank you for yuor help.

Could you give me an example for this and if possible, an example to transform the result in String again for me to be able to print it?

Thank you so much :slight_smile:

an example to transform the result in String again for me to be able to print it?

You shouldn't need to convert a string to a String to print it. If you do, get rid of the crippled class that insists that Strings are the only way.

As for an example of using atof(), I'm sure that google has examples.