GPS varying Output

I am designing an autonomous Robot based on GPS but as i am displaying THE GPS data on LCD its showing me varying Latitude and Longitude tell me how can i fix it

// This is my first very simple GPS navigation tool, that
// was written for my Wiring board. It connects to a GPS
// module via port Serial1 (4800bps) and shows some very
// basic navigation information on a character-based LCD.
// The information shown is:
// - direction to destination, relative to own movement
// - distance to destination in meters (it is really
//   easy to do kilometers, miles, etc.)
// - my current speed in kilometers per hour
// - GPS status identifier
//
// I tried it in my car, and it works perfectly, although
// it's quite useless. The code below uses the Wiring
// board diagnostic LED on pin 48, which does not exist
// on Arduino's -- be aware.
#include <math.h>
#include <nmea.h>
#include <LiquidCrystal.h>
#include <NewSoftSerial.h>

NewSoftSerial mygps(7, 8);
// create connection to GPRMC sentences from my GPS
NMEA myGPS(GPRMC);
// create LCD object (I use a 2x16 character display)
LiquidCrystal myLCD = LiquidCrystal(12, 11, 5, 4, 3, 2);

// my destination coordinates in signed degrees-decimal
float dest_latitude = 25.362023;
float dest_longitude = 68.355542;  
//25.362023, 68.355542?
void setup() {
  
 myLCD.begin(16,2);
  mygps.begin(4800);
  pinMode(13, OUTPUT);  // diagnostic led on Wiring-board
  myLCD.clear();
  myLCD.home();
  myLCD.print("GPS-NAV By Eshu");
  delay(1000);
  
}
void loop() {
  // check if data from GPS available on Serial1 port
  if (mygps.available() > 0 ) {

    // check if full sentence recieved from GPS
    if (myGPS.decode(mygps.read())) {
      // if so, set status led on
      digitalWrite(13, HIGH);
         
      // calculate direction to destination, relative to my own direction of movement
      float lat = myGPS.gprmc_latitude();
      float longi = myGPS.gprmc_longitude();
      
      myLCD.clear();
      myLCD.home();
      myLCD.setCursor(0, 0);
      myLCD.print("lat:");
      myLCD.print(lat);
      myLCD.setCursor(0, 1);
      myLCD.print("longi:");
      myLCD.print(longi);
      myLCD.setCursor(15, 1);
      myLCD.print(myGPS.gprmc_status());

}
  }
}

its showing the output up to 10 digits

How much is it varying by? If it's a few meters/feet then that normal.

Its output is last 4 to 5 digits are varying e.g 25.3750023 the Bold digits are continously varying

its showing 10 digits after Point what can i do know

its showing 10 digits after Point what can i do know

What does "it" show if you change lat and long from float to double?

The position from a GPS receiver will drift continuously, due to inaccuracies in the system and the fact that the constellation is moving.

Part of the GPS inaccuracy is due to atmospheric conditions, which are constantly changing, causing propagation delays and errors in the resulting the calculation. That error changes with time, as the satellites move overhead.

This phenomenon is usually called drift. The drift will be worse if you have a poor signal, reflections (multipath), etc.

At a previous employer, we called this a WAD problem - it Works As Designed. :slight_smile:

-j

what do you mean if its showing the variation how can i fix it or round it

what do you mean if its showing the variation how can i fix it or round it

You can't fix it because it isn't broken. That's just how it works.

You can easily truncate (not the same as rounding) by chopping digits off the end. To round, you'll need to convert from a string to a number.

-j

P.S. Try using some punctuation. This isn't SMS or IM.

How ..... to chop off the digits?

How ..... to chop off the digits?

Under what circumstances? When displaying the value somewhere? If so, that depends on the display class being used. If the class derives from Print, the Print::print() method that prints a float takes two arguments - one mandatory (the float to print) and one optional - the number of digits after the decimal point.

Chopping off digits for any other purpose is not possible. Get over it.

sir Why the output of GPS varying Plz tell me

or From which library i can get GPGGA

Why the output of GPS varying Plz tell me

Weren't you paying attention any of the other times?

Sorry Sir I dont get ti

Assuming the device is outside in an open sky, how much variation (in meters) would be acceptable for your design?

This is probably too technical for you, but it discusses all the things that lead up to the small variation you are seeing.

Assuming the device is outside in an open sky, how much variation (in meters) would be acceptable for your design?

And how much are you seeing?

Show some serial output, not another out of focus, poorly lit, often blocked, view of an LCD.

Sir we are designing an autonomous Robot based on GPS and our steering will move according to the direction and distance of the waypoints but our GPS is showing Varied output in terms of direction Hence the Steering will get confuse too

cutebuddy6:
Sir we are designing an autonomous Robot based on GPS and our steering will move according to the direction and distance of the waypoints but our GPS is showing Varied output in terms of direction Hence the Steering will get confuse too

We need to see some numbers

So you need to manipulate the #s then.
Try averaging 10 samples to smooth out the result.