GPS not responding (NEED HELP)

hello every one, I have been playing with the gps and TinyGPS library to get my reading. however every time i try to read float(f_get_position()) i wouldn’t get any respond . can some one look at my code and tell me what am doing wrong. my guess is that if am not outside some times the gps wouldn’t get accurate reading.

HERE IS MY CODE!!!

#include <NewSoftSerial.h>

#include <TinyGPS.h>

#include <Wire.h>

TinyGPS gps;

NewSoftSerial nss(0, 1); // The GPS is connected to port D5, so pins 9 and 8 are used

void setup()

{

nss.begin(115200); // Input GPS

Serial.begin(9600); // Output to the Arduino Serial Monitor

Serial.print("Testing TinyGPS library v. ");

Serial.print(TinyGPS::library_version());

Serial.print(“\n”);

Serial.print("Sizeof(gpsobject) = ");

Serial.print(sizeof(TinyGPS));

Serial.print(“\n”);

Serial.print(“Searching…”);

Serial.println(“\n”);

}

void loop(){

while (nss.available()){

if (gps.encode(nss.read())){

float lat, lon, alt, spd;

unsigned long age;

gps.f_get_position(&lat, &lon, &age);

alt = gps.f_altitude();

spd = gps.f_speed_mph();

// We print the latitude, longitude and fix age to the Serial Monitor

Serial.print(“---------Starting------------”);

Serial.print(“\n”);

Serial.print("latitude = ");

Serial.print(lat, 5);

Serial.print(“\n”);

Serial.print("longitude = ");

Serial.print(lon, 5);

Serial.print(“\n”);

Serial.print("FIX-Position = ");

Serial.print(age);

Serial.print(“\n”);

Serial.print("Altitude = ");

Serial.print(alt, 1);

Serial.print("m ");

Serial.print(“\n”);

Serial.print("Speed = ");

Serial.print(spd, 1);

Serial.print (“\n”);

Serial.println(“------Ending----------------”);

Serial.print(“\n”);

delay(5000);

}

}

}

i have about 29 viewer but still didn’t get any help. however my main problem i figured out is that my my while() and if() is not responding. if i tried the code with out while or if statement it will give me some thing and will be reading. but if i run the code as the example below, which i found in some of the examples on the web it wouldn’t respond… this is making me pull my hair off. the Void setup() will print even on my LCD but from there on it wouldn’t print. it is stuck on that position saying …waiting for lock… please please help i need it for my Electrician technician project I’m working on. i don’t want to use Assembly to program it , it is simpler this way because i understand the problem and i can troubleshoot it easier.

#include <NewSoftSerial.h>

#include <TinyGPS.h>

#define RXPIN 2

#define TXPIN 3

#define led 13

TinyGPS gps;

#define GPSBAUD 4800

NewSoftSerial uart_gps(RXPIN, TXPIN);

void getgps(TinyGPS&gps);

void setup(){

pinMode(led,OUTPUT);

Serial.begin(115200);

uart_gps.begin(GPSBAUD);

Serial.println(“”);

Serial.println(“GPS”);

Serial.println(" …wating for lock…");

Serial.println(“”);

}

void loop(){

while(uart_gps.available())

{

int c = uart_gps.read();

if(gps.encode(c))

{

getgps(gps);

digitalWrite(led,HIGH);

}

}

}

void getgps(TinyGPS&gps)

{

float latitude, longitude;

gps.f_get_position(&latitude, &longitude);

Serial.print(latitude,5);

Serial.print(" ");

Serial.println(longitude,5);

}

I haven’t used the Tinygps or NewSoftSerial libraries, but it looks like you’re waiting for your gps to send you a message because you use the .available() and .read() functions.

I may be wrong, but I believe you communicate with the gps through the *_get_position, etc… functions. Shouldn’t you just wait 1 sec in your loop and then call f_get_position()? The .available() and .read() don’t seem to be needed or useful since all you really need to do is .begin() the connection to your gps once during the setup function.

You should try the example sketches that come with the Tinygps library.

May be the touch screen have problem , before I bought a mobile phone, GPS can’t use, I do not know what is the reason,could some people to give me directions.

WethaGuy

The example am using is the same as the TinyGPS example. I even run the test code to see if my software is good, and it run good. I took out the while() and just Serial.write(nss.read()); that gave me every read. Now what am confuse is why if I say

While(nss.available()){

}

This is not retriving the code.