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)