Go Down

Topic: Position coordinates not updated, Gps module and Arduino Uno issue (Read 1 time) previous topic - next topic

ellepiu

Hi
I bought a PMB-688 GPS receiver and an Arduino Uno. I need to get gps location coordinates to serial monitor. I connected yellow gps cable to digital pin 6, red cable to 5v, black to ground.

I used tinyGPS and SoftwareSerial library. Following is the code I used:

Code: [Select]


#include <SoftwareSerial.h>
#include "TinyGPS.h"                 // Special version for 1.0

TinyGPS gps;
SoftwareSerial nss(6, 255);            // Yellow wire to pin 6

void setup() {
  Serial.begin(9600);
  nss.begin(4800);
  Serial.println("Reading GPS");
}

void loop() {
  bool newdata = false;
  unsigned long start = millis();
  while (millis() - start < 5000) {  // Update every 5 seconds
    if (feedgps())
      newdata = true;
  }
  if (newdata) {
    gpsdump(gps);
  }
}

// Get and process GPS data
void gpsdump(TinyGPS &gps) {
  float flat, flon;
  unsigned long age;
  gps.f_get_position(&flat, &flon, &age);
  Serial.print(flat, 6); Serial.print(", ");
  Serial.println(flon, 6);
}

// Feed data as it becomes available
bool feedgps() {
  while (nss.available()) {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}


When powered on, on serial monitor I saw correct latitute and longitude coordinates, but when I move the gps module, coordinates stay the same. Coordinates will be correctly updated only by power off and subsequently power on Arduino.

Does anybody knows why this could happens? Suggestions are appreciated!

Indeed, I checked the raw strings received without using tinyGPS library, and it turned  out that GPRMC messages frequently overlaps with GPGGA messages, such as:

$GPRMC,143044.000$GPGGA,143045.000,4152.9430,N,01119.2805,E,2,10,0.8,50.0,M,46.8,M,1.8,0000*45

Thanks for your help!

Chagrin

Your GPS sends coordinate updates every second and you're only reading them every five seconds. What's happening is that you're overflowing the 64 byte serial buffer and causing messages to overlap.

See also http://arduino.cc/en/Reference/SoftwareSerialOverflow

ellepiu

wow!! Thank you Dubuque for your suggestion, it helped me to fix the later issue. Now the serial monitor receives correct strings like

$GPRMC,150111.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*6B
$GPRMC,150112.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*68
$GPRMC,150113.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*69
$GPRMC,150114.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*6E
$GPRMC,150115.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*6F
$GPRMC,150116.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*6C
$GPRMC,150118.000,A,4551.8988,N,01211.8911,E,0.00,263.77,110612,,,D*62

However, as you can see, when moving far from initial position (at least 10 m/33 ft), the latitude and longitude values remain the same...

Some hints?

Do you think the gps module is broken?

Thanks!

Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial GPS = SoftwareSerial(6,255);
char byteGPS;

void setup()
{
  Serial.begin(9600);
  GPS.begin(4800);
}

void loop()
{
  if (GPS.overflow()){
    Serial.println("overflow");
  }
  byteGPS = GPS.read();

  if (byteGPS == -1) {           // See if the port is empty yet
    delay(50);
  }
  else {
    Serial.print(byteGPS);
  }
}

Docedison

No it is probably Ok Even though 'Selective Availability is disabled and theoretically the accuracy should be 3 meters, 10 meters or 33" is about the minimum typical measurable distance. Try twice that far.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

ellepiu


Go Up