Arduino Neo 6m GPS module Interfacing, Programming, Library
Table of Contents
Neo 6m GPS Description:
Neo 6m GPS Module is one of the most frequently used GPS modules throughout the world. The Neo-6m GPS module is used for Location Tracking. I have been using the Ublox Neo 6m GPS module in different types of advanced level projects, which you can check out by clicking on the links given below.
Due to a lot of requests from my Subscribers and Followers, I decided to make a very basic tutorial on the Ublox Neo GPS Module explaining each and every detail.
In this tutorial, you will learn how to use the Ublox Neo-6m GPS Module with Arduino and find the Longitude and Latitude values along with the Speed and date-time information. In this
Tutorial, I have tried to cover the maximum things so that you don’t need to search for any other Article. In this article, I will also explain under what circumstances you don’t get the Longitude and Latitude Values? This is a very common problem which I will discuss in this Tutorial.
The library used in this project is developed by Mikal Hart.
In this tutorial, we will cover
- Neo 6m GPS Module Pinout
- soldering
- Neo-6m GPS Module features
- Neo-6m GPS Module interfacing with Arduino Uno
- Neo-6m GPS Module programming and finally
- Testing
Amazon Links:
Arduino Nano USB-C Type (Recommended)
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
What is GPS?
GPS or Global Positioning System is a satellite navigation system that furnishes location and time information in all climate conditions to the user. GPS is used for navigation in planes, ships, cars, and so on. GPS provides continuous real-time, 3-dimensional positioning, navigation, and timing worldwide. The GPS is used to finding the Longitude and Latitude values.
How GPS Determines a Position:
The working/operation of the Global positioning system is based on the ‘trilateration’ mathematical principle. The position is determined from the distance measurements to satellites. From the figure, the four satellites are used to determine the position of the receiver on the earth. The target location is confirmed by the 4th satellite. And three satellites are used to trace the location place. A fourth satellite is used to confirm the target location of each of those space vehicles. The global positioning system consists of a satellite control station, and a monitor station and receiver. The GPS receiver takes the information from the satellite and uses the method of triangulation to determine a user’s exact position.
About the Neo-6m GPS Module:
This is the Ublox Neo 6M GPS module that I am going to use in this Tutorial.
This GPS module can be interfaced with the Arduino using VCC, RX, TX, and GDND. In order to interface this module with Arduino, we will need to solder 4 wires. Usually, the Ublox NEO GPS modules come with the male headers, and using Male to Female type jumper wires this module can be easily interfaced with the Arduino. But if this GPS module does not have any Male headers then you can solder 4 wires.
For the easy Soldering, first of all, apply solder to all the wires that you want to solder with the GPS module, it will save a lot of time. So after applying solder to the 4 wires then I started attaching the wires with the VCC, RX, TX, and Ground.
After I was done with the Soldering then I started checking the short circuit using a Digital Multimeter. To avoid any damage always check the short circuit before you power up any circuit. To check the short circuit set the multimeter on the Beep or continuity.
As you can see there is a short circuit. You can practically see how beneficial this can be. So always check the short circuit and continuity before powering up the circuit.
I removed the solder bridge and I tested again the short circuit and this time everything was just fine. Now this GPS module is ready and can be interfaced with the Arduino Uno or Mega.
Neo 6M GPS Module Features as per the Datasheet:
This GPS module can be powered up using 3 to 5v. I will be using 5v. Its default baud rate is 9600 which we will be using in the programming.
Dimensions help in calculating the size of the final product. We can use this information to make a plastic enclosure in SolidWorks or any other software.
Neo GPS Arduino wiring:
The Neo-6M GPS module interfacing with Arduino is very simple. The VCC of the GPD module is connected with 5v, RX will be connected with pin3 of the Arduino, TX will be connected with pin2 of the Arduino and Ground will be connected with the Arduino’s GND.
I followed the same exact connections and now this GPS module is ready for the programming.
Before you start the Programming, first of all, make sure that you download the TinyGPSPlus library. While you don’t need to download the SoftwareSerial library, this is already available in the Arduino IDE, all you need is only include this in the programming.
Download TinyGPS: TinyGPSPlus
Neo 6m GPS Arduino Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
#include <TinyGPS++.h> #include <SoftwareSerial.h> /* This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object. It requires the use of SoftwareSerial, and assumes that you have a 4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx). */ // connect tx pin of the gps module with rx pin of arduino // connect rx pin of the gps module with tx pin of the arduino // vcc with 5v // gnd with ground of arduino static const int RXPin = 2, 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(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); Serial.print(" "); Serial.print(F("Speed:")); Serial.print(gps.speed.kmph()); } 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(); } /* Commands that we can try also Serial.println(gps.location.lat()); // Latitude in degrees (double) Serial.println(gps.location.lng()); // Longitude in degrees (double) Serial.print(gps.location.rawLat().negative ? "-" : "+"); Serial.println(gps.location.rawLat().deg); // Raw latitude in whole degrees Serial.println(gps.location.rawLat().billionths);// ... and billionths (u16/u32) Serial.print(gps.location.rawLng().negative ? "-" : "+"); Serial.println(gps.location.rawLng().deg); // Raw longitude in whole degrees Serial.println(gps.location.rawLng().billionths);// ... and billionths (u16/u32) Serial.println(gps.date.value()); // Raw date in DDMMYY format (u32) S erial.println(gps.date.year()); // Year (2000+) (u16) Serial.println(gps.date.month()); // Month (1-12) (u8) Serial.println(gps.date.day()); // Day (1-31) (u8) Serial.println(gps.time.value()); // Raw time in HHMMSSCC format (u32) Serial.println(gps.time.hour()); // Hour (0-23) (u8) Serial.println(gps.time.minute()); // Minute (0-59) (u8) Serial.println(gps.time.second()); // Second (0-59) (u8) Serial.println(gps.time.centisecond()); // 100ths of a second (0-99) (u8) Serial.println(gps.speed.value()); // Raw speed in 100ths of a knot (i32) Serial.println(gps.speed.knots()); // Speed in knots (double) Serial.println(gps.speed.mph()); // Speed in miles per hour (double) Serial.println(gps.speed.mps()); // Speed in meters per second (double) Serial.println(gps.speed.kmph()); // Speed in kilometers per hour (double) Serial.println(gps.course.value()); // Raw course in 100ths of a degree (i32) Serial.println(gps.course.deg()); // Course in degrees (double) Serial.println(gps.altitude.value()); // Raw altitude in centimeters (i32) Serial.println(gps.altitude.meters()); // Altitude in meters (double) Serial.println(gps.altitude.miles()); // Altitude in miles (double) Serial.println(gps.altitude.kilometers()); // Altitude in kilometers (double) Serial.println(gps.altitude.feet()); // Altitude in feet (double) Serial.println(gps.satellites.value()); // Number of satellites in use (u32) Serial.println(gps.hdop.value()); // Horizontal Dim. of Precision (100ths-i32) Chat Conversation End */ |
For the complete program explanation and Practical testing, you can watch a video tutorial given at the end.
Neo 6m GPS module connection Problem and how to fix it:
There are situations when you don’t get the longitude and latitude values, the same thing has happened to me and maybe you will also face the same problem. If you are using the same program and connections and still unable to receive the longitude and latitude values then I am sure you might be inside a Building or in the Basement.
To solve this problem, don’t use this GPS module in the Basement or in a building, because this way the GPS module will take a lot of time in connecting with the Satellites or it will never connect. So try to use this in an open space. I am telling you this from my personal experience as I have been using this GPS module for years.
how can change the time in GMT+8?