Page 1 of 1

skgps53 and arduino mega

PostPosted: Mon Mar 10, 2014 4:13 pm
by sitimariam
hello,

I have try by using the tutorial that provided at cytron for skgps53 with arduino.
I tried a lot with the codes but my result shown below,

Latitude : 0.0000000 :: Longitude : 0.0000000
Latitude : 0.0000000 :: Longitude : 0.0000000
Latitude : 0.0000000 :: Longitude : 0.0000000

I have try at the outdoor for 3hours but still same result I get,

Latitude : 0.0000000 :: Longitude : 0.0000000
Latitude : 0.0000000 :: Longitude : 0.0000000
Latitude : 0.0000000 :: Longitude : 0.0000000

do you know what is the problem?

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 7:58 am
by ober
Mind sharing the photo of hardware setup?

Besides, is the LED at G_TX blink?

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 12:09 pm
by sitimariam
this is the hardware setup..and the led of G-TX is blink when i connect with the laptop..

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 12:50 pm
by ober
Which tutorial that you refer? Can you provide the link to the tutorial? Also can you share the code?

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 1:07 pm
by sitimariam
http://tutorial.cytron.com.my/2012/08/1 ... -skgps-53/

CODE: SELECT_ALL_CODE
#include <TinyGPS.h>
#include <SoftwareSerial.h>

unsigned long fix_age;

SoftwareSerial GPS(2,3);
TinyGPS gps;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
long lat, lon;
float LAT, LON;

void setup(){
 GPS.begin(9600);
 Serial.begin(115200);
}

void loop(){
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;

// retrieves +/- lat/long in 100000ths of a degree
gps.get_position(&lat, &lon, &fix_age);

// time in hh:mm:ss, date in dd/mm/yy
/*gps.get_datetime(&date, &time, &fix_age);
year = date % 100;
month = (date / 100) % 100;
day = date / 10000;
hour = time / 1000000;
minute = (time / 10000) % 100;
second = (time / 100) % 100;
Serial.print("Date: ");
Serial.print(year); Serial.print("/");
Serial.print(month); Serial.print("/");
Serial.print(day);
Serial.print(" :: Time: ");
Serial.print(hour); Serial.print(":");
Serial.print(minute); Serial.print(":");
Serial.println(second);
*/
getGPS();
Serial.print("Latitude : ");
Serial.print(LAT/100000,7);
Serial.print(" :: Longitude : ");
Serial.println(LON/100000,7);
}

void getGPS(){
  bool newdata = false;
  unsigned long start = millis();
  // Every 1 seconds we print an update
  while (millis() - start < 1000)
  {
    if (feedgps ()){
      newdata = true;
    }
  }
  if (newdata)
  {
    gpsdump(gps);
  }
}

bool feedgps(){
  while (GPS.available())
  {
    if (gps.encode(GPS.read()))
      return true;
    }
    return 0;
}

void gpsdump(TinyGPS &gps)
{
  //byte month, day, hour, minute, second, hundredths;
  gps.get_position(&lat, &lon);
  LAT = lat;
  LON = lon;
  {
     feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors
  }
}

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 2:15 pm
by ober
If you check software serial library, Arduino Mega cannot support software Serial for pin 2 or 3 for Rx. But you are using pin 2 and 3 as the UART pin.

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 2:26 pm
by sitimariam
owh..that means I need to change the pin for RX?
I have try the pin for RX to 5 and 6 still I got the same result..

Re: skgps53 and arduino mega

PostPosted: Tue Mar 11, 2014 9:58 pm
by ober
Please do some study yourself to understand the softwareserial: http://arduino.cc/en/Reference/SoftwareSerial#.Ux8R2vmSwR8

It does not mean pin 2 and 3 cannot use, pin 5 and 6 can be used. :mrgreen: