gps neo-6m code problems

im using windows 7
an uno board
and a neo-6m-0-001 shield
the most up to date IDE
the software serial library that came with the IDE
and a freshly downloaded TinyGPS library (NOT the ++ version)

i’ve shown my code below, its a widely used code to simply print lat & lon data. i know the chip is receiving data as i’ve previously hardwired the shield’s TX & RX to the boards RX and TX respectively and opened the serial monitor and physically seen the data steadily flowing in from the neo-6m

the code below, brings up NOTHING in the serial monitor

i am using the below code:

#include <SoftwareSerial.h>
#include <TinyGPS.h>
 
long lat,lon; // create variable for latitude and longitude object
 
SoftwareSerial gpsSerial(2, 3); // create gps sensor connection
TinyGPS gps; // create gps object
 
void setup(){
  Serial.begin(9600); // connect serial
  gpsSerial.begin(4800); // connect gps sensor
}
 
void loop(){
  while(gpsSerial.available()){ // check for gps data
   if(gps.encode(gpsSerial.read())){ // encode gps data
    gps.get_position(&lat,&lon); // get latitude and longitude
    // display position
    Serial.print("Position: ");
    Serial.print("lat: ");Serial.print(lat);Serial.print(" ");// print latitude
    Serial.print("lon: ");Serial.println(lon); // print longitude
   }
  }
}

HOWEVER

if i delete the following two lines of code

  while(gpsSerial.available()){ // check for gps data
   if(gps.encode(gpsSerial.read())){ // encode gps data

the serial buffer does exactly what it is supposed to EXCEPT!

instead of co-ordinates, i just get 9’s

the output looks like this
“Position: lat: 999999999 lon: 999999999
Position: lat: 999999999 lon: 999999999
Position: lat: 999999999 lon: 999999999”
etcetc

any ideas would be great

minor correction i have since modified the baud rate or the gps object so as to match that of the neo-6m

A link to the shield is going to be necessary.

and a freshly downloaded TinyGPS library (NOT the ++ version)

Why not?

  while(gpsSerial.available()){ // check for gps data
   if(gps.encode(gpsSerial.read())){ // encode gps data

Capture the serial data in a character, and print the character. You need to see if you are receiving anything, and, if so, what you are receiving.

Right now, you are shooting in the dark with dummy rounds.

hi

the shield is simply a generic gps shield using the chip already stated above, which if im brutally honest i cannot find on the internet any more

yes at the moment im stabbing in the dark, if im honest, its how i generally learn best, it sounds ridiculous but as a result i tend to learn a lot more, its just a personal preference

could you possibly give me an example or snippet of the code i might co about using to capture the data at all? i understand fully what you mean im just not sure of the exact syntax in this instance

interestingly the ascII code that the gps unit itself is spitting out... doesnt seem to follow any discernible format at all even after various conversions etc.... though i am on the tired side and looking at it is making me want to throw up

thanks for you help
if possibly that snippet of code would be very useful :slight_smile:

as for the tiny gps++ i simply wanted to get the code working that i have, understand how it works, why it works and then work towards improving it, one of these improvements will no doubt include upgrading the library :slight_smile:

Your gps might be outputting data but if it doesn't have an actual signal, the data will be invalid.

Connect it directly to the serial monitor again, and check you are getting an actual lattitude and longitude.

the data im receiving is in ascII code but im not sure it seems to fit the format of the NMEA standard? :S or any of the standard sentences, though im not sure what i should expect

how should i go about converting the ascII code, surely if i convert each sentence to decimal i will have only numbers, meaning the gps can give letters which from what i understand my gps unit should give out ? :S

What does the raw data from the gps look like?

it varies a little

here's an example of what it usually looks like after its been running for a minute or two and settled down a little

¦Ü@!%1%± 1!!±%1®?¥!{«@­±!%¡!¥±±5±1q«H!±!¡!%¡!µ±!¥±$!±!%5¡!!¡%¡!%¡R±!%%±!¡±±±!!s«H!¡!5¡%5±!¡5!¡$?1%± 1!!!%!{ÿ

it usually seems to be a shorter piece of information followed by a space, then a longer sentence, is that of any help?

here is another example of what it has settled upon recently, specifically in a more enclosed area (though i doubt that will make much odds right now):

R??§ÜH??
«@?Î¥¥¥s«@)¥¥¥¥¥¥¥q«H!¡µ¡%±%¡%k«H!¡%±%¡µs«B??®ÿ

surely if i convert each sentence to decimal

Surely, you have no clue what a sentence looks like.

Change this:

  while(gpsSerial.available()){ // check for gps data
   if(gps.encode(gpsSerial.read())){ // encode gps data

to this:

  while(gpsSerial.available())
  { // Down here where it belongs
   char c = gpsSerial.read();
   Serial.print(c);
   if(gps.encode(c))
   { // Ditto

What do you see in the Serial Monitor?

apologies, not sure if sarcasm intended there? i had worded the worded that slightly wrong, my point originally was that i was under this impression i should be receiving a standard format of characters comprised of letters and numbers?

the serial monitor is now showing something like this?

1)ÿ?þ?1¥?1)T#D=TAT?1L5)+8© «þ1)T#D=TA)Ò3hè9#9áb1ÿ1)T#D=TA)Ò3@ø9+9áb­ÿ

was under this impression i should be receiving a standard format of characters comprised of letters and numbers?

That would be the correct impression to be operating under.

the serial monitor is now showing something like this?

That looks like a mismatch in baud rates, either between the SoftwareSerial instance and the GPS or between the Serial instance and the Serial Monitor.

Add a Serial.println("Hello, Mr. Serial Monitor"); statement in setup(). If that prints correctly, the Arduino and PC are communicating correctly, and the Arduino and GPS are not. If it does not print correctly, then the Arduino and PC are not communicating correctly.

just going to give it a go now
laptop battery on the brink of death i WILL get back to you if you dont hear from me in the next hours i apologize and thank you for taking the time to help me so far

out of interest what gave you the impression it was the baud rate?

out of interest what gave you the impression it was the baud rate?

The fact that there is nothing recognizable in the stream of data.

it prints fine no problem

laptop is truely and utterly dead, ill look further into the baud rate, and get back to you, thanks again