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
A part of 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);
the results is shown below
next i tried to define 2 variable in order to copy the longitude and latitude value by adding simple code after the Serial.println(GPS.longitudeDegrees, 4); as shown below
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 only number four in my lat1 and lon1 value in serial monitor
then i edit the code by removing number 4 from it as shown below
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 below
so im asking how can i save the full number in my lon1 and lat1 because i need these number for further analysis
BTW i tried to defie lon1, lat1 as float, double and still same issue just 2 number after digit i got
thank you all