Making simple GPS

Hallo,

I have been trying making simple GPS With UNO,
and using GPS Module FASTRAX UP500.

with Tiny GPS sketch:

#include "TinyGPS.h"

TinyGPS gps;

void setup() {
Serial.begin(4800);
}

void loop() {
while (Serial.available()) {
int c = Serial.read();
gps.encode(c);
Serial.println("oh no, I'm never gonna exit this while loop");
}

long latitude, longitude;
gps.get_position(&latitude, &longitude, NULL);
Serial.print("Latitude: "); Serial.println(latitude);
Serial.print("Longitude: "); Serial.println(longitude);
}

RX (Pin2 of UNO)
TX (Pin3 of UNO)

Problem :

on serial monitor not detect GPS signal : (Latitude : 9999999...)

What is the solution?

If this

RX (Pin2 of UNO)
TX (Pin3 of UNO)

means that you have the GPS connected to pins 2 and 3 then the answer is that serial works on pins 0 and 1. There for you are not getting any input.

Mark

You are also not checking the result of gps.encode() to see when a message has been encoded. When the function return 'true' you have data to display.

See the TinyGPS examples for how to use the library.

Now I change that sketch with library TinyGPS-13 simple_test, below :

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 0(rx) and 1(tx).
*/

TinyGPS gps;
SoftwareSerial ss(0, 1);

void setup()
{
Serial.begin(115200);
ss.begin(4800);

Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
Serial.println("by Mikal Hart");
Serial.println();
}

void loop()
{
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);
if (chars == 0)
Serial.println("** No characters received from GPS: check wiring **");
}

but then in Serial Monitor no result (No characters received from GPS: check wiring).

What is problem,My sketch or GPS Modul(wiring,etc)...?

Marson

Hi,
Can you please post a copy of your sketch, using code tags.

Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom.... :slight_smile:

sumarsono:
but then in Serial Monitor no result (No characters received from GPS: check wiring).

What is problem,My sketch or GPS Modul(wiring,etc)...?

SoftwareSerial ss(0, 1);
void setup()
{
  Serial.begin(115200);
  ss.begin(4800);

One obvious problem is that you are trying to use Pins 0 and 1 for both hardware Serial and SoftwareSerial. That won't work.

For example the sketch I change to sketch below, wrong or correct?

SoftwareSerial ss(4, 3);

void setup()
{
  Serial.begin(4800);
  ss.begin(4800);

Marson :slight_smile:

sumarsono:
For example the sketch I change to sketch below, wrong or correct?

SoftwareSerial ss(4, 3);

void setup()
{
 Serial.begin(4800);
 ss.begin(4800);

That has a chance of working. Your sketch will receive on 4 and send on 3 so hook the TX of the GPS to 4 and the RX of the GPS to 3. Also connect the Ground of the GPS to Ardunio Ground.