{"id":49434,"date":"2018-01-04T14:46:48","date_gmt":"2018-01-04T14:46:48","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=49434"},"modified":"2025-03-24T11:51:57","modified_gmt":"2025-03-24T11:51:57","slug":"guide-to-neo-6m-gps-module-with-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/guide-to-neo-6m-gps-module-with-arduino\/","title":{"rendered":"Guide to NEO-6M GPS Module with Arduino"},"content":{"rendered":"\n<p>This guide shows how to use the NEO-6M GPS module with the Arduino to get GPS data.&nbsp;GPS stands for <em>Global Positioning System<\/em> and&nbsp;can be used to determine position, time, and speed if you&#8217;re travelling.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO-GPS-Arduino-thumbnail.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-49460\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO-GPS-Arduino-thumbnail.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO-GPS-Arduino-thumbnail.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO-GPS-Arduino-thumbnail.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO-GPS-Arduino-thumbnail.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>You&#8217;ll learn how to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wire the NEO-6M GPS module to the Arduino UNO<\/li>\n\n\n\n<li>Get raw GPS data<\/li>\n\n\n\n<li>Parse raw data to obtain selected and readable GPS information<\/li>\n\n\n\n<li>Get location<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing the NEO-6M GPS Module<\/h2>\n\n\n\n<p>The NEO-6M GPS module is shown in the figure below. It comes with an external antenna, and does&#8217;t come with header pins. So, you&#8217;ll need to get and solder some.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"670\" height=\"526\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/NEO-GPS-1.jpg?resize=670%2C526&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-45439\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/NEO-GPS-1.jpg?w=670&amp;quality=100&amp;strip=all&amp;ssl=1 670w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/NEO-GPS-1.jpg?resize=300%2C236&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>This module has an external antenna and built-in EEPROM.<\/li>\n\n\n\n<li>Interface: RS232 TTL<\/li>\n\n\n\n<li>Power supply: 3V to 5V<\/li>\n\n\n\n<li>Default baudrate: 9600 bps<\/li>\n\n\n\n<li>Works with standard NMEA sentences<\/li>\n<\/ul>\n\n\n\n<p>The NEO-6M GPS module is also compatible with other microcontroller boards. To learn how to use the NEO-6M GPS module with the Raspberry Pi, you can read:&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/email-alert-system-on-location-change-with-raspberry-pi-and-gps-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">Email Alert System on Location Change with Raspberry Pi and GPS Module<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Where to buy?<\/h3>\n\n\n\n<p>You can get the NEO-6M GPS module for a price between $5 to $20. We recommend checking the <a href=\"https:\/\/makeradvisor.com\/tools\/neo-6m-gps-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">NEO-6M GPS module page on Maker Advisor<\/a> to compare the price in different stores and find the best one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pin Wiring<\/h3>\n\n\n\n<p>The NEO-6M GPS module has four pins: <span class=\"rnthl rntcred\">VCC<\/span>, <span class=\"rnthl rntclgray\">RX<\/span>, <span class=\"rnthl rntcyellow\">TX<\/span>, and <span class=\"rnthl rntcblack\">GND<\/span>. The module communicates with the Arduino via serial communication using the TX and RX pins, so the wiring couldn&#8217;t be simpler:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>NEO-6M GPS Module<\/strong><\/td><td><strong>Wiring to Arduino UNO<\/strong><\/td><\/tr><tr><td><span class=\"rnthl rntcred\">VCC<\/span><\/td><td>5V<\/td><\/tr><tr><td><span class=\"rnthl rntclgray\">RX<\/span><\/td><td>TX pin defined in the software serial<\/td><\/tr><tr><td><span class=\"rnthl rntcyellow\">TX<\/span><\/td><td>RX pin defined in the software serial<\/td><\/tr><tr><td><span class=\"rnthl rntcblack\">GND<\/span><\/td><td>GND<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Getting GPS Raw Data<\/h2>\n\n\n\n<p>To get raw GPS data you just need to start a serial communication with the GPS module using Software Serial. Continue reading to see how to do that.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Parts Required<\/h3>\n\n\n\n<p>For testing this example you&#8217;ll need the following parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/compatible-arduino-uno-r3-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">Arduino<\/a> &#8211; read <a href=\"https:\/\/makeradvisor.com\/best-arduino-starter-kits\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best Arduino Starter Kits<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/neo-6m-gps-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">NEO-6M GPS module<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jumper wires<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Schematics<\/h3>\n\n\n\n<p>Wire the NEO-6M GPS module to your Arduino by following the schematic below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1200\" height=\"645\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO_6M_Arduino.png?resize=1200%2C645&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-49448\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO_6M_Arduino.png?w=1428&amp;quality=100&amp;strip=all&amp;ssl=1 1428w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO_6M_Arduino.png?resize=300%2C161&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO_6M_Arduino.png?resize=768%2C413&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO_6M_Arduino.png?resize=1024%2C551&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO_6M_Arduino.png?resize=280%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 280w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>The module GND pin is connected to Arduino <span class=\"rnthl rntcblack\">GND<\/span> pin<\/li>\n\n\n\n<li>The module RX pin is connected to Arduino <span class=\"rnthl rntclgray\">pin 3<\/span><\/li>\n\n\n\n<li>The module TX pin is connected to Arduino <span class=\"rnthl rntcyellow\">pin 4<\/span><\/li>\n\n\n\n<li>The module VCC pin is connected to Arduino <span class=\"rnthl rntcred\">5V<\/span> pin<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Code<\/h3>\n\n\n\n<p>Copy the following code to your Arduino IDE and upload it to your Arduino board.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n * Rui Santos \n * Complete Project Details http:\/\/randomnerdtutorials.com\n *\/\n \n#include &lt;SoftwareSerial.h&gt;\n\n\/\/ The serial connection to the GPS module\nSoftwareSerial ss(4, 3);\n\nvoid setup(){\n  Serial.begin(9600);\n  ss.begin(9600);\n}\n\nvoid loop(){\n  while (ss.available() &gt; 0){\n    \/\/ get the byte data from the GPS\n    byte gpsData = ss.read();\n    Serial.write(gpsData);\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Arduino-GPS\/GPS_Raw_Data.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>This sketch assumes you are using <span class=\"rnthl rntcyellow\">pin 4<\/span> and <span class=\"rnthl rntclgray\">pin 3<\/span> as RX and TX serial pins to establish serial communication with the GPS module. If you&#8217;re using other pins you should edit that on the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SoftwareSerial ss(4, 3);<\/code><\/pre>\n\n\n\n<p>Also, if your module uses a different default baud rate than 9600 bps, you should modify the code on the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ss.begin(9600);<\/code><\/pre>\n\n\n\n<p>This sketch listen to the GPS serial port, and when data is received from the module, it is sent to the serial monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>while (ss.available() &gt; 0){\n  \/\/ get the byte data from the GPS\n  byte gpsData = ss.read();\n  Serial.write(gpsData);\n}<\/code><\/pre>\n\n\n\n<p>Open the Serial Monitor at a baud rate of 9600.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"425\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/GPS-raw-data-serial-monitor-blurred-2.png?resize=730%2C425&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-49503\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/GPS-raw-data-serial-monitor-blurred-2.png?w=730&amp;quality=100&amp;strip=all&amp;ssl=1 730w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/GPS-raw-data-serial-monitor-blurred-2.png?resize=300%2C175&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 730px) 100vw, 730px\" \/><\/figure><\/div>\n\n\n<p>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.<\/p>\n\n\n\n<p>NMEA stands for National Marine Electronics Association, and in the world of GPS, it is a standard data format supported by GPS manufacturers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Understanding NMEA Sentences<\/h3>\n\n\n\n<p>NMEA sentences start with the $ character, and each data field is separated by a comma.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>$GPGGA<\/strong>,110617.00,41XX.XXXXX,N,00831.54761,W,1,05,2.68,129.0,M,50.1,M,,*42\n<strong>$GPGSA<\/strong>,A,3,06,09,30,07,23,,,,,,,,4.43,2.68,3.53*02\n<strong>$GPGSV<\/strong>,3,1,11,02,48,298,24,03,05,101,24,05,17,292,20,06,71,227,30*7C\n<strong>$GPGSV<\/strong>,3,2,11,07,47,138,33,09,64,044,28,17,01,199,,19,13,214,*7C\n<strong>$GPGSV<\/strong>,3,3,11,23,29,054,29,29,01,335,,30,29,167,33*4E\n<strong>$GPGLL<\/strong>,41XX.XXXXX,N,00831.54761,W,110617.00,A,A*70\n<strong>$GPRMC<\/strong>,110618.00,A,41XX.XXXXX,N,00831.54753,W,0.078,,030118,,,A*6A \n<strong>$GPVTG<\/strong>,,T,,M,0.043,N,0.080,K,A*2C<\/pre>\n\n\n\n<p>There are different types of NMEA sentences. The type of message is indicated by the characters before the first comma.<\/p>\n\n\n\n<p>The GP after the $ indicates it is a GPS position.&nbsp; The $GPGGA is the basic GPS NMEA message, that provides 3D location and accuracy data. In the following sentence:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>$GPGGA<\/strong>,110617.00,41XX.XXXXX,N,00831.54761,W,1,05,2.68,129.0,M,50.1,M,,*42<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>110617<\/strong> &#8211; represents the time at which the fix location was taken, 11:06:17 UTC<\/li>\n\n\n\n<li><strong>41XX.XXXXX,N<\/strong> &#8211; latitude 41 deg XX.XXXXX&#8217; N<\/li>\n\n\n\n<li><strong>00831.54761,W<\/strong> &#8211; Longitude 008 deg 31.54761&#8242; W<\/li>\n\n\n\n<li><strong>1<\/strong> &#8211; fix quality (0 = invalid; 1= GPS fix; 2 = DGPS fix; 3 = PPS fix; 4 = Real Time Kinematic; 5 = Float RTK; 6 = estimated (dead reckoning); 7 = Manual input mode; 8 = Simulation mode)<\/li>\n\n\n\n<li><strong>05<\/strong> &#8211; number of satellites being tracked<\/li>\n\n\n\n<li><strong>2.68<\/strong> &#8211; Horizontal dilution of position<\/li>\n\n\n\n<li><strong>129.0, M<\/strong> &#8211; Altitude, in meters above the sea level<\/li>\n\n\n\n<li><strong>50.1, M<\/strong> &#8211;&nbsp;Height of geoid (mean sea level) above WGS84 ellipsoid<\/li>\n\n\n\n<li>empty field &#8211;&nbsp;time in seconds since last DGPS update<\/li>\n\n\n\n<li>empty field &#8211;&nbsp;DGPS station ID number<\/li>\n\n\n\n<li><strong>*42<\/strong> &#8211; the checksum data, always begins with *<\/li>\n<\/ul>\n\n\n\n<p>The other NMEA sentences provide additional information:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$GPGSA<\/strong> &#8211;&nbsp;GPS DOP and active satellites<\/li>\n\n\n\n<li><strong>$GPGSV<\/strong> &#8211;&nbsp;Detailed GPS satellite information<\/li>\n\n\n\n<li><strong>$GPGLL<\/strong> &#8211;&nbsp;Geographic Latitude and Longitude<\/li>\n\n\n\n<li><strong>$GPRMC<\/strong> &#8211;&nbsp;Essential GPS pvt (position, velocity, time) data<\/li>\n\n\n\n<li><strong>$GPVTG<\/strong> &#8211;&nbsp;Velocity made good<\/li>\n<\/ul>\n\n\n\n<p>To know what each data field means in each of these sentences, you can consult <a href=\"http:\/\/www.gpsinformation.org\/dale\/nmea.htm\" target=\"_blank\" rel=\"noreferrer noopener\">NMEA data here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parsing NMEA Sentences with TinyGPS++ Library<\/h2>\n\n\n\n<p>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&#8217;re going to use the&nbsp;<a href=\"https:\/\/github.com\/mikalhart\/TinyGPSPlus\" target=\"_blank\" rel=\"noreferrer noopener\">TinyGPS++ library<\/a>.<\/p>\n\n\n\n<p>This library makes it simple to get information on location in a format that is useful and easy to understand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the TinyGPS++ Library<\/h3>\n\n\n\n<p>In the Arduino IDE, go to <strong>Sketch <\/strong>> I<strong>nclude Library<\/strong> > <strong>Manage Libraries<\/strong> or click on the Library Manager icon at the left sidebar.<\/p>\n\n\n\n<p>Search for <strong>TinyGPSPlus<\/strong> and install the library by Mikal Hart.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"497\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/install-tiny-gps-plus-library-arduino-ide.png?resize=750%2C497&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing TinyGPSPlus Library Arduino IDE\" class=\"wp-image-160832\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/install-tiny-gps-plus-library-arduino-ide.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/install-tiny-gps-plus-library-arduino-ide.png?resize=300%2C199&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The library provides several examples of how to use it. In your Arduino IDE, you just need to go to&nbsp;<strong>File&nbsp;<\/strong>&gt;&nbsp;<strong>Examples<\/strong> &gt; <strong>TinyGPS++<\/strong>, and choose from the examples provided.<\/p>\n\n\n\n<p><strong>Note<\/strong>: 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&#8217;re using the NEO-6M GPS module.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Getting Location Using the NEO-6M GPS Module and the TinyGPS++ Library<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n * Rui Santos \n * Complete Project Details http:\/\/randomnerdtutorials.com\n *\/\n \n#include &lt;TinyGPS++.h&gt;\n#include &lt;SoftwareSerial.h&gt;\n\nstatic const int RXPin = 4, TXPin = 3;\nstatic const uint32_t GPSBaud = 9600;\n\n\/\/ The TinyGPS++ object\nTinyGPSPlus gps;\n\n\/\/ The serial connection to the GPS device\nSoftwareSerial ss(RXPin, TXPin);\n\nvoid setup(){\n  Serial.begin(9600);\n  ss.begin(GPSBaud);\n}\n\nvoid loop(){\n  \/\/ This sketch displays information every time a new sentence is correctly encoded.\n  while (ss.available() &gt; 0){\n    gps.encode(ss.read());\n    if (gps.location.isUpdated()){\n      Serial.print(&quot;Latitude= &quot;); \n      Serial.print(gps.location.lat(), 6);\n      Serial.print(&quot; Longitude= &quot;); \n      Serial.println(gps.location.lng(), 6);\n    }\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Arduino-GPS\/NEO_6M_get_location.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>You start by importing the needed libraries: <span class=\"rnthl rntliteral\">TinyGPSPlus<\/span> and <span class=\"rnthl rntliteral\">SoftwareSerial<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;TinyGPS++.h&gt;\n#include &lt;SoftwareSerial.h&gt;<\/code><\/pre>\n\n\n\n<p>Then, you define the software serial RX and TX pins, as well as the GPS baud rate. If you are using other pins for software serial you need to change that here. Also, if your GPS module uses a different default baud rate, you should also modify that.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>static const int RXPin = 4, TXPin = 3;\nstatic const uint32_t GPSBaud = 9600;<\/code><\/pre>\n\n\n\n<p>Then, you create a <span class=\"rnthl rntliteral\">TinyGPS++<\/span> object:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TinyGPSPlus gps;<\/code><\/pre>\n\n\n\n<p>And start a serial connection on the pins you&#8217;ve defined earlier<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SoftwareSerial ss(RXPin, TXPin);<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, you initialize serial communication, both to see the readings on the serial monitor and to communicate with the GPS module.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void setup() {\n  Serial.begin(9600);\n  ss.begin(GPSBaud);\n}<\/code><\/pre>\n\n\n\n<p>In the loop is where you request the information. To get TinyGPS++ to work, you have to repeatedly funnel the characters to it from the GPS module using the <span class=\"rnthl rntliteral\">encode()<\/span> method.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>while (ss.available() &gt; 0){\n gps.encode(ss.read());<\/code><\/pre>\n\n\n\n<p>Then, you can query the <span class=\"rnthl rntliteral\">gps<\/span> object to see if any data fields have been updated:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (gps.location.isUpdated()){\n  Serial.print(\"Latitude=\"); Serial.print(gps.location.lat(), 6);\n  Serial.print(\"Longitude=\"); Serial.println(gps.location.lng(), 6);\n}<\/code><\/pre>\n\n\n\n<p>Getting the latitude and longitude is as simple has using <span class=\"rnthl rntliteral\">gps.location.lat()<\/span>, and <span class=\"rnthl rntliteral\">gps.location.lng()<\/span>, respectively.<\/p>\n\n\n\n<p>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 more accurate data.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"535\" height=\"362\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/GPS-get-location-serial-monitor-blurred-2.png?resize=535%2C362&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-49502\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/GPS-get-location-serial-monitor-blurred-2.png?w=535&amp;quality=100&amp;strip=all&amp;ssl=1 535w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/GPS-get-location-serial-monitor-blurred-2.png?resize=300%2C203&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 535px) 100vw, 535px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Getting More GPS Information Using the TinyGPS++ Library<\/h3>\n\n\n\n<p>The TinyGPS++ library allows you to get way more information than just the location, and in a simple way. Besides the location, you can get:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>date<\/li>\n\n\n\n<li>time<\/li>\n\n\n\n<li>speed<\/li>\n\n\n\n<li>course<\/li>\n\n\n\n<li>altitude<\/li>\n\n\n\n<li>satellites<\/li>\n\n\n\n<li>hdop<\/li>\n<\/ul>\n\n\n\n<p>The code below exemplifies how you can get all that information in a simple way.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n * Rui Santos \n * Complete Project Details http:\/\/randomnerdtutorials.com\n *\n * Based on the example TinyGPS++ from arduiniana.org\n *\n *\/\n \n#include &lt;TinyGPS++.h&gt;\n#include &lt;SoftwareSerial.h&gt;\n\nstatic const int RXPin = 4, TXPin = 3;\nstatic const uint32_t GPSBaud = 9600;\n\n\/\/ The TinyGPS++ object\nTinyGPSPlus gps;\n\n\/\/ The serial connection to the GPS device\nSoftwareSerial ss(RXPin, TXPin);\n\nvoid setup(){\n  Serial.begin(9600);\n  ss.begin(GPSBaud);\n}\n\nvoid loop(){\n  \/\/ This sketch displays information every time a new sentence is correctly encoded.\n  while (ss.available() &gt; 0){\n    gps.encode(ss.read());\n    if (gps.location.isUpdated()){\n      \/\/ Latitude in degrees (double)\n      Serial.print(&quot;Latitude= &quot;); \n      Serial.print(gps.location.lat(), 6);      \n      \/\/ Longitude in degrees (double)\n      Serial.print(&quot; Longitude= &quot;); \n      Serial.println(gps.location.lng(), 6); \n       \n      \/\/ Raw latitude in whole degrees\n      Serial.print(&quot;Raw latitude = &quot;); \n      Serial.print(gps.location.rawLat().negative ? &quot;-&quot; : &quot;+&quot;);\n      Serial.println(gps.location.rawLat().deg); \n      \/\/ ... and billionths (u16\/u32)\n      Serial.println(gps.location.rawLat().billionths);\n      \n      \/\/ Raw longitude in whole degrees\n      Serial.print(&quot;Raw longitude = &quot;); \n      Serial.print(gps.location.rawLng().negative ? &quot;-&quot; : &quot;+&quot;);\n      Serial.println(gps.location.rawLng().deg); \n      \/\/ ... and billionths (u16\/u32)\n      Serial.println(gps.location.rawLng().billionths);\n\n      \/\/ Raw date in DDMMYY format (u32)\n      Serial.print(&quot;Raw date DDMMYY = &quot;);\n      Serial.println(gps.date.value()); \n\n      \/\/ Year (2000+) (u16)\n      Serial.print(&quot;Year = &quot;); \n      Serial.println(gps.date.year()); \n      \/\/ Month (1-12) (u8)\n      Serial.print(&quot;Month = &quot;); \n      Serial.println(gps.date.month()); \n      \/\/ Day (1-31) (u8)\n      Serial.print(&quot;Day = &quot;); \n      Serial.println(gps.date.day()); \n\n      \/\/ Raw time in HHMMSSCC format (u32)\n      Serial.print(&quot;Raw time in HHMMSSCC = &quot;); \n      Serial.println(gps.time.value()); \n\n      \/\/ Hour (0-23) (u8)\n      Serial.print(&quot;Hour = &quot;); \n      Serial.println(gps.time.hour()); \n      \/\/ Minute (0-59) (u8)\n      Serial.print(&quot;Minute = &quot;); \n      Serial.println(gps.time.minute()); \n      \/\/ Second (0-59) (u8)\n      Serial.print(&quot;Second = &quot;); \n      Serial.println(gps.time.second()); \n      \/\/ 100ths of a second (0-99) (u8)\n      Serial.print(&quot;Centisecond = &quot;); \n      Serial.println(gps.time.centisecond()); \n\n      \/\/ Raw speed in 100ths of a knot (i32)\n      Serial.print(&quot;Raw speed in 100ths\/knot = &quot;);\n      Serial.println(gps.speed.value()); \n      \/\/ Speed in knots (double)\n      Serial.print(&quot;Speed in knots\/h = &quot;);\n      Serial.println(gps.speed.knots()); \n      \/\/ Speed in miles per hour (double)\n      Serial.print(&quot;Speed in miles\/h = &quot;);\n      Serial.println(gps.speed.mph()); \n      \/\/ Speed in meters per second (double)\n      Serial.print(&quot;Speed in m\/s = &quot;);\n      Serial.println(gps.speed.mps()); \n      \/\/ Speed in kilometers per hour (double)\n      Serial.print(&quot;Speed in km\/h = &quot;); \n      Serial.println(gps.speed.kmph()); \n\n      \/\/ Raw course in 100ths of a degree (i32)\n      Serial.print(&quot;Raw course in degrees = &quot;); \n      Serial.println(gps.course.value()); \n      \/\/ Course in degrees (double)\n      Serial.print(&quot;Course in degrees = &quot;); \n      Serial.println(gps.course.deg()); \n\n      \/\/ Raw altitude in centimeters (i32)\n      Serial.print(&quot;Raw altitude in centimeters = &quot;); \n      Serial.println(gps.altitude.value()); \n      \/\/ Altitude in meters (double)\n      Serial.print(&quot;Altitude in meters = &quot;); \n      Serial.println(gps.altitude.meters()); \n      \/\/ Altitude in miles (double)\n      Serial.print(&quot;Altitude in miles = &quot;); \n      Serial.println(gps.altitude.miles()); \n      \/\/ Altitude in kilometers (double)\n      Serial.print(&quot;Altitude in kilometers = &quot;); \n      Serial.println(gps.altitude.kilometers()); \n      \/\/ Altitude in feet (double)\n      Serial.print(&quot;Altitude in feet = &quot;); \n      Serial.println(gps.altitude.feet()); \n\n      \/\/ Number of satellites in use (u32)\n      Serial.print(&quot;Number os satellites in use = &quot;); \n      Serial.println(gps.satellites.value()); \n\n      \/\/ Horizontal Dim. of Precision (100ths-i32)\n      Serial.print(&quot;HDOP = &quot;); \n      Serial.println(gps.hdop.value()); \n    }\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Arduino-GPS\/NEO_6M_get_all_GPS_data.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>We hope you&#8217;ve found this guide useful. We intend to make a GPS data logger with the <a href=\"https:\/\/makeradvisor.com\/tools\/neo-6m-gps-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">NEO-6M GPS module<\/a> and the <a href=\"https:\/\/makeradvisor.com\/tools\/sd-card-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">SD card module<\/a>, so stay tuned.<\/p>\n\n\n\n<p>If you liked this project you may also like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/sim900-gsm-gprs-shield-arduino\/\" target=\"_blank\" rel=\"noreferrer noopener\">Guide to SIM900 GSM GPRS Shield with Arduino<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/email-alert-system-on-location-change-with-raspberry-pi-and-gps-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">Email Alert System on Location Change with Raspberry Pi and GPS Module<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/arduino-step-by-step-projects\/\" target=\"_blank\" rel=\"noreferrer noopener\">Arduino Step-by-Step Projects<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide shows how to use the NEO-6M GPS module with the Arduino to get GPS data.&nbsp;GPS stands for Global Positioning System and&nbsp;can be used to determine position, time, and &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Guide to NEO-6M GPS Module with Arduino\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/guide-to-neo-6m-gps-module-with-arduino\/#more-49434\" aria-label=\"Read more about Guide to NEO-6M GPS Module with Arduino\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":49460,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,267,302,269,264,10],"tags":[],"class_list":["post-49434","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-arduino-project","category-0-guide","category-guide-project","category-project","category-a-tutorials"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/01\/NEO-GPS-Arduino-thumbnail.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/49434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=49434"}],"version-history":[{"count":2,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/49434\/revisions"}],"predecessor-version":[{"id":168255,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/49434\/revisions\/168255"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/49460"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=49434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=49434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=49434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}