Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
75 min
Share

Know your location coordinates with Arduino and GPS module

You may have asked yourself before how planes know the coordinates of their location on the map. In fact, planes know the coordinates of their location through the GPS module that is built into the plane control circuits, in this tutorial we will use one of those modules with Arduino. which is NEO-6M GPS module, which can accurately determine your location.

Project Video

Overview

In this tutorial, we will learn about NEO-6M GPS module and how to interface it with Arduino to obtain GPS parameters such as latitude, longitude, altitude date, time, speed, and display them on your computer.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
NEO-6M GPS Module
Get Item
Jumper Wires – Male to Female (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the NEO-6M GPS module and the Arduino, as shown in the image below.

Connections from the NEO-6M GPS module to arduino :

    • Vcc  → Arduino 5V pin

    • GND →  Arduino GND pin

    • RX PIN →  Arduino pin 3

    • TX PIN → Arduino pin 4

Coding


/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial: put the link of the tutorial here

Tutorial: Know your location coordinates with Arduino and gps module!

The function of this sketch is to obtain the latitude, longitude, altitude date, time, speed, and display them on your computer.

Connections from the NEO-6M GPS module to arduino :

• Vcc  → Arduino 5V pin

• GND →  Arduino GND pin

• RX PIN →  Arduino pin 3

• TX PIN → Arduino pin 4

*/

#include "TinyGPS++.h"
#include "SoftwareSerial.h"

const int RXPin = 3, TXPin = 4;
const uint32_t GPSBaud = 9600; //Default baud of NEO-6M is 9600


TinyGPSPlus gps; // the TinyGPS++ object
SoftwareSerial gpsSerial(RXPin, TXPin); // the serial interface to the GPS device

void setup() {
 Serial.begin(9600);
 gpsSerial.begin(GPSBaud);

 Serial.println(F("Arduino - GPS module"));
}

void loop() {
 if (gpsSerial.available() > 0) {
   if (gps.encode(gpsSerial.read())) {
     if (gps.location.isValid()) {
       Serial.print(F("- latitude: "));
       Serial.println(gps.location.lat());

       Serial.print(F("- longitude: "));
       Serial.println(gps.location.lng());

       Serial.print(F("- altitude: "));
       if (gps.altitude.isValid())
         Serial.println(gps.altitude.meters());
       else
         Serial.println(F("INVALID"));
     } else {
       Serial.println(F("- location: INVALID"));
     }

     Serial.print(F("- speed: "));
     if (gps.speed.isValid()) {
       Serial.print(gps.speed.kmph());
       Serial.println(F(" km/h"));
     } else {
       Serial.println(F("INVALID"));
     }

     Serial.print(F("- GPS date&time: "));
     if (gps.date.isValid() && gps.time.isValid()) {
       Serial.print(gps.date.year());
       Serial.print(F("-"));
       Serial.print(gps.date.month());
       Serial.print(F("-"));
       Serial.print(gps.date.day());
       Serial.print(F(" "));
       Serial.print(gps.time.hour());
       Serial.print(F(":"));
       Serial.print(gps.time.minute());
       Serial.print(F(":"));
       Serial.println(gps.time.second());
     } else {
       Serial.println(F("INVALID"));
     }

     Serial.println();
   }
 }

 if (millis() > 5000 && gps.charsProcessed() < 10)
   Serial.println(F("No GPS data received: check wiring"));
}

Testing it Out

Know your location coordinates with Arduino and gps module

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

Now, as shown in the image below, the serial monitor displays the latitude, longitude, altitude date, time, speed, and display them on your computer.

Resources

No items found.