Ublox neo 6m not sending data all the time

I am using a arduino uno and neo 6m gps module. The problem I am facing is quite weird. When I connected the setup the data from neo6M was seen in serial monitor, I even printed it on a Oled display. It was a close room at night. I used tiny gps plus plus library to parse the data. I got both latitude longitude. After disconnected the circuit i tried again and that is when nothing came out in serial monitor. The same sketch did not work for a day. But again at afternoon at some point i got the data properly. Sometimes the red led is blinking but nothing happens. While I change the rx and tx pins in software serial it got data but then again same problem and changing pins don't work. I have tested it in front of my window so there must be a good signal. Can someone tell me what is wrong with the system? I have so far waited long enough like 10 mins to get the data but nothing. I have to present the project by tomorrow in office. This is the code :

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

// Choose two Arduino pins to use for software serial
int RXPin = 2;
int TXPin = 3;

int GPSBaud = 9600;

// Create a TinyGPS++ object
TinyGPSPlus gps;

// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);

void setup()
{
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(9600);

// Start the software serial port at the GPS's default baud
gpsSerial.begin(GPSBaud);
}

void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (gpsSerial.available() > 0)
if (gps.encode(gpsSerial.read()))
displayInfo();

// If 5000 milliseconds pass and there are no characters coming in
// over the software serial port, show a "No GPS detected" error
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println("No GPS detected");
while(true);
}
}

void displayInfo()
{
if (gps.location.isValid())
{
Serial.print("Latitude: ");
Serial.println(gps.location.lat(), 6);
Serial.print("Longitude: ");
Serial.println(gps.location.lng(), 6);
Serial.print("Altitude: ");
Serial.println(gps.altitude.meters());
}
else
{
Serial.println("Location: Not Available");
}

Serial.print("Date: ");
if (gps.date.isValid())
{
Serial.print(gps.date.month());
Serial.print("/");
Serial.print(gps.date.day());
Serial.print("/");
Serial.println(gps.date.year());
}
else
{
Serial.println("Not Available");
}

Serial.print("Time: ");
if (gps.time.isValid())
{
if (gps.time.hour() < 10) Serial.print(F("0"));
Serial.print(gps.time.hour());
Serial.print(":");
if (gps.time.minute() < 10) Serial.print(F("0"));
Serial.print(gps.time.minute());
Serial.print(":");
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(".");
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.println(gps.time.centisecond());
}
else
{
Serial.println("Not Available");
}

Serial.println();
Serial.println();
delay(1000);
}

debarun:
I am using a arduino uno and neo 6m gps module. The problem I am facing is quite weird.

It was a close room at night.

The same sketch did not work for a day. But again at afternoon at some point i got the data properly.

I have tested it in front of my window so there must be a good signal.

Can someone tell me what is wrong with the system?

Its quite simple, a GPS might work sometimes indoors, but its going to be very inconsistent, as you have discovered.

Your assumption that when a GPS is in front of a Window that there 'must' be good signals, is incorrect.

Take the GPS outside, give it a good view of the sky, and see how it performs then.

Can you suggest me some other module which can have a good performance in indoors?? And many many thanks for the answer.

debarun:
Can you suggest me some other module which can have a good performance in indoors?? And many many thanks for the answer.

Nope.

There may be some very specialised GPSs, with large high gain antennas, that work better indoors, but I would expect them to be very expensive, but I would not know of anything specific.

Hello.

What kind of antenna are you using?

The puck style meant for sitting on a car roof gives good performance. With 3m lead it can be easily positioned outside a convenient window. The screw connecton is more reliable than the tiny press type.

There are many elements to a GPS system. Each has to work. You really need to be able to recognise when each element is working. It may be too early for a presentation to the office.

Can you elaborate on the performance when it is not working for you? Is it that you are not getting positional data or you are not getting anything at all, or is the data garbled?

John.