Go Down

Topic: gps.encode() always returning false (Read 3 times) previous topic - next topic

dannable

$GPGGA, sixth position (starting from 1!), 0=fix not available.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

PaulS

Quote
Could the reason be that I'm inside my home and the GPS isn't directly below the sky ?

Well, duh!


wildbill

For best results, a GPS unit needs an unobstructed view of the sky. You can get away with some obstruction - depending on the device, it may work near a window for example.

Try taking it outside and see if things improve. At this point I'd forget TinyGPS and just echo what the GPS is sending to serial until you get better data. Note too that it may take a while to get a decent fix for the first time.

Sembazuru

I'm not that familiar with tinygps.h (but have a lot of familiarity dealing with NMEA sentences), so I may be way off base here. But, how is tinygps.h getting a full sentence? This bit of code (which is the only code presented in this thread, I added all but the first comment for clarity):
Code: [Select]

void loop() // run over and over
{
  if (mySerial.available())
    c = mySerial.read();     // previously declared as int, will read 1 character from SoftwareSerial
    if(gps.encode(c)){     // passes 1 character to gps.encode()
      Serial.println("Inside if condition");
      gps.get_position(&lat, &lon, &fix_age);
      Serial.print("Lat :");
      Serial.print(lat);
    }
}


Only sends one character to gps.encode(), not an entire sentence. (The issue of missing braces for the first if condition appears to have been already covered in this thread.) If tinygps.h is expected to fetch the rest of the sentence over serial (i doubt it, but I don't know), where do you tell tinygps.h what pins you are using for it's serial communication (and how would tinygps.h know whether it's a hardware serial port or SoftwareSerial)?

http://www.catb.org/jargon/html/I/I-didn-t-change-anything-.html

PaulS

Quote
Only sends one character to gps.encode(), not an entire sentence.

True, but the TinyGPS instance is what is responsible for storing each new character in an array, and returning true or false, if the last character added is the end of the sentence.


Sembazuru


Quote
Only sends one character to gps.encode(), not an entire sentence.

True, but the TinyGPS instance is what is responsible for storing each new character in an array, and returning true or false, if the last character added is the end of the sentence.




Ok, got it. Yeah, the OP should really take it outside to get a good GPS lock.
http://www.catb.org/jargon/html/I/I-didn-t-change-anything-.html

omerjerk

I took the GPS outside and and waited for one minute still no results.
i tried another Arduino too. Now finally I think the GPS module is actually derped.

PaulS

Quote
I took the GPS outside and and waited for one minute still no results.

It has been pointed out that a brand new, never been used, GPS can take up to 10 minutes to locate satellites and download enough data. Patience, grasshopper.

Docedison

#24
Jul 01, 2013, 12:25 pm Last Edit: Jul 01, 2013, 12:27 pm by Docedison Reason: 1
From the TinyGPS12.zip file found on http://arduiniana.org/libraries/tinygps/ there is a demonstration program that you might try, outside. test_with_gps_device, Change line 11 to read "SoftwareSerial nss(10, 11);", upload the code to the Arduino and take your GPS device outside, I used a laptop for my first experiments and found that it works well enough by my window. Much better outside however, your position and altitude will shift noticeably and erratically inside.
When the GPS receiver has built an ephemeris from data received from the GPS sat's it will start to display meaningful data. I currently own a Skylabs SKM53 and a U-Blox 6M and either require 4 to 6 minutes to get a position fix. Once a 'fix' is determined the device will output data as long as there are enough sat's visible and close enough for accurate reception. HTH... I attached a file that can be freely downloaded from U-Blox that will display a great deal about your GPS receiver, While written for the U-Blox product I believe that it will work with any GPS receiver. The program is quite well featured, Almost more than you need.

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

michinyon

1.  You need to display the data being actually sent by the GPS.    then you can worry about whether it is being parsed OK.

2.  GPS devices can take a long time to start up,  particularly indoors.

michinyon

I use a program called "MiniGPS"  which allows you to connect the GPS directly to the PC ( without the arduino )   and see what it is doing.

Your GPS is working.  Thats what those  $GPSGA...    text string you have are.    But is hasn't got a position because it hasn't
collected enough data from the satellites.    Mine takes up to 20 minutes indoors.

jerseyguy1996

When a GPS is first powered up it spits out NMEA sentences but it won't have a lock on any satellites yet.  It needs at least 3 and this will take a few minutes to happen.  You will know that it has a lock when this:



$GPGGA,125318.539,,,,,0,0,,,M,,M,,*4B



changes to something like this:

Code: [Select]
$GPGGA,175025.530,4041.1271,N,07406.4956,W,1,05,1.8,-266.0,M,-34.2,M,,0000*48

It will happen eventually if you have a clear view of the sky but it may take several minutes.  Just walk away from it and check back after about 10 minutes.  Assuming you always have the GPS hooked to power and you just put it into sleep mode when not using it, subsequent activations should take less than a minute to get a valid fix.
Arduino Uno;
Mega328

Nick Gammon

I just tried my digital GPS clock described here.

Powered up from cold, indoors, it took about 60 seconds to even show the correct time, and another 45 seconds to get a lock.

However within a second or so it should be spitting out correct NMEA sentences.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

omerjerk


When a GPS is first powered up it spits out NMEA sentences but it won't have a lock on any satellites yet.  It needs at least 3 and this will take a few minutes to happen. 


I waited for one and a half hour.

Go Up