NEO-6M GPS Module With Arduino

About: Share Knowledge about Arduino, ESP,GSM,Basic Electronics, DIY PROJECTS, Raspberry pi

This post shows how to use the NEO-6M GPS module with the Arduino to get GPS data. GPS stands for Global Positioning System and can be used to determine position, time, and speed if you’re travelling.

You’ll learn how to:

  • Wire the NEO-6M GPS module to the Arduino UNO
  • Get raw GPS data
  • Parse raw data to obtain selected and readable GPS information
  • Get location

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Introducing the NEO-6M GPS Module

The NEO-6M GPS module is shown in the figure Above. It comes with an external antenna, and does’t come with header pins. So, you’ll need to get and solder some.

  • This module has an external antenna and built-in EEPROM.
  • Interface: RS232 TTL
  • Power supply: 3V to 5V
  • Default baudrate: 9600 bps
  • Works with standard NMEA sentences
  • The NEO-6M GPS module is also compatible with other microcontroller boards.

Step 2: Where to Buy?

You can get the NEO-6M GPS module for a price between $5 to $20. We recommend checking the NEO-6M GPS module.

Step 3: Pin Wiring

The NEO-6M GPS module has four pins: VCC, RX, TX, and GND. The module communicates with the Arduino via serial communication using the TX and RX pins, so the wiring couldn’t be simpler

NEO-6M GPS Module Wiring to Arduino UNO

VCC 5V

RX TX pin defined in the software serial

TX RX pin defined in the software serial

GND GND

Step 4: Schematics

Wire the NEO-6M GPS module to your Arduino by following the schematic Above.

  • The module GND pin is connected to Arduino GND pin
  • The module RX pin is connected to Arduino pin 3
  • The module TX pin is connected to Arduino pin 4
  • The module VCC pin is connected to Arduino 5V pin

Step 5: Code

Copy the following code to your Arduino IDE and upload it to your Arduino board.

#include <SoftwareSerial.h>

// The serial connection to the GPS module

SoftwareSerial ss(4, 3);

void setup()

{

Serial.begin(9600); ss.begin(9600);

}

void loop()

{

while (ss.available() > 0){

// get the byte data from the GPS

byte gpsData = ss.read();

Serial.write(gpsData); }

}

Step 6: Output

Open the Serial Monitor at a baud rate of 9600.

You should get a bunch of information in the GPS standard language, NMEA. Each line you get int the serial monitor is an NMEA sentence.
NMEA stands for National Marine Electronics Association, and in the world of GPS, it is a standard data format supported by GPS manufacturers.

Step 7: Parsing NMEA Sentences With TinyGPS++ Library

You can work with the raw data from the GPS, or you can convert those NMEA messages into a readable and useful format, by saving the characters sequences into variables. To do that, we’re going to use theTinyGPS++ library.

This library makes it simple to get information on location in a format that is useful and easy to understand. You can click here for more information about the TinyGPS++ Library.

Step 8: Installing the TinyGPS++ Library

Follow the next steps to install the TinyGPS++ library in your Arduino IDE:

1.Click hereto download the TinyGPSPlus library. You should have a .zip folder in your Downloads folder

2.Unzip the .zip folder and you should get TinyGPSPlus-master folder

3.Rename your folder from TinyGPSPlus-master to TinyGPSPlus

4.Move the TinyGPSPlus folder to your Arduino IDE installation libraries folder

5.Finally, re-open your Arduino IDE

The library provides several examples on how to use it.

In your Arduino IDE, you just need to go to File > Examples > TinyGPS++, and choose from the examples provided.

Note: the examples provided in the library assume a baud rate of 4800 for the GPS module. You need to change that to 9600 if you’re using the NEO-6M GPS module.

You can get the location in a format that is convenient and useful by using the TinyGPS++ library. Below, we provide a code to get the location from the GPS. This is a simplified version of one of the library examples.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <TinyGPS++.h>

#include<SoftwareSerial.h>

static const int RXPin = 4, 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(9600);

ss.begin(GPSBaud);

}

void loop(){

// This sketch displays information every time a new sentence is correctly encoded.

while (ss.available() > 0){

gps.encode(ss.read());

if (gps.location.isUpdated()){

Serial.print("Latitude= ");

Serial.print(gps.location.lat(), 6);

Serial.print(" Longitude= ");

Serial.println(gps.location.lng(), 6);

}

}

}

Step 9: Upload the Code to Your Arduino

Upload the code to your Arduino, and you should see the location displayed on the serial monitor. After uploading the code, wait a few minutes while the module adjusts the position to get a more accurate data.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    Discussions