I am trying to get location and speed data from my GPS module which uses the SKYLAB SKG13C.
I am using an Arduino Uno.
The problem is that I am receiving the same Invalid Data.
Here is my code:
void getgps(TinyGPS &gps)
float latitude, longitude;
byte month, day, hour, minute, second, hundredths;
Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/");
Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
Serial.print(" Time: "); Serial.print(hour, DEC); Serial.print(":");
Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC);
Serial.print("."); Serial.println(hundredths, DEC);
Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude());
Serial.print("Course (degrees): "); Serial.println(gps.f_course());
Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
unsigned long chars;
unsigned short sentences, failed_checksum;
gps.stats(&chars, &sentences, &failed_checksum);
Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
int c = Serial.read();
Serial.print("Inside while...: ");
//if(gps.encode(c)) I have omitted this line because encode() always returns FALSE!!
getgps(gps); //Used this as I had to see the Data that was being acquired...
The module’s status LED blinks every second. So I am assuming that it has acquired a Fix, but still I am receiving Wrong output.
The GPS module’s TX output is connected to Arduino Uno’s PIN 0 (RX), and the GND PIN is connected to Arduino’s GND.
Is the problem with the GPS Antenna?
Antenna Specifications :-
Frequency: 1575.42 MHZ
Voltage : 3.0-5.0V
Gain : 30±3dBi
Below is the output’s screenshot (as Attachment) that I get:
There's several things wrong with what you're trying to do, and listing them would probably cause you a lot of confusion. So, I'm going to suggest you get the example from the author's site and use it as a starting point.
There's several reasons for this, but there are two notable that you should pay close attention to. First, he uses SoftwareSerial so that the console port is available for you to use for debugging and testing. Second, he doesn't have any delay() calls in there that will make you miss characters since the cpu is in a hard loop and ignoring everything else. You can't do that kind of thing with something that is sending characters all the time.
The example is at: TinyGPS | Arduiniana
Now, before you tell me that you used that example and that's where you got the code from, take a closer look at what he's doing and reproduce it. Get the darn delay() out and use SoftwareSerial.
There are other examples where people used the same library out there as well.
I understand what you instructed, but I have already tried those…
Ill elaborate a bit more on what I have tried so far.
This is the simplest code that I have tried So far… returns similar output (Output’s Screenshot is attached)
SoftwareSerial ss(10,11); //I have Multi-checked the PIN Connections...
ss.begin(4800); //Default baudrate of SKG13C is 4800
Serial.begin(4800); //I have tried different rates here but to no effect
int c = ss.read();
Serial.println((char)c); //Explicitly Conversion to char for better analysis...
long lat, lng;
Also, the delay() function has been inserted so that the data is viewable.
If the encode() function always returns FALSE when not commented out, the function never runs…
That looks like you have the wrong baud rate. I suggest that you put together a small program that just reads from the GPS pin and prints what it gets. The sentences should make sense, and yours don't.
Just cut the code down to do a read a character from the GPS and then print it. You should see the sentences come out with the data in it. When you do this, attach the GPS to the sofware serial port, and use the regular serial port with the arduino IDE, don't try to use the serial port in a split mode where you have one pin hooked to the gps and expect the other one to talk to the IDE.
So, move the GPS tx pin to the software serial input pin, and try to just read from the GPS and output it through the regular serial port. Remember to set the baud rate of the software serial port. You don't have that in the first code you posted, but do in the second. Something like this:
ss.begin(4800); // your GPS should be hooked here
Serial.begin(4800); // this is only to talk to the IDE serial monitor
// you can use any baud rate you want here.
int c = ss.read();
and see what you get. For some problems, you have to go all the way back to the very beginning.
I have tried what you said… using your code…
int c = ss.read();
The output I got is Attaached Below, but makes no sense (!?)
GPS sentences start with a $ and end with a carriage return, what you’re getting looks like one of the baud rates is wrong. Looking at the datasheets vs code examples for this chip I see both 4800 and 9600 being used as the rx baudrate. So, just to set that possibility aside, put a Serial.println(“Hello World”); right after the Serial.begins to be sure the IDE terminal is right, then try different baud rates for the ss.begin()
I’ve seen different baud rates for different chips, your problem could be something like that.
The GPS module's TX output is connected to Arduino Uno's PIN 0 (RX)
I don't like the sound of that. Aren't you using 0 & 1 for Serial communication with the pc?
And do you have a link to the actual gps device you are using?
Im Sorry about the confusing posts.... I have been trying to make it work so I have been trying different wirings.
Currently Im using PIN 10 as Receiving PIN in the Arduino, i.e the TX PIN of the GPS device is connected to PIN 10 of the Arduino.
The Serial output works fine.... please refer to my 1st post.
If I try to print anything on the Serial Monitor directly, it works fine. Like For Example:
//rest of the code;
The link to the Device is
I have already tried all available Baud rates for the GPS device.
1 very important detail that I had missed in all my earlier posts is that the Device worked the first time I hooked it up with the Arduino. Now its not working, today I also got another Device(Exactly Same).
The same errors were encountered again.
Now I have got a new Antenna which I think is the last solution. (Im thinking that this antenna might be the problem)
Ill hook the new antenna and post again.
I can't see any reason a powered antenna would cause the serial to mess up. It really looks like a baud rate problem since the various lines have similarities. However, it could be a framing error or inverted data as well.
So, I'm goiing to recommend that you switch libraries from the software serial you have to the one here:
unless you're absolutely certain that you have the newest architecture. Then, you can try data inversion to see if it straightens out the framing.
Beyond that, I have no clue.
I immensely Thank everyone for all the time that was given to try and solve my problem. The problem still exists.... Im depressed by it. Im going to find a "cure" for it.... not gonna rest slack off until then.
Ill post the solution in this forum.
Ill still keep checking for updates here.
I got the same problem, this is how I sold it:
- upgrade baudrate at 38400 in your code:
- upgrade baudrate at 38400 in your serial Monitor.
Test it with examples in TinyGPS