GPS module GY-NEO6MV2 location not working

Hi. I'm testing the GPS module GY-NEO6MV2 in an Arduino UNO board. My objective is getting the location through the serial monitor and put it in somewhere like Google Maps or Google Earth and obtain this location. The connections are these:

  • The module RX pin is connected to Arduino pin 3
  • The module TX pin is connected to Arduino pin 4

When I try this code, it works:

#include <SoftwareSerial.h>

// The serial connection to the GPS module
SoftwareSerial ss(4, 3);

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

void loop(){
  while (ss.available() > 0){
    // get the byte data from the GPS
    byte gpsData = ss.read();
    Serial.write(gpsData);
  }
}

And I receive this information:

I've read about how to interpret this info, but I don't know where I can put it to show the exact location in a map. So I tried these type of codes with libraries to convert this info into latitude, maps location, etc.:

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

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

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

void loop(){
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      Serial.print("Latitude= "); 
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= "); 
      Serial.println(gps.location.lng(), 6);
    }
  }
}

or:

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

TinyGPSPlus gps;

SoftwareSerial gps_serial(3,4);   //RX = 4 TX = 3

double LATITUDE , LONGITUDE;
String latitude="", longitude="";
double SPEED;
String SMS;

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);
    gps_serial.begin(9600);

    pinMode(A1,INPUT);
    pinMode(13,OUTPUT);
    digitalWrite(13, LOW);
    Serial.println(F("arduino with neo 6m gps module"));
    

}




String double_string_con(double input)
{
  String storag1 = "";
  int count=0, count2=0;
  String storag2="";
  char dot='.';
  String val_string="";

  
  storag2=(String)input;
  storag1= (String)(input*1000000);
  //Serial.println(b);
  //Serial.println(j);

  for(int i=0; i<6; i++)
    {
     
     if(storag2.charAt(i)==dot) break;
     count++;
     
    }

  for(int i=0; i<15; i++)
    {
     
     if(storag1.charAt(i)==dot) break;
     count2++;
     
    }
  //Serial.println(count2);
  
  for(int i=0; i<count2; i++)
    {
      if(i==count) 
           {
            val_string = val_string + dot ;
           }
           val_string = val_string + storag1.charAt(i);
    
    }
   
   count=0;
   count2=0;
   return val_string;
}




void loop() {
   
   while (gps_serial.available() > 0)  gps.encode(gps_serial.read());

   if (millis() > 5000 && gps.charsProcessed() < 10)
      {
        Serial.println(F("No GPS detected: check wiring."));
        while(true);
      }  
      
           
  
  int reading;
  reading= analogRead(A1);

  if(reading>800)
        {
          digitalWrite(13, HIGH);
      
          if (gps.location.isValid())
              {
                LATITUDE = gps.location.lat(), 6 ;
                latitude = double_string_con(LATITUDE);
                
                
                LONGITUDE = gps.location.lng(), 6 ;
                longitude = double_string_con(LONGITUDE);
          
                SPEED = gps.speed.kmph();

                
          
               
              }
      
          else
          {
            Serial.println(F("INVALID"));
          }
          
      
           SMS = "caution: Tlit sensor is activated !";       // this part create a msg for gsm module
           SMS = SMS + "\n";
           
           SMS = SMS + "Latitude: ";
           SMS = SMS + latitude;
           SMS = SMS + "\n";
           
           SMS = SMS + "Longitude: ";
           SMS = SMS + longitude;
           SMS = SMS + "\n";
           
           SMS = SMS + "Speed: ";
           SMS = SMS + (String)SPEED;
      
           SMS = SMS + "\n";
           SMS = SMS + "https://www.google.com/maps/search/?api=1&query=";
           SMS = SMS + latitude;
           SMS = SMS + ",";
           SMS = SMS + longitude;
           
      
           Serial.println(SMS);
         
      
           delay(2000);
           digitalWrite(13,LOW);
          }

  
  

}

BUT THESE CODES DON'T WORK. Or I don't get anything in the serial monitor, or I get some strange signs similar to "?".

I would be really grateful if you could help me. Thanks.

try this (with your serial monitor open at 115200 bauds)

#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial ss(4, 3);

void setup() {
  Serial.begin(115200);
  ss.begin(9600);
  Serial.println("Ready");
}

void loop()
{
  if (ss.available() > 0)
    if (gps.encode(ss.read())) {
      Serial.print(F("Location "));
      if (gps.location.isValid()) {
        Serial.print(gps.location.lat(), 6);
        Serial.write(',');
        Serial.println(gps.location.lng(), 6);
      } else {
        Serial.println(F(" is not valid."));
      }
    }
}

RX and TX are backwards

no, he is just talking about the Rx and Tx of the GPS

EDIT

oops you're right in the second code he got that wrong

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.