gps.encode() is always returning false,,,, how to fix this bug sir

In this gps program,,, line 13: (gps.encode() is always returning false,,, how to fix the bug sir,,,),,

please help me sir,,,

#include <SoftwareSerial.h>
#include "TinyGPS.h"
long lat,lon;
SoftwareSerial gpsSerial(2, 3);
TinyGPS gps;
void setup(){
Serial.begin(9600);
gpsSerial.begin(9600);
}
void loop(){
while(gpsSerial.available())
{
if(gps.encode(gpsSerial.read()))
{
gps.get_position(&lat,&lon);
Serial.print("Position: ");
Serial.print("lat: ");
Serial.print(lat);
Serial.print("lon: ");
Serial.println(lon);
}
}
}

Echo what you're getting from the GPS to serial. You'll likely discover that the GPS doesn't have a valid position. Most likely reason for that is that the device can't "see" the sky adequately and to solve that, it'll need to be outside or perhaps nearer to a window.

wildbill:
Echo what you're getting from the GPS to serial. You'll likely discover that the GPS doesn't have a valid position. Most likely reason for that is that the device can't "see" the sky adequately and to solve that, it'll need to be outside or perhaps nearer to a window.

I am having the same problem too! Please assist. I am doing this in a building. And there are lots of tall buildings around, and I have opened the window and placed the GPS outside the window.

Kindly advice.

Same thing - just write a little sketch that echoes the data from the GPS to serial. Until you can see that it's getting good position data there's little point trying to use tinyGPS.

ok, now I can see something.

#include "TinyGPS.h"
#include <SoftwareSerial.h>

SoftwareSerial gpsSerial (3, 4); //yellow, orange
TinyGPS gps; // create a TinyGPS object

void setup() {
  Serial.begin(115200);
  gpsSerial.begin(4800); // GPS devices frequently operate at 4800 baud
}
void loop() {
  while (gpsSerial.available()) {
    int c = gpsSerial.read();
    Serial.println(gps.encode(c));
    // Encode() each byte
    // Check for new position if encode() returns "True"
    if (gps.encode(c)) {
      Serial.println("Encoded");
      long lat, lon;
      gps.get_position(&lat, &lon);
      //Serial.println(lon);
    }
  }
}

Though I can see something, my gps.encode(c), gives some garbage like this. And the blocks within that condition is not executed as well.

þþÿþÿþÿþÿþþþÿþÿþÿþ    àþÿþÿþÿþÿþÿþÿþÿþÿþÿþ

and if I were to call the below, the data displayed as as gibberish as above too, even if I were to convert it to byte.

Serial.println(gpsSerial.read());

What's happening?