user1499: I have an Arduino Duemilanove and em408.
My code is this:

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

#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPS gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

void loop()
{
  while (ss.available())
  {
    char c = byte(ss.read());
    // Here i tried Serial.write(c); and i succesully saw the NMEA data in my serial monitor
    if (gps.encode(c))
    {
      long lat, lon;
     unsigned long fix_age;
    gps.get_position(&lat, &lon, &fix_age);
    if (fix_age == TinyGPS::GPS_INVALID_AGE )
      Serial.println("No fix ever detected!");
    else if (fix_age > 2000)
      Serial.println("Data is getting STALE!");
    else
      Serial.println("Latitude and longitude valid!");

      Serial.print("Lat: "); 
      Serial.print(lat);
      Serial.print(" Lon: "); 
      Serial.println(lon);

    }
    else Serial.println("No data!");
  }
}

My output is this:
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
Latitude and longitude valid!
Lat: 32758239
 Lon: 15637489
No data!
No data!
No data!
No data!
No data!
No data!
No data!

And then i continue getting No data! forever...
So...

Why does gps.encode() only manage to return true only 1 time? I have gotten the raw data from the gps (the commented code on my code snippet) and it's ok. Why it returns true only one time? 
Why the longitude/latidude data is like this? As far as i know, this isnt valid, correct?

EDIT:
Also tried with TinyGPS++.. but no luck in encoding too...
#include <TinyGPS++.h>
#include <SoftwareSerial.h>


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

void loop()
{
  while (ss.available()>0)
  {
    char c = byte(ss.read());
    // Here i tried Serial.write(c); and i succesully saw the NMEA data in my serial monitor
    if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then
    {
      Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

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

  Serial.println();

    }
    else Serial.println("No data!");
  }
}

New code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

char clat[11];
char clng[11];

void loop()
{
    //if (buttons || tilt) {
    //if (buttons & BUTTON_SELECT) {

        bool isGpsLocationValid = false;
        do
        {  
            while (ss.available()>0)
            {
                char c = byte(ss.read());
                if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then
                {    
                    if (gps.location.isValid())
                    {
                        dtostrf(gps.location.lat(), 11, 6, clat);
                        dtostrf(gps.location.lng(), 11, 6, clng);
                        //send-print
                        //delay (just in case multiple bumps)
                        isGpsLocationValid = true;
                    }
                }   
             }
        } while (isGpsLocationValid == false);
        Serial.write(clat);
        Serial.println();
        Serial.write(clng);
       //}
    //}
}

EDIT: The newest code i have posted works 100%!
So if you have similar problems with that aweful gps, use this!
Apparently, TinyGPS and TinyGPS++ don't work well with this gps.
To be precice, there is a problem with the gps.encode(c) function.
So using if (gps.encode(c)) most of the times returns false, except some rare occasions which returns true and then you can do some processing...
My last code takes care of that problem by checking continuously, using a do...while loop.
If if (gps.location.isValid()) returns true, which means i have valid data, then i do the processing i want and end the do...while loop.

user1499: The newest code i have posted works 100%! So if you have similar problems with that aweful gps, use this!
Apparently, TinyGPS and TinyGPS++ don't work well with this gps. To be precice, there is a problem with the gps.encode(c) function.
So using if (gps.encode(c)) most of the times returns false, except some rare occasions which returns true and then you can do some processing...
My last code takes care of that problem by checking continuously, using a do...while loop. If if (gps.location.isValid()) returns true, which means i have valid data, then i do the processing i want and end the do...while loop.
NOTE: This code is for TinyGPS++ library. Same theory will work for TinyGPS too of course...
Here it is:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

char clat[11];
char clng[11];

void loop()
{
    bool isGpsLocationValid = false;
    do
    {  
        while (ss.available()>0)
        {
            char c = byte(ss.read());
            if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then
            {    
                if (gps.location.isValid())
                {
                    dtostrf(gps.location.lat(), 11, 6, clat);
                    dtostrf(gps.location.lng(), 11, 6, clng);                        
                    isGpsLocationValid = true;
                }
            }   
        }
    } while (isGpsLocationValid == false);
    Serial.write(clat);
    Serial.println();
    Serial.write(clng);
}


1499: <p>I have an Arduino Duemilanove and em408.</p>

<p>My code is this:
</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;TinyGPS.h&gt;
#include &lt;SoftwareSerial.h&gt;

#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPS gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

void loop()
{
  while (ss.available())
  {
    char c = byte(ss.read());
    // Here i tried Serial.write(c); and i succesully saw the NMEA data in my serial monitor
    if (gps.encode(c))
    {
      long lat, lon;
     unsigned long fix_age;
    gps.get_position(&amp;lat, &amp;lon, &amp;fix_age);
    if (fix_age == TinyGPS::GPS_INVALID_AGE )
      Serial.println("No fix ever detected!");
    else if (fix_age &gt; 2000)
      Serial.println("Data is getting STALE!");
    else
      Serial.println("Latitude and longitude valid!");

      Serial.print("Lat: "); 
      Serial.print(lat);
      Serial.print(" Lon: "); 
      Serial.println(lon);

    }
    else Serial.println("No data!");
  }
}
</code></pre>

<p>My output is this:</p>

<pre class="lang-cpp prettyprint-override"><code>No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
No data!
Latitude and longitude valid!
Lat: 32758239
 Lon: 15637489
No data!
No data!
No data!
No data!
No data!
No data!
No data!
</code></pre>

<p>And then i continue getting No data! forever...</p>

<p>So...</p>

<ol>
<li><p>Why does gps.encode() only manage to return true only 1 time? I have gotten the raw data from the gps (the commented code on my code snippet) and it's ok. Why it returns true only one time? </p></li>
<li><p>Why the longitude/latidude data is like this? As far as i know, this isnt valid, correct?</p></li>
</ol>

<p>EDIT:
Also tried with TinyGPS++.. but no luck in encoding too...</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;TinyGPS++.h&gt;
#include &lt;SoftwareSerial.h&gt;


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

void loop()
{
  while (ss.available()&gt;0)
  {
    char c = byte(ss.read());
    // Here i tried Serial.write(c); and i succesully saw the NMEA data in my serial monitor
    if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then
    {
      Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() &lt; 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() &lt; 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() &lt; 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() &lt; 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.println();

    }
    else Serial.println("No data!");
  }
}
</code></pre>

<p>New code:</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;TinyGPS++.h&gt;
#include &lt;SoftwareSerial.h&gt;


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

char clat[11];
char clng[11];

void loop()
{
    //if (buttons || tilt) {
    //if (buttons &amp; BUTTON_SELECT) {

        bool isGpsLocationValid = false;
        do
        {  
            while (ss.available()&gt;0)
            {
                char c = byte(ss.read());
                if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then
                {    
                    if (gps.location.isValid())
                    {
                        dtostrf(gps.location.lat(), 11, 6, clat);
                        dtostrf(gps.location.lng(), 11, 6, clng);
                        //send-print
                        //delay (just in case multiple bumps)
                        isGpsLocationValid = true;
                    }
                }   
             }
        } while (isGpsLocationValid == false);
        Serial.write(clat);
        Serial.println();
        Serial.write(clng);
       //}
    //}
}
</code></pre>

<p>EDIT: The newest code i have posted works 100%!
So if you have similar problems with that aweful gps, use this!</p>

<p>Apparently, TinyGPS and TinyGPS++ don't work well with this gps.
To be precice, there is a problem with the gps.encode(c) function.</p>

<p>So using <code>if (gps.encode(c))</code> most of the times returns false, except some rare occasions which returns true and then you can do some processing...</p>

<p>My last code takes care of that problem by checking continuously, using a do...while loop.
If <code>if (gps.location.isValid())</code> returns true, which means i have valid data, then i do the processing i want and end the do...while loop.</p>
 1499: <p>The newest code i have posted works 100%! So if you have similar problems with that aweful gps, use this!</p>

<p>Apparently, TinyGPS and TinyGPS++ don't work well with this gps. To be precice, there is a problem with the gps.encode(c) function.</p>

<p>So using <code>if (gps.encode(c))</code> most of the times returns false, except some rare occasions which returns true and then you can do some processing...</p>

<p>My last code takes care of that problem by checking continuously, using a do...while loop. If <code>if (gps.location.isValid())</code> returns true, which means i have valid data, then i do the processing i want and end the do...while loop.</p>

<p><strong>NOTE:</strong> This code is for TinyGPS++ library. Same theory will work for TinyGPS too of course...</p>

<p>Here it is:</p>

<pre class="lang-c prettyprint-override"><code>#include &lt;TinyGPS++.h&gt;
#include &lt;SoftwareSerial.h&gt;


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

char clat[11];
char clng[11];

void loop()
{
    bool isGpsLocationValid = false;
    do
    {  
        while (ss.available()&gt;0)
        {
            char c = byte(ss.read());
            if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then
            {    
                if (gps.location.isValid())
                {
                    dtostrf(gps.location.lat(), 11, 6, clat);
                    dtostrf(gps.location.lng(), 11, 6, clng);                        
                    isGpsLocationValid = true;
                }
            }   
        }
    } while (isGpsLocationValid == false);
    Serial.write(clat);
    Serial.println();
    Serial.write(clng);
}
</code></pre>
