Hi,
i'm new to arduino stuff. I've recently bought this GPS shield and I cannot make it work. First of all the guy that sold me also gave me a PDF manual with specifications saying it works with 38400 baud rate.
I'm using Arduino UNO R2 board and GPS is set to communicate with RX = 4 and TX = 3.
Here is my code (which is a modified example):
#include <TinyGPS.h>
#include <SoftwareSerial.h>
#define RXPIN 3
#define TXPIN 4
TinyGPS gps;
SoftwareSerial ss = SoftwareSerial(RXPIN, TXPIN); // Aqui é feito o instanciamento, ou seja, atribuimos a comunicação serial denominada de ss (poderia ser gps, minhaporta ou qualquer outra palavra) para as portas 3 e 4.
void setup()
{
Serial.begin(115200); // Aqui é a velocidade de transmissão entre o Arduino e o PC é de 115200 bps.
Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version()); //só perfumaria...e os devidos //créditos do autor
Serial.println("by Mikal Hart");
Serial.println();
pinMode(RXPIN, INPUT);
pinMode(TXPIN, OUTPUT);
ss.begin(9600);
}
void loop() //loop principal. Os comentários do autor ajudam a entender.
{
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ss.available())
{
char c = ss.read();
Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}
if (newData)
{
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print("LAT=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" LON=");
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
Serial.print(" SAT=");
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
Serial.print(" PREC=");
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
}
gps.stats(&chars, &sentences, &failed);
Serial.print(" CHARS=");
Serial.print(chars);
Serial.print(" SENTENCES=");
Serial.print(sentences);
Serial.print(" CSUM ERR=");
Serial.println(failed);
}
As you can see, i used 9600 baud rate from GPS to Arduino and 115200 from Arduino to PC. Altough the PDF said 38400, this (9600) was the only configuration that it seems to work. With 4800 and 38400 baud rates i get strange characters in screen. With this sample code the result is as follow:
Simple TinyGPS library v. 12
by Mikal Hart
$GPGGA,235951.074,,,,,0,00,,,M,0.0,M,,00005C
$GPGLL,,,,,235951.074,V12
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,20,00,000,,10,00,000,,31,00,000,,2 CHARS=153 SENTENCES=0 CSUM ERR=0
7,00,000,7C
$GPGSV,3,2,12,19,00,000,,07,00,000,,04,00,000,,24,00,000,76
$GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,29,00,000,78
$GPRMC,235951.074,V,,,,,,,281006,,28
$GPVTG,,T,,M,,N,,K4E
$GPGGA,235952.067,,,,,0,00,,,M,0.0,M,,00005D
$GPGLL,,,,,235952.067,V13
$GPGSA,A,1,,,,,,,,,,,,,,,1E
$GPRMC,235952.067,V,,,,,,,281006,,29
$GPVTG,,T,,M,,N,,K CHARS=516 SENTENCES=0 CSUM ERR=0
4E
$GPGGA,235953.067,,,,,0,00,,,M,0.0,M,,00005C
$GPGLL,,,,,235953.067,V12
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235953.067,V,,,,,,,281006,,28
$GPVTG,,T,,M,,N,,K4E CHARS=685 SENTENCES=0 CSUM ERR=0
No matter how much time it runs, it never gives me a good result.
The GPS shield came with the square antenna and it is correctly connected to it. Could this be a serial communication problem (once i heard that with arduino UNO the GPS shield only worked in pins 0 and 1 (used to exchange messages with PC))?
As it is receiving correct characters I imagine that is not an communication issue. Does anyone have any suggestion?
Thanks