Beginners GuideSensors/Modules

Arduino GPS Module Interface

There are like a ton of projects that can be made using GPS module with Arduino, to name some are GPS logger, Car Tracker, path tracker and many more. In this tutorial we will learn to interface Arduino with U-Blox Neo6M V2 GPS module( if you don’t have this particular module then no need to worry you can still follow this tutorial with any GPS module that have Serial Communication.)

Components Required:

  • Arduino Uno
  • GPS Module Neo6M V2 (or other)
  • Jumper Wires

If you look at your GPS module it have generally 4 pins: VCC, GND,TX and RX. These modules usually communicate over simple serial connection like RS232 that is the exact protocol which Arduino uses for serial communication, so we will simply use “Serial.being” to read the module data.The module is very simple and it just splits continuously NMEA (National Marine Electronics Association) data strings to the TX pin.

Here, we will first go through reading data from GPS module by just using serial communication and later on look at the dedicated libraries like TinyGPS++ and see how it breaks down the raw GPS data to the one needed  for our projects like latitude, longitude, time, number of satellites and others.

Connection:

Arduino Uno GPS Module
3 RX
4 TX
5V VCC
Gnd GND

 

Code : Getting RAW data from GPS

Ublox NEO-6M GPS Module has build in EEPROM and comes with ceramic antenna. It use Rs232 TTL interface and operates on 3-5V supply with default Baudrate of 9600bps. So, while coding we need to take care of the baudrate of serial communication between the two.

#include <SoftwareSerial.h>
 
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600; //Baudrate of your GPS here
 
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
 
void setup()
{
  Serial.begin(115200); // Beginning the serial monitor at Baudrate 115200 and make sure you select same in serial monitor
  ss.begin(GPSBaud);
}
 
void loop()
{
  // Output raw GPS data to the serial monitor
  while (ss.available() > 0){
    Serial.write(ss.read());
  }
}

 

After uploading the above code you will get something similar to this on your serial monitor:

Here, you can see that the data is not in the format we want that is it is a kind of mess. So, we will now use a dedicated library for this and the most popular and precise is TinyGPS++ (Get this library)

Using TinyGPS++ library :

Step 1: First we have to include the TinyGPS++ library in our Arduino IDE. Go to the GitHub link shared above and download it. It’s a zip file, now extract it and copy it and paste to directory of Arduino IDE under the libraries folder.

Step2: Open Arduino IDE and under File navigate to Examples—TinyGPSPlus and upload any of those sample code. Here we are uploading <DeviceExample> code. Once, the code is uploaded open the serial monitor and you will find the data are now more readable like Location: Latitude, Longitude along with Date/Time.

Some things to take care:
  1. It takes for about half a minute or one to read the data by the GPS module initially when you run it, so do not panic for this it’s very usual.
  2. It happens in some case that it is unable to detect the data that might be the issue with antenna, so unplug the antenna( if it is detachable) and attach it again.
  3. If, code says “Check Connection”, then you should definitely check it twice, before giving up. Also, sometimes interchanging the TX and RX pins is preferable and surprisingly works.
So, here are some of the projects you can make now from the knowledge you gained right now.
  • GPS Car tracker
  • GPS Data logger
  • IOT GPS tracker

 

 

 

 

 

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close