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);
}
}
}