GPS help

Hi all I just but the GY-GPS6MV2 GPS and I m having some code issues…The only thing that appears in the monitor is “GPS START” and an LED is blinking on the device. This is the code :

#include “TinyGPS++.h”
#include “SoftwareSerial.h”

SoftwareSerial serial_connection(10, 11);
TinyGPSPlus gps;
void setup()
{
Serial.begin(9600);
serial_connection.begin(9600);
Serial.println(“GPS Start”);
}

void loop()
{
while(serial_connection.available())//While there are characters to come from the GPS
{
gps.encode(serial_connection.read());
}
if(gps.location.isUpdated())
{

Serial.println(“Satellite Count:”);
Serial.println(gps.satellites.value());
Serial.println(“Latitude:”);
Serial.println(gps.location.lat(), 6);
Serial.println(“Longitude:”);
Serial.println(gps.location.lng(), 6);
Serial.println(“Speed MPH:”);
Serial.println(gps.speed.mph());
Serial.println(“Altitude Feet:”);
Serial.println(gps.altitude.feet());
Serial.println("");
}
}

if you replace your loop() function with this:

it will tell you if you have a connection to your GPS, otherwise you may have it wored improperly.

void loop()
{
  if(serial_connection.available())
  {
    Serial.println(serial_connection.read());
  }
}

Suggestions:

  • Put your code in [code] tags [/code], so
 it looks
     like this.
  • SoftwareSerial is the worst way to connect the GPS device. Read this for better alternatives. If you use pins 8 & 9, you could use the excellent AltSoftSerial.

  • Then read the next section about connecting a 5V Arduino to a 3.3V GPS device. More level-shifting suggestions here.

  • Be sure the GPS TX pin is connected to the Arduino receive pin (10 in your code). This may work without level-shifting. If you need to send configuration commands to the GPS device, connect the GPS RX pin (through level-shifting) to the Arduino transmit pin (11 in your code). Your sketch does not need to use the GPS RX pin.

  • Be careful about using GPS values that may not be valid.

  • You might try my NeoGPS library. It is smaller, faster, more reliable and more accurate than all other libraries. The examples are structured properly, and can usually be modified without breaking them. Be sure to work through the Installation instructions, to make sure you have the correct configuration. The docs also have some good Troubleshooting tips.

Here is your sketch, modified to use NeoGPS:

#include <NMEAGPS.h>
NMEAGPS gps;

//-----------------
//   Choose a serial port for the GPS device:
//
//   BEST: For a Mega, Leonardo or Due, use the extra hardware serial port
//#define gpsPort Serial1

//   2nd BEST:  For other Arduinos, use AltSoftSerial on the required pins
//                 (8&9 for an UNO)
// #include <AltSoftSerial.h>
// AltSoftSerial gpsPort;  // pin 8 to GPS TX, pin 9 to GPS RX

//   3rd BEST:  If you can't use those specific pins (are you sure?),
//                 use NeoSWSerial on any two pins @ 9600, 19200 or 38400
#include <NeoSWSerial.h>
NeoSWSerial gpsPort( 10, 11 ); // pin 10 to GPS TX, pin 11 to GPS RX (LEVEL-SHIFT!!)

//   WORST:  SoftwareSerial is NOT RECOMMENDED

//-----------------

void setup()
{
  Serial.begin(9600);
  gpsPort.begin(9600);
  Serial.println( F("GPS Start") );
}

void loop()
{
  while(gps.available( gpsPort ))//While there are characters to come from the GPS
  {
    gps_fix fix = gps.read();  // get a complete fix structure when its available

    Serial.print( F("Satellite Count:") );
    if (fix.valid.satellites)
      Serial.print( fix.satellites );

    Serial.print( F("\nLatitude:") );
    if (fix.valid.location)
      Serial.print( fix.latitude(), 6 );
    Serial.print( F("\nLongitude:") );
    if (fix.valid.location)
      Serial.print( fix.longitude(), 6 );

    Serial.print( F("\nSpeed MPH:") );
    if (fix.valid.speed)
      Serial.print( fix.speed_mph() );
    
    Serial.print( F("\nAltitude Feet:") );
    if (fix.valid.altitude)
      Serial.print( fix.altitude() * 3.28084 ); // meters to feet
    Serial.println();
  }
}

The original sketch uses 8912 bytes of program space and 610 bytes of RAM.
The NeoGPS version uses 8908 bytes of program space and 341 bytes of RAM.

If you want to try it, NeoGPS, AltSoftSerial and NeoSWSerial are all available from the Arduino IDE Library Manager, under the menu Sketch → Include Library → Manage Libraries.

Cheers,
/dev