Storing Serial Data as a Variable or a float for GPS location

Hello everyone, I'm trying to make a code for data storing.
I'm trying to store a GPS coordinate as a temporary variable or float for later use. So basically, I want the arduino to save a GPS coordinate that is coming in the Serial monitor.

I don't have a code yet so I would appreciate some advises or reference or whatnot to start my code.
I am not familiar with the "Serial" portion of arduino programming so a help would be deeply appreciated.

For now what I understood is how to grab a data that you typed in the serial monitor.
Like this:

while(Serial.available()> 0){
    delay(10);
   char c = Serial.read();
   readString  += c;
  }
   
   if(readString.length() > 0){
     Serial.println(readString);
     readString="";

that code doesn't seem to print out what is being printed out before it.
for example:

void setup(){
Serial.begin(9600);
Serial.println("hello");
}
.
.
.
 while(Serial.available()> 0){
    delay(10);
   char c = Serial.read();
   readString  += c;
  }
   
   if(readString.length() > 0){
     Serial.println(readString);
     readString="";

I added a serial print for "hello" and once the hello prints in the serial monitor, the code doesn't seem to print out hello as well.

I am attempting to basically read what was in the serial monitor and then store it as a variable or a float.

Regards,

Serial.println("Hello") sends the word to the Serial monitor. It does not send anything back to the Arduino. You have to do that yourself.

I suspect your problem is that the Arduino is checking for characters far faster than you are sending them.

while(Serial.available()> 0){ will do nothing if there is not already at least one character in the input buffer. And if it finds 1 character it will end if the next check (a few microseconds later) shows the buffer is empty.

You need a more reliable way of detecting there is data available and reading it. Look at the Arduino code in this demo. It should be straightforward to modify it to meet your needs. You can use the Arduino code unmodified with the Serial monitor - it does not need the Python program.

...R

Ohhh... I didn't know that!

Let me rephrase what my intentions are...
I want to store whatever is written in the Serial Monitor to a variable.

Like the "Hello", it just appears in the monitor, and I would like the arduino to store the "hello" as a variable without me typing anything...

Is that possible?

If something appears in the Serial Monitor, the Arduino sent it. So whatever was printed is already stored as a variable or a contant in the Arduino program.

How are you planning to capture the GPS information? If with TinyGPS, there are function calls to return the current latitude and longitude, for example.

Thanks for the quick reply

I am using NMEA library, so basically I plan on making the autonomous vehicle go through waypoints and if an “if” statement occurs the vehicle will remove itself from the waypoints and proceed to another waypoint, and once the “if” statement is over, I plan on making it return to its previous location where the vehicle left off.

EDIT

I actually found a different way to do it, or an idea of what to do instead of reading off the serial monitor. thanks jremington for giving me a clue.

now this time, I want to grab the coordinates directly from arduino, and then store it into a variable without going through the serial monitor, how can I store a data from arduino into a variable directly?

then store it into a variable without going through the serial monitor, how can I store a data from arduino into a variable directly?

What data? What variable? On what computer?

Again: anything that is printed to the serial monitor by an Arduino program is ALREADY stored in the Arduino, and is sent to the serial monitor (via the serial port) by the Arduino.

Perhaps he could send us a link to the GPS system he's using. Somewhere in this world there is a document that says what the Data Format is. I tend to see more devices sending back HEX bytes, as for example the DHT11 temp sensor does.

If you want to print a string that is stored: (To answer what I think you were asking)

char* Msg ={"ERROR","VOID","HELLO"};

Serial.print(Msg[0]); // This prints ERROR
Serial.print(Msg[1]); // This prints VOID
Serial.print(Msg[2]); // This prints HELLO

jordano00:
I want to grab the coordinates directly from arduino, and then store it into a variable without going through the serial monitor, how can I store a data from arduino into a variable directly?

You are not describing what you want to do clearly. Your use of language leaves us confused about what the data is coming from and where it is going to.

When you say "from the arduino" that suggests to me that the arduino is sending data to something - but you have not said what the something is.

...R