Sponsor Link:

UTSource.net Reviews

It is a trustworthy website for ordering electronic components with cheap price and excellent quality.

Mounting the circuit

Since this project doesn't require a breadboard at all, it makes your life even easier with only 4 jumper wires required. Before making a start, make sure your Arduino board or Ublox Neo-7N GPS module isn't externally powered or connected to power in any way, just to prevent safety hazards from occurring. Now, let's move on to the actual wiring of the modules. First, use one jumper wire to connect the VCC pin (+) on your GPS module to the 5v pin (+5 volts) on your Arduino board. Then, use another jumper wire to connect the GND pin (-) on your Ublox module to any of your Arduino's GND pins (-). After that, hook up the TXD pin (Data Transit) pin of your GPS module to D3 (digital pin 3) of your Arduino for data transmitting. Along with that pin, you will have to hook up the RXD pin (Data Receive) on your GPS module to D4 (digital pin 4) on your Arduino board for receiving data. Now, this wraps up all of the hardware setup to this project.

Arduino Ublox Neo-7N GPS Module Project Code

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);
  Serial.println(F("Ublox Neo-7N GPS Module Test"));
}

void loop()
{
  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();
}

About the code

Utilising one main library, the TinyGPS++ library by Mikal Hart, it helps us massively in using this Ublox GPS module with Arduino. In the first two lines of this sketch, we declare two main libraries for this program to work. Then, we declare the transmit and receive pins which we have hooked up from the GPS module to the Arduino and we also declare the frequency in which the GPS-satellite communication will take place at. Next, on the fourth line, an instance is made, to set up the TinyGPS++ library and state that this library is being utilised. The follow line is an instance for the communication pins (TXD & RXD), which states that we will be using those pins. Now, we move on to the void setup part of this sketch, starting with declaring the baud rate for receiving the data to the computer, it is now set to 115200 bauds but it is changeable to your preference. Right after that line, we start up the GPS module communication. Plus, at the end of the setup section, a message is written to the serial monitor, making sure everything is also ready. Moving on, the void loop section is now present, where while and if functions exists. The first three lines of this section basically means: while this program is running and a new line of information is received from the GPS module, it will be encoded and then displayed. Then another if statement appears, meaning: if 5 seconds has passed and less than 10 data characters is encoded, it will print out the message "No GPS detected: check wiring.", and this whole algorithm will be active while this whole program is working, basically indicating an error. Then, we set up another void section, called displayInfo, which is responsible for printing the positional information. We first print the text, "Location:" into out serial monitor in the first line of this section, followed by another if else statement. This statement says that: if the GPS setup is valid and properly set up, it will print the latitude, longitude, or else a message, "INVALID", will appear in the serial monitor, alerting us that something is wrong. The lat. and long. data is also separated by a comma as stated in the second down of this if else statement. Right after that group of data, we now print out, "Data/Time:" onto the serial monitor, and again we utilise another if else statement, stating that: if the GPS module is working fine, we print the month/day/year into the serial monitor, or else, the message, "INVALID", will appear in the serial monitor. Finally, we are at our last step to this code; calculating the time and displaying it onto the serial monitor. First we set up a big if else statement, saying that if the GPS module is working well, we will continue on with the rest of the code, or else, it will display an error message onto the serial monitor, "INVALID". Now, most of the lines in between this if else statement has a very similar algorithm, just printing out different  data every time. You could substitute these words, hour, minute, second and centisecond, in the following explanation of this repetitive pattern, keeping in mind that the algorithm all work the same and different things are only printed out. The first if statement says: if the count of each hour is less than 10 from the start of this program, print out, "0", followed by the calculated amount of hours, and ending with a colon. That is the basic pattern for the next 3 if statements, just using different data like minutes, seconds and centiseconds. These are all commands from this library, making our life so much easier to just print real-time data. This project is now done.

Amazing opportunities

Also, be sure to check out PCBWay, a leading manufacturer and distributor in PCB design and manufacturing. They have amazing prices and excellent quality in their services, so don't miss out on them! Plus, PCBWay has an amazing website, online Gerber viewer function and a gift shop so make sure to check out their links below:

PCBWay Free Online Gerber Viewer Function:  https://www.pcbway.com/project/OnlineGerberViewer.html

PCBWay Gift Shop: https://www.pcbway.com/projects/gifts.html

Make sure you check out the review for this module by clicking here.

Enjoy! Contact us for any inquiries!