How to interface GPS Module(ublox neo-6m) with Arduino

Vinoth Kumar
2 min readJan 24, 2021

GPS module is the cheapest and interesting add-on to work with. GPS module helps to know the real-time longitude and latitude of the current location. By using the GPS module we can log the Latitude and Longitude data into Google map or any other map services.

Connection:

GPS module with Arduino (UNO):

Connect VCC or Supply pin of GPS module to 5v of Arduino UNO (3.3v is also allowed), the Ground pin of GPS module to Ground Pin of Arduino UNO, TX of GPS Module to D2(2) of Arduino UNO, RX of GPS Module to D3 (3) of Arduino UNO.

Vcc5vGNDGNDTXD2 (2)RXD3 (3)Pin Diagram for Arduino UNO

GPS module with ESP 8266/Node MCU:

Connect VCC or Supply pin of GPS module to 3.3V of Node MCU the Ground pin of GPS module to Ground Pin of Node MCU, TX of GPS Module to D6 of Node MCU, RX of GPS Module to D7 of Node MCU.

Vcc5vGNDGNDTXD6RXD7Pin Diagram for Node MCU

Code:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 12, TXPin = 13;
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(115200);
ss.begin(GPSBaud);
Serial.println(F("DeviceExample.ino"));
Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo()
{
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();

--

--

Vinoth Kumar

Embedded Engineer who doing lot DIY's and Physical Computing for Fun.