arduino Mega and SKM53 gps

I'm new to this arduino since i bought arduino mega2560, and i want to try a few things, and see a bit of example, in any case, i got SKM53 and i want to connect to my arduino mega with SKM53, but i can't figure the arduino code for showing latitude and longitude, I already download the library and so on step. Can any help me do correction in my code ? > here some code i try from internet .. it didn't show anything... i read thread show in internet but i try mostly but i still didn't get any number..

#include <SoftwareSerial.h>
#include <TinyGPS.h>

long lat, lon;

SoftwareSerial gpsSerial(10, 11);
TinyGPS gps;

void setup(){
  Serial.begin(9600);
  gpsSerial.begin(115200);
}
void loop(){
  while(gpsSerial.available()){
    if(gps.encode(gpsSerial.read()))
{
    gps.get_position(&lat,&lon);
    Serial.print("Position: ");
    Serial.print("lat: ");
    Serial.print(lat);
    Serial.print(" ");
    Serial.print("lon: ");
    Serial.println(lon);
    }
  }
}
[code]

Here is code. You can upload the code.

check baudrate used by your GPS sensor properly.since it uses 9600 baud rate not a 115200

main_c.zip (1.78 KB)

erm.... the output show :

i try change the pin output compatible pin for arduino mega which recomended by people, the output still the same, is this correct?

Capture.JPG

which pins have you used for Serial monitor
Use 19 & 18 pins
Just replace below line

SoftwareSerial mySerial(19, 18);

change baud rate with 9600 if doesnt worked change to 4800

If not working , first try with basic make ensure you getting GPS data properly,

connect 0 to pin RX of GPS
connect 1 to pin TX of GPS
Baudrate must be 9600, if not worked try with 4800

#include <string.h>
 #include <ctype.h>
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
char gps_time[25],gps_status[5],gps_latitude[20],gps_indl[5],gps_longitude[20],gps_indlong[5],gps_NS[10],gps_date[10],gps_head[8],gps_EW[8],gps_mode[5],gps_checksum[8],gps_mag[10];
char *temp;
int varcnt=0;
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
float time,latitude,longitude,date,lat_ind,long_ind,Status;
 
 int k;
 int m;
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   Serial.begin(9600);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
   }   
 }
 void loop() {
   digitalWrite(ledPin, HIGH);
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
    // delay(50); 
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
    // Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW); 
       cont=0;
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             indices[cont]=i;
             cont++;
           
               
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         Serial.println("");      // ... and write to the serial port
         Serial.println("");
         Serial.println("---------------");
         for (int i=0;i<12;i++){
           switch(i){
			   case 0 :Serial.print("Time in UTC (HhMmSs): ");temp=gps_time;break;
             
			   case 1 :Serial.print("Status (A=OK,V=NOT OK): ");temp=gps_status; break;
             case 2 :Serial.print("Latitude: ");temp=gps_latitude; Serial.println("");break;
             case 3 :Serial.print("Direction (N/S): ");temp=gps_indl; Serial.println("");break;
             case 4 :Serial.print("Longitude: ");temp=gps_longitude; Serial.println("");break;
             case 5 :Serial.print("Direction (E/W): ");temp=gps_indlong; Serial.println("");break;
             case 6 :Serial.print("velocity knots: ");temp=gps_NS;break;  
             case 7 :Serial.print("Heading in degrees: ");temp=gps_head;break;
              case 8:Serial.print("Date UTC (DdMmAa): ");temp=gps_date; Serial.println("");break;
               case 9 :Serial.print("Magnetic degrees: ");temp=gps_mag;break;
               case 10 :Serial.print("(E/W): ");temp=gps_EW;break;
               case 11 :Serial.print("Mode: ");temp=gps_mode;break;
                case 12 :Serial.print("Checksum: ");temp=gps_checksum;break;
              
              
                         }
			 varcnt=0;
           for (int j=indices[i];j<(indices[i+1]-1);j++){
             Serial.print(linea[j+1]); 
			   temp[varcnt]=linea[j+1];
			   varcnt++;
               
            
           }             
            
           Serial.println("");
			 
           
         }
         Serial.println("");
        
          
         float time=atof(gps_time);
       
         float latitude=atof(gps_latitude);
       
         float longitude=atof(gps_longitude);
        
         float date=atof(gps_date);
         
          Serial.print(time);
          Serial.print(gps_status);
           Serial.print(latitude);
            Serial.print(gps_indl);
             Serial.print(longitude);
              Serial.print(gps_indlong);
               Serial.print(date);
          Serial.print("");
         sprintf(gps_time,"%f",time);
          
         
         
         
         
         
         
            Serial.print("");
         
         Serial.println("---------------");
             
         
       }
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             
       }                 
     }
   }
 }

output must be similar.

Time in UTC (HhMmSs): 154653 
 Status (A=OK,V=KO): V 
 Latitude: 4428.2011 
 Direction (N/S): N 
 Longitude: 00440.5161 
 Direction (E/W): W 
 Speed in knots: 000.5 
 Direction in degrees: 342.8 
 Date in UTC (DdMmAa): 050407 
 Magnetic variation:  
 Variation (E/W):  
 Mode: A

Put your output screenshot.

Here i am attaching softwareSerial library . some time it might problem due library also. SO first try with above example if didnt work , then replcae software library that i have shared below.

SoftwareSerial.zip (8.75 KB)

Erm ...it still didn't show desire output... i try replace the library already.. i test the example...nothing works, it show empty... then again i try the code given.. test out on every compatible pins for mega...
for pin 0 and 1.. this is the output..

does it means my GPS recieving data? =.= ... i really hope i could get something, i just bought a few days this new SKM53 GPS and Arduino mega 2560

test 5.JPG

Did i just need to run these program? it don't have SoftwareSerial.h and TinyGPS.h in it..

#include <string.h>
 #include <ctype.h>
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
char gps_time[25],gps_status[5],gps_latitude[20],gps_indl[5],gps_longitude[20],gps_indlong[5],gps_NS[10],gps_date[10],gps_head[8],gps_EW[8],gps_mode[5],gps_checksum[8],gps_mag[10];
char *temp;
int varcnt=0;
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
float time,latitude,longitude,date,lat_ind,long_ind,Status;
 
 int k;
 int m;
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   Serial.begin(9600);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
   }   
 }
 void loop() {
   digitalWrite(ledPin, HIGH);
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
    // delay(50); 
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
    // Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW); 
       cont=0;
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             indices[cont]=i;
             cont++;
           
               
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         Serial.println("");      // ... and write to the serial port
         Serial.println("");
         Serial.println("---------------");
         for (int i=0;i<12;i++){
           switch(i){
			   case 0 :Serial.print("Time in UTC (HhMmSs): ");temp=gps_time;break;
             
			   case 1 :Serial.print("Status (A=OK,V=NOT OK): ");temp=gps_status; break;
             case 2 :Serial.print("Latitude: ");temp=gps_latitude; Serial.println("");break;
             case 3 :Serial.print("Direction (N/S): ");temp=gps_indl; Serial.println("");break;
             case 4 :Serial.print("Longitude: ");temp=gps_longitude; Serial.println("");break;
             case 5 :Serial.print("Direction (E/W): ");temp=gps_indlong; Serial.println("");break;
             case 6 :Serial.print("velocity knots: ");temp=gps_NS;break;  
             case 7 :Serial.print("Heading in degrees: ");temp=gps_head;break;
              case 8:Serial.print("Date UTC (DdMmAa): ");temp=gps_date; Serial.println("");break;
               case 9 :Serial.print("Magnetic degrees: ");temp=gps_mag;break;
               case 10 :Serial.print("(E/W): ");temp=gps_EW;break;
               case 11 :Serial.print("Mode: ");temp=gps_mode;break;
                case 12 :Serial.print("Checksum: ");temp=gps_checksum;break;
              
              
                         }
			 varcnt=0;
           for (int j=indices[i];j<(indices[i+1]-1);j++){
             Serial.print(linea[j+1]); 
			   temp[varcnt]=linea[j+1];
			   varcnt++;
               
            
           }             
            
           Serial.println("");
			 
           
         }
         Serial.println("");
        
          
         float time=atof(gps_time);
       
         float latitude=atof(gps_latitude);
       
         float longitude=atof(gps_longitude);
        
         float date=atof(gps_date);
         
          Serial.print(time);
          Serial.print(gps_status);
           Serial.print(latitude);
            Serial.print(gps_indl);
             Serial.print(longitude);
              Serial.print(gps_indlong);
               Serial.print(date);
          Serial.print("");
         sprintf(gps_time,"%f",time);
          
         
         
         
         
         
         
            Serial.print("");
         
         Serial.println("---------------");
             
         
       }
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             
       }                 
     }
   }
 }[\code]

Yes you need to run above program. I wanted to know Whether GPS working or not.

Share me screen shot of image .

Make ensure you used baud rate of 9600
Tx pin 1
Rx pin as
While doing test be sit open space , it need some satellite to get locked. Then only you get valid data.

wait atleast 2~3minutes.

Send me screen shot i will tell what todo later. connection wise it seems ok.

if didn't worked replace tx & rx line to 2& 3.

Please let me know problem you facing.

I have attached one software to check GPS working or not. You need USB to TTl converter
Give TTL out put of GPS to converter & 5v externally to GPS sensor. You will come to know gps working or not

software.zip (447 KB)

Er, it this correct?... sorry i just wanna make sure connection to check the GPS... and step to start the software reading... its was my 1st time seeing the software.. :sweat_smile:

yes it is correct. Let me know what is output? in screen shot.

In your picture What is blue color board??

I am considering green color board you are using; If you using other board share me datasheet.
else connection wise it ok

You can use green module directly. Take 5v from mega2560, gnd from mega 2560

connect RxD pin to pin0 arduino mega 2560
connnect TXD pin of module to pin1 of arduino mega 2560

its an USB to UART converter ... item from Cytron.com.my > ... can't find the datasheet...but there features about the item on this page... u can see... your opinion, can i use the item? :cry:

http://cytron.com.my/p-uc00b

Yes you can connect & check . IS device is with you. COnnect & send me screen shot..

http://cytron.com.my/p-uc00b

Your relevant driver are avilable here. You connect TTL output like in image. you previously shared

You dont need external 5v for USB To TTL.

Give 5v to GPS sensor,If VCC 5v you are getting from USB to TTL you can use same 5v.

If you have multimeter just check voltage across USB to TTL , VCC point & ground. if 5v available use same thing to power on GPS.

Let me know how it react to software.

Is it start working or not??

when i use your code that you mentioned in your post#3 but my gps does not give any value on serial monitor but when i use the code that i have mention in below then it gives garbage value, i also attach the snap of serially received gps value.

// FOR SKM53 GPS MODULE
/* This is simplest code designed to be used with Ardiuno Mega or those
versions of Arduino which have more than one serial port built in hardware.
This code avoids usage of any library and outputs raw data.
Raw data can be decoded by studying mediatek_3329 datasheet or using TinyGPS lib.

Found at: HotResistor.blogspot.com
Please donot forget accreditation if you find it useful.
*/

void setup()
{
Serial.begin(9600);//(115200);
Serial3.begin(9600); // connect TXD pin of gps skm 53 to arduino mega digital pin 15[RX3] and RXD pin of gps to digital pin 14.

Serial.println("GPS Test with no libraries ");
Serial.println("by HotResistor.blogspot.com");
Serial.println();
}

void loop()
{
boolean data=false;

for (unsigned long start = millis(); millis() - start < 1000;)
{
while (Serial3.available())
{
char c = Serial3.read();
Serial.print(c);
data=true;
}
}

if(data==false){ Serial.println("No data"); }
}

snapshot

void setup()
{
 Serial.begin(9600);//(115200);
 Serial3.begin(9600); // connect TXD pin of gps skm 53 to arduino mega digital pin 15[RX3] and RXD pin of gps to digital pin 14.
 
 Serial.println("GPS Test with no libraries ");
 Serial.println("by HotResistor.blogspot.com");
 Serial.println();
}

you are using two serial. Either you need use Software serial library for communicate.

I have attached two code here. First try float store as i mention the connection.

You can config your pins as per requirement.

first you upload your float store code & send me screen shot of the image

make ensure you get proper data atleast .

Then upload second code which gives you latitude;date;time etc. send me screen shot here also.

As i said ealier make this experiment in open space possible; because it take quickly to lock signals.& gives proper result.else you get Zero. like earlier..

Nmea _158 is software if you have USB to TLL you can get direct read datahere,to make ensure your sensor working or not

gps test.zip (3.39 KB)

NMEA_158.zip (501 KB)