GPS delay of around 5 ish seconds

#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>


#include <Wire.h>
#include <LiquidCrystal_I2C.h> 

LiquidCrystal_I2C  lcd(0x27,20,4);

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPSPlus object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

float average = 0;
float Alpha = 0.3;
float speed;

long start = 0;

void setup()
{
  Serial.begin(9600);
  ss.begin(GPSBaud);

  
  lcd.init();
  lcd.backlight();
}

void loop()
{
  
  
  speed = gps.speed.kmph();
  average = average  * (1-Alpha) + speed * Alpha;
  Serial.print(average);

  if (millis()-start>=1000){
    lcd.setCursor(0,0);
    Serial.print(" -------- Dis: ");
    Serial.print(average);
    Serial.print("--------");
    lcd.print(average);
    start = millis();
  }  
  Serial.println("");
  
  smartDelay(100);

  if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS data received: check wiring"));
}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}


when trying this code outside, when i start walking it takes 5 seconds to display a speed of 2-3 ish kmph instead of .3-5. It is a neo6mv2 gps, and i set it to 5hz in the u center application because i need that accuracy for the project i am working on. Does anybody know why it takes so long? Note, the serial also writes 9 ish messages per second.

The speed is determined from distance between successive locations divided by time, and is not very accurate if walking. The sensor probably uses smoothing or averaging over a period of several seconds to produce reasonably stable estimates.

I imagine that your expectations of responsiveness and accuracy may simply be unrealistic.

1 Like

Well, if you remember, speed is computed as the distance moved in a certain time. How often does your GPS return a change in distance?

ohh, idk why i thought it used the dopler effect to measure speed, so that why i thought it would be a real time speed. do you know i can make it use the doppler effect or am i just wrong in that regard

How do you see that working using satellites so far away you cannot see them?

I have never heard of using "the dopler effect" to get real time speed in a low end consumer GPS module. Please eludicate.

Doppler also has issues with accuracy, depending on conditions. It can also experience large jumps, so is filtered to get a smooth average. I would expect low end units could use both location delta and doppler to derive a speed, but that does not mean all low end units do.

The bottom line is that neither GPS location nor speed is as accurate as people think it might be.

i think i read it somewherwe, the other comment also believes it, thanks for replying

when going around 3-5 m/s, how accurate would it be? and would the accuracy be a random deviation of -0.2 to 0.2 m/s or something?

Good luck with your project. I expect you'll need it.

is that meant pasive agressively? or am i understanding wrongly

thanks if its npot

Thanks for the reply!

Honestly I have no idea. There is not much research on the subject; there are not many applications were people need to accurately measure walking speed.

However, I did find the following paper:

Test it by timing yourself, while walking a straight line at constant speed for a known distance d.

Average velocity = d/t.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.