Breakout Arduino Parsing using Adafruit Ultimate GPS

Hi all,
Im new in Arduino programming and i have quite a problem which is save longitude and latitude values of my new Adafruit Ultimate GPS Breakout. im using the tutorial giving in the website then i tried to apply parsing code in the library
Open up the File→Examples→Adafruit_GPS→parsing sketch and upload it to the Arduino. Then open up the serial monitor.
i got the results in my serial monitor as shown in the attached file (i highlighted my question in the snap below)

Im trying to save the values of my location in the degree which is appear in the serial monitor as
Location (in degrees, works with Google Maps): 32.5011, 44.4499

the standard code for display result is

Serial.print("\nTime: ");
    Serial.print(GPS.hour, DEC); Serial.print(':');
    Serial.print(GPS.minute, DEC); Serial.print(':');
    Serial.print(GPS.seconds, DEC); Serial.print('.');
    Serial.println(GPS.milliseconds);
    Serial.print("Date: ");
    Serial.print(GPS.day, DEC); Serial.print('/');
    Serial.print(GPS.month, DEC); Serial.print("/20");
    Serial.println(GPS.year, DEC);
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.println((int)GPS.fixquality); 
    if (GPS.fix) {
      Serial.print("Location: ");
      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
      Serial.print(", "); 
      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
      Serial.print("Location (in degrees, works with Google Maps): ");
      Serial.print(GPS.latitudeDegrees, 4);
      Serial.print(", "); 
      Serial.println(GPS.longitudeDegrees, 4);
      
      Serial.print("Speed (knots): "); Serial.println(GPS.speed);
      Serial.print("Angle: "); Serial.println(GPS.angle);
      Serial.print("Altitude: "); Serial.println(GPS.altitude);
      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);

next i tried to define 2 varaible in order to copy the longitude and latitude value by adding simple code after the

Serial.print("Location (in degrees, works with Google Maps): ");
      Serial.print(GPS.latitudeDegrees, 4);
      Serial.print(", "); 
      Serial.println(GPS.longitudeDegrees, 4);

      lat1= (GPS.latitudeDegrees, 4);
      lon1=(GPS.longitudeDegrees, 4);
      Serial.println (lat1);
      Serial.println (lon1);
      delay (500);

then i got the result as shown in the 2nd picture in the attached file which print just the number (4)

then i edit the code as:

Serial.print("Location (in degrees, works with Google Maps): ");
      Serial.print(GPS.latitudeDegrees, 4);
      Serial.print(", "); 
      Serial.println(GPS.longitudeDegrees, 4);

      lat1= GPS.latitudeDegrees;
      lon1=GPS.longitudeDegrees;
      Serial.println (lat1);
      Serial.println (lon1);
      delay (500);

then i got only 2 number after the dot
32.5011 → 32.50
44.4499 → 44.45
as shown in the attached file

so im asking how can i save the full number in my lon1 and lat1 becuse i nedd these number for further analysis

thank you all


then i got only 2 number after the dot

      lat1= GPS.latitudeDegrees;

lon1=GPS.longitudeDegrees;
      Serial.println (lat1);
      Serial.println (lon1);

==> that’s because printing a float only shows two decimals by default.

use

      lat1= GPS.latitudeDegrees;
      lon1=GPS.longitudeDegrees;
      Serial.println (lat1,6);
      Serial.println (lon1,6);

and you’ll get 6 decimals.

that’s in the print documentation and you’ve done it with 4 digits when you did

Serial.print("Location (in degrees, works with Google Maps): ");
Serial.print(GPS.latitudeDegrees, 4);
Serial.print(", "); 
Serial.println(GPS.longitudeDegrees, 4);

Thank you for your reply, i appreciate that.
Actually i the real problem is not printing, as when I print the output using serial monitor, there is no problem, but I want to store the resulting values in a variable in order to send it later, when I put the output with a variable for the purpose of storing things do not go well.
I did a simple experiment based on your parameters, where you can notice that when I print it there is no problem, but when I put it in a variable it does not work.

I’m not sure what to look for ? You get 6 digits as expected

Don’t post pictures of text... just copy paste (using code tags for the code) and explain what you see and what you expect to be different

I want to store the value in a specific variable, then this value I send it using a wireless transmitter for the purpose of applying the Haversine formula to calculate the distances between two devices, so it is not important for me to display the value in the Serial Monitor, but the important thing is to transmit the entire data through the transmitter for both lat1 and lon1. If i send lat1 and lon1 what did you expect to receive at the receiver since it is look by defaults to only showing me 2 of the decimal places.

Serial.print("\nTime: ");
    Serial.print(GPS.hour, DEC); Serial.print(':');
    Serial.print(GPS.minute, DEC); Serial.print(':');
    Serial.print(GPS.seconds, DEC); Serial.print('.');
    Serial.println(GPS.milliseconds);
    Serial.print("Date: ");
    Serial.print(GPS.day, DEC); Serial.print('/');
    Serial.print(GPS.month, DEC); Serial.print("/20");
    Serial.println(GPS.year, DEC);
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.println((int)GPS.fixquality); 
    if (GPS.fix) {
      Serial.print("Location: ");
      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
      Serial.print(", "); 
      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
      Serial.print("Location (in degrees, works with Google Maps): ");
      Serial.print(GPS.latitudeDegrees, 4);
      Serial.print(", "); 
      Serial.println(GPS.longitudeDegrees, 4);
      float lat1,lon1,x,y;
      lat1= GPS.latitudeDegrees;
      lon1=GPS.longitudeDegrees;
      Serial.println ("TEST");
      Serial.println (lat1,6);
      Serial.println (lon1,6);
      x= (lat1,6);
      y= (lon1,6);
      Serial.println (x);
      Serial.println (y);

For example:
x value if i use x= (lat1,6); it will save not 6 decimal places but it will save only 6
x value if i use x= (lat1); it will save only 2 decimal places

If x is a float, then;

Serial.println (x);

Will print it to two decimal places as pointed out in post #1.

the data in memory is the simple precision floating point in IEEE representation on 4 bytes (what the type float is on your arduino)

The way you print it is just a human representation of that value

how do you plan to send it through the transmitter?

=> you need to send either in ASCII with 6 digits so that you get the full precision or alternatively just send in binary mode the 4 bytes and you'll get the very exact value on the other side as a IEEE single precision float.