Sitemap / Advertise

Introduction

To generate code for Arduino automatically to obtain data from a GY-NEO6MV2 GPS module, enter RX and TX pins depending on the pinout.


Tags

Share

Arduino | GY-NEO6MV2 GPS Code Generator

Advertisement:


read_later

Read Later



read_later

Read Later

Introduction

To generate code for Arduino automatically to obtain data from a GY-NEO6MV2 GPS module, enter RX and TX pins depending on the pinout.

Tags

Share





Advertisement

Advertisement





Description

To generate code for Arduino automatically to obtain data from a GY-NEO6MV2 GPS module - latitude, longitude, date, month, day, and year - enter RX and TX pins depending on the pinout. And, if you are a novice to use the GY-NEO6MV2 GPS module with Arduino, do not worry this tool provides you with the proper and concise code, including the required library, for the mentioned module. Furthermore, you can use the generated code with any compatible GPS module with the given library.

GY-NEO6MV2 GPS Module(1)

The NEO-6 module series is a family of stand-alone GPS receivers featuring the high performance u-blox 6 positioning engine. These flexible and cost effective receivers offer numerous connectivity options in a miniature 16 x 12.2 x 2.4 mm package. Their compact architecture and power and memory options make NEO-6 modules ideal for battery operated mobile devices with very strict cost and space constraints.

The 50-channel u-blox 6 positioning engine boasts a Time-To-First-Fix (TTFF) of under 1 second. The dedicated acquisition engine, with 2 million correlators, is capable of massive parallel time/frequency space searches, enabling it to find satellites instantly. Innovative design and technology suppresses jamming sources and mitigates multipath effects, giving NEO-6 GPS receivers excellent navigation performance even in the most challenging environments.

Supply of aiding information like ephemeris, almanac, rough last position and time and satellite status and an optional time synchronization signal will reduce time to first fix significantly and improve the acquisition sensitivity. All NEO-6 modules support the u-blox AssistNow Online and AssistNow Offline A-GPS services11 and are OMA SUPL compliant.


Code Generator

Download the TinyGPSPlus library from here.

Define the RX and TX pins and connect the 5V and GND pins to Arduino according to the given pinout.


RX :

TX :


// Connections
// Arduino :           
//                                GY-NEO6MV2 GPS Module
// {{TX_PIN}}  --------------------------- RX
// {{RX_PIN}}  --------------------------- TX


// Include TinyGPS++ to get variables from the GY-NEO6MV2 GPS Module.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>


// Define required variables by TinyGPS++ library.
static const int RXPin = {{RX_PIN}}, TXPin = {{TX_PIN}};
static const uint32_t GPSBaud = 9600;

String latitude, longitude, date, month, day, year, _time, hour, minute, second, centisecond;

// The TinyGPS++ object
TinyGPSPlus gps;

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

void setup() {
  
  Serial.begin(9600);
  
  // Initiate the GPS Module.
  ss.begin(GPSBaud);
}

void loop() {
  
  // This sketch displays information every time a new sentence is correctly encoded on the GPS Module.
    while (ss.available() > 0)
    if (gps.encode(ss.read()))
      get_GPS_Data();
  // Check whether the GPS connection is alive or not.
  if (millis() > 5000 && gps.charsProcessed() < 10) { Serial.println("No GPS detected: check wiring."); while(true); }
}

void get_GPS_Data(){
  Serial.print("\nGathering information from the GPS Module...\n------------------------------\n");
  if(gps.location.isValid()){
      longitude = String(gps.location.lng(), 6);
      latitude = String(gps.location.lat(), 6);
      Serial.print("Location: " + latitude + " , " + longitude + "\n");
  }else{
     longitude = "NotDetected";
     latitude = "NotDetected";
     Serial.print("Location: Not detected...\n");
  }

    if (gps.date.isValid()){
    month = String(gps.date.month());
    day = String(gps.date.day());
    year = String(gps.date.year());
    date = month + "/" + day + "/" + year;
    Serial.print("Date: " + date + "\n");
  }else{
    date = "Failed";
    Serial.print("Date: Failed...\n");
  }

  if (gps.time.isValid()){
    if (gps.time.hour() < 10){ hour = "0" + String(gps.time.hour()); }else{ hour = String(gps.time.hour());}
    if (gps.time.minute() < 10){ minute = "0" + String(gps.time.minute()); }else{ minute = String(gps.time.minute()); } 
    if (gps.time.second() < 10){ second = "0" + String(gps.time.second()); }else{ second = String(gps.time.second()); }
    if (gps.time.centisecond() < 10){ centisecond = "0" + String(gps.time.centisecond()); }else{ centisecond = String(gps.time.centisecond()); }
    _time = hour + ":" + minute + ":" + second + "." + centisecond;
    Serial.print("Time: " + _time + "\n");
  }
  else{
    _time = "Failed";
    Serial.print("Time: Failed...\n");
  }
}


References

(1) https://www.openimpulse.com/blog/wp-content/uploads/wpsc/downloadables/GY-NEO6MV2-GPS-Module-Datasheet.pdf