{"id":160875,"date":"2024-08-14T14:23:32","date_gmt":"2024-08-14T14:23:32","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=160875"},"modified":"2025-03-24T11:52:18","modified_gmt":"2025-03-24T11:52:18","slug":"esp8266-nodemcu-neo-6m-gps-module-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-neo-6m-gps-module-arduino\/","title":{"rendered":"ESP8266 NodeMCU with NEO-6M GPS Module (Arduino IDE)"},"content":{"rendered":"\n<p>Learn how to interface the NEO-6M GPS module with an ESP8266 NodeMCU board to get GPS data. You&#8217;ll learn how to get latitude, longitude, altitude, speed, and UTC time. The ESP8266 will be programmed using Arduino IDE.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NODEMCU with NEO-6M GPS Module Arduino IDE\" class=\"wp-image-160880\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>In summary, in this tutorial 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 ESP8266 via serial<\/li>\n\n\n\n<li>Parse raw data to obtain selected and readable GPS information<\/li>\n\n\n\n<li>Get your current location, date, time, and more&#8230;<\/li>\n<\/ul>\n\n\n\n<p>We have a similar guide for the <a href=\"https:\/\/randomnerdtutorials.com\/esp32-neo-6m-gps-module-arduino\/\">ESP32 board with NEO-6M GPS Module (Arduino IDE)<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<p>Throughout this tutorial, we&#8217;ll cover the following subjects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#neo-6m-gps-intro\" title=\"\">Introducing the NEO-6M GPS Module<\/a><\/li>\n\n\n\n<li><a href=\"#neo-6m-gps-wiring-esp8266\" title=\"\">Wiring the NEO-6M GPS Module to the ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"#get-gps-data-neo-6m-esp8266\" title=\"\">ESP8266 with the NEO-6M GPS Module &#8211; Getting GPS Data<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclgreen\">If you&#8217;re new to the ESP8266 board, you may like reading: <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-esp8266-wifi-transceiver-review\/\" title=\"\">Getting Started with ESP8266 NodeMCU Development Board<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"neo-6m-gps-intro\">Introducing the NEO-6M GPS Module<\/h2>\n\n\n\n<p>The NEO-6M GPS module is a GPS receiver compatible with most microcontroller boards. It can get data about location, speed, altitude, and time.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/NEO-6M-GPS-Module.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"NEO-6M GPS Module\" class=\"wp-image-160848\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/NEO-6M-GPS-Module.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/NEO-6M-GPS-Module.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>It comes with a small backup battery, external EEPROM, and an LED signal indicator. This LED will start blinking when it gets a position fix.<\/p>\n\n\n\n<p>Usually, these modules come with a GPS ceramic antenna.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ceramic-GPS-antenna.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ceramic GPS antenna\" class=\"wp-image-160851\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ceramic-GPS-antenna.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ceramic-GPS-antenna.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>But, you can change it to any other compatible antenna that might suit your project better. For example, I like to use the one at the right in the picture below because it is waterproof, and the antenna comes with a long cable which allows for more flexibility.<\/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=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/antennas-for-GPS-Modules.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"antennas for GPS modules\" class=\"wp-image-160852\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/antennas-for-GPS-Modules.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/antennas-for-GPS-Modules.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The NEO-6M GPS Module communicates with a microcontroller using serial communication protocol.<\/p>\n\n\n\n<p>This module works with standard NMEA sentences. 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\" id=\"neo-6m-gps-features\">NEO-6M GPS Module Features<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"263\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/08\/NEO-6M-GPS-Module.jpg?resize=263%2C263&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"NEO-6M GPS Module\" class=\"wp-image-134340\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/08\/NEO-6M-GPS-Module.jpg?w=263&amp;quality=100&amp;strip=all&amp;ssl=1 263w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/08\/NEO-6M-GPS-Module.jpg?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" sizes=\"(max-width: 263px) 100vw, 263px\" \/><\/figure><\/div>\n\n\n<p>In summary:<\/p>\n\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<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&nbsp;<a href=\"https:\/\/makeradvisor.com\/tools\/neo-6m-gps-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">NEO-6M GPS module page on Maker Advisor<\/a>&nbsp;to compare the prices in different stores and find the best one.<\/p>\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<h2 class=\"wp-block-heading\" id=\"neo-6m-gps-wiring-esp8266\">Wiring the NEO-6M GPS Module to the ESP8266 NodeMCU<\/h2>\n\n\n\n<p>To communicate with the NEO-6M GPS module, we&#8217;ll use software serial, so you can use any available GPIOs. We&#8217;ll use: GPIO 14 (D5), and GPIO 12 (D6).<\/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=\"855\" height=\"536\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-GPS-Circuit_fritzing.png?resize=855%2C536&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wiring the NEO-6M GPS Module to the ESP8266 NodeMCU\" class=\"wp-image-160878\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-GPS-Circuit_fritzing.png?w=855&amp;quality=100&amp;strip=all&amp;ssl=1 855w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-GPS-Circuit_fritzing.png?resize=300%2C188&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-GPS-Circuit_fritzing.png?resize=768%2C481&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 855px) 100vw, 855px\" \/><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>NEO-6M GPS Module<\/strong><\/td><td><strong>ESP8266<\/strong><\/td><\/tr><tr><td>VCC<\/td><td><span class=\"rnthl rntcred\">3V3<\/span><\/td><\/tr><tr><td>RX<\/td><td><span class=\"rnthl rntcgreen\">GPIO 12<\/span> (D6)<\/td><\/tr><tr><td>TX<\/td><td><span class=\"rnthl rntcyellow\">GPIO 14<\/span> (D5)<\/td><\/tr><tr><td>GND<\/td><td><span class=\"rnthl rntcblack\">GND<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the TinyGPSPlus Library<\/h2>\n\n\n\n<p>To decode the NMEA sentences received by the GPS module, we&#8217;ll use the <a href=\"http:\/\/arduiniana.org\/libraries\/tinygpsplus\/\" target=\"_blank\" rel=\"noopener\" title=\"\">TinyGPSPlus library<\/a>. Install it before proceeding.<\/p>\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<h2 class=\"wp-block-heading\" id=\"get-gps-data-neo-6m-esp8266\">ESP8266 with the NEO-6M GPS Module &#8211; Getting GPS Data<\/h2>\n\n\n\n<p>After wiring the GPS module to the ESP8266 and installing the TinyGPSPlus library, let&#8217;s run a simple example to get latitude, longitude, altitude, data, time, and more.<\/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=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-with-NEO-GPS-Module-Circuit.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NodeMCU with NEO-6M GPS Module\" class=\"wp-image-160884\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-with-NEO-GPS-Module-Circuit.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-with-NEO-GPS-Module-Circuit.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The following code shows how to get GPS data using the TinyGPSPlus library. We&#8217;ll get date, time, speed, altitude, number of visible satellites, and HDOP (a measurement of how accurate the signal is).<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete instructions at https:\/\/RandomNerdTutorials.com\/esp8266-nodemcu-neo-6m-gps-module-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*********\/\n\n#include &lt;SoftwareSerial.h&gt;\n#include &lt;TinyGPS++.h&gt;\n\n\/\/ Define the RX and TX pins for Software Serial 2\n#define RX 14\n#define TX 12\n\n#define GPS_BAUD 9600\n\n\/\/ The TinyGPS++ object\nTinyGPSPlus gps;\n\n\/\/ Create an instance of Software Serial\nSoftwareSerial gpsSerial(RX, TX);\n\nvoid setup() {\n  \/\/ Serial Monitor\n  Serial.begin(115200);\n  \n  \/\/ Start Serial 2 with the defined RX and TX pins and a baud rate of 9600\n  gpsSerial.begin(GPS_BAUD);\n  Serial.println(&quot;Software Serial started at 9600 baud rate&quot;);\n}\n\nvoid loop() {\n  \/\/ This sketch displays information every time a new sentence is correctly encoded.\n  unsigned long start = millis();\n\n  while (millis() - start &lt; 1000) {\n    while (gpsSerial.available() &gt; 0) {\n      gps.encode(gpsSerial.read());\n    }\n    if (gps.location.isUpdated()) {\n      Serial.print(&quot;LAT: &quot;);\n      Serial.println(gps.location.lat(), 6);\n      Serial.print(&quot;LONG: &quot;); \n      Serial.println(gps.location.lng(), 6);\n      Serial.print(&quot;SPEED (km\/h) = &quot;); \n      Serial.println(gps.speed.kmph()); \n      Serial.print(&quot;ALT (min)= &quot;); \n      Serial.println(gps.altitude.meters());\n      Serial.print(&quot;HDOP = &quot;); \n      Serial.println(gps.hdop.value() \/ 100.0); \n      Serial.print(&quot;Satellites = &quot;); \n      Serial.println(gps.satellites.value()); \n      Serial.print(&quot;Time in UTC: &quot;);\n      Serial.println(String(gps.date.year()) + &quot;\/&quot; + String(gps.date.month()) + &quot;\/&quot; + String(gps.date.day()) + &quot;,&quot; + String(gps.time.hour()) + &quot;:&quot; + String(gps.time.minute()) + &quot;:&quot; + String(gps.time.second()));\n      Serial.println(&quot;&quot;);\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\/ESP8266\/ESP8266_NEO_6M_GPS_TinyGPS.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Does the Code Work?<\/h3>\n\n\n\n<p>You start by importing the <span class=\"rnthl rntliteral\">TinyGPSPlus<\/span> and <span class=\"rnthl rntliteral\">SoftwareSerial<\/span> library.<\/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 GPIOs you want to use for Software Serial and the GPS module baud rate.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Define the RX and TX pins for Software Serial 2\n#define RX 14\n#define TX 12\n\n#define GPS_BAUD 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>Create <span class=\"rnthl rntliteral\">SoftwareSerial<\/span> instance on the pins you defined earlier.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SoftwareSerial gpsSerial(RX, TX);<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize the Serial Monitor and the serial communication with the GPS module.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void setup() {\n  \/\/ Serial Monitor\n  Serial.begin(115200);\n  \n  \/\/ Start Serial 2 with the defined RX and TX pins and a baud rate of 9600\n  gpsSerial.begin(GPS_BAUD);\n  Serial.println(\"Software Serial started at 9600 baud rate\");\n}<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span> is where you request the information. Parse the data from the GPS module into the <span class=\"rnthl rntliteral\">TinyGPS++<\/span> object using the <span class=\"rnthl rntliteral\">encode()<\/span> method as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>while (gpsSerial.available() &gt; 0) {\n  gps.encode(gpsSerial.read());\n}<\/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()) {<\/code><\/pre>\n\n\n\n<p>If there is new data, we can get it as follows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Latitude<\/td><td><span class=\"rnthl rntliteral\">gps.location.lat()<\/span><\/td><\/tr><tr><td>Longitude<\/td><td><span class=\"rnthl rntliteral\">gps.location.lng()<\/span><\/td><\/tr><tr><td>Speed (km\/h)<\/td><td><span class=\"rnthl rntliteral\">gps.speed.kmph()<\/span><\/td><\/tr><tr><td>Altitude (meters)<\/td><td><span class=\"rnthl rntliteral\">gps.altitude.meters()<\/span><\/td><\/tr><tr><td>HDOP<\/td><td><span class=\"rnthl rntliteral\">gps.hdop.value()<\/span><\/td><\/tr><tr><td>The number of visible satellites<\/td><td><span class=\"rnthl rntliteral\">gps.satellites.value()<\/span><\/td><\/tr><tr><td>Year<\/td><td><span class=\"rnthl rntliteral\">gps.date.year()<\/span><\/td><\/tr><tr><td>Month<\/td><td><span class=\"rnthl rntliteral\">gps.date.month()<\/span><\/td><\/tr><tr><td>Day<\/td><td><span class=\"rnthl rntliteral\">gps.date.day()<\/span><\/td><\/tr><tr><td>Hour<\/td><td><span class=\"rnthl rntliteral\">gps.time.hour()<\/span><\/td><\/tr><tr><td>Minutes<\/td><td><span class=\"rnthl rntliteral\">gps.time.minute()<\/span><\/td><\/tr><tr><td>Seconds<\/td><td><span class=\"rnthl rntliteral\">gps.time.second()<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>In the code, we get the data and print all the information in the Arduino IDE Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(\"LAT: \");\nSerial.println(gps.location.lat(), 6);\nSerial.print(\"LONG: \"); \nSerial.println(gps.location.lng(), 6);\nSerial.print(\"SPEED (km\/h) = \"); \nSerial.println(gps.speed.kmph()); \nSerial.print(\"ALT (min)= \"); \nSerial.println(gps.altitude.meters());\nSerial.print(\"HDOP = \"); \nSerial.println(gps.hdop.value() \/ 100.0); \nSerial.print(\"Satellites = \"); \nSerial.println(gps.satellites.value()); \nSerial.print(\"Time in UTC: \");\nSerial.println(String(gps.date.year()) + \"\/\" + String(gps.date.month()) + \"\/\" + String(gps.date.day()) + \",\" + String(gps.time.hour()) + \":\" + String(gps.time.minute()) + \":\" + String(gps.time.second()));\nSerial.println(\"\");<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Testing the Code<\/h3>\n\n\n\n<p>Upload the code to your board. <\/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=\"36\" height=\"39\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/05\/arduino-ide-2-upload-button.png?resize=36%2C39&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Upload Button\" class=\"wp-image-146269\"\/><\/figure><\/div>\n\n\n<p>Then, open the Serial Monitor at a baud rate of 115200.<\/p>\n\n\n\n<p>Make sure the antenna is connected and that the module or antenna is placed outside or next to a window so that it can get data from the satellites.<\/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=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/active-GPS-antenna-for-NEO-6M.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"active GPS antenna for NEO-6M\" class=\"wp-image-160850\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/active-GPS-antenna-for-NEO-6M.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/active-GPS-antenna-for-NEO-6M.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The module&#8217;s blue LED will start blinking when it finds a position fix.<\/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=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Neo-6M-GPS-Module-Blue-LED-Blinking.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"NEO-6M GPS Module Blue LED Blinking\" class=\"wp-image-160849\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Neo-6M-GPS-Module-Blue-LED-Blinking.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Neo-6M-GPS-Module-Blue-LED-Blinking.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Open the Serial Monitor at a baud rate of 115200. Make sure your GPS module is placed outside or next to a window to get data from satellites.<\/p>\n\n\n\n<p>You&#8217;ll get GPS data on the Serial Monitor about your current location, speed, altitude, number of visible satellites HDOP, and time.<\/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=\"830\" height=\"379\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP32-Get-GPS-Data-NEO-6M-Demonstration.png?resize=830%2C379&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Get GPS data with ESP32 - NEO-6M module\" class=\"wp-image-160853\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP32-Get-GPS-Data-NEO-6M-Demonstration.png?w=830&amp;quality=100&amp;strip=all&amp;ssl=1 830w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP32-Get-GPS-Data-NEO-6M-Demonstration.png?resize=300%2C137&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP32-Get-GPS-Data-NEO-6M-Demonstration.png?resize=768%2C351&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/figure><\/div>\n\n\n<p>HDOP stands for Horizontal Dilution of Precision. This is a measurement of position-fixing accuracy. The higher the HDOP value is, the less accurate the position fix will be. Ideally, you should get a value lower than 2. A lower value means a better accuracy.<\/p>\n\n\n\n<p>Now, you can take this project further and display the data on an OLED display, for example. To learn how to use an OLED display with the ESP8266 board, you can follow the next tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-0-96-inch-oled-display-with-arduino-ide\/\">ESP8266 0.96 inch OLED Display with Arduino IDE<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned how to use the NEO-6M GPS Module with the ESP8266 to get GPS data: latitude, longitude, altitude, speed, date, time, number of satellites, and more.<\/p>\n\n\n\n<p>The accuracy of the data will depend on where the module is placed and the antenna used. For better performance, the sensor should be placed outside or next to a window and away from narrow streets with tall buildings. The higher the number of visible satellites, the more accurate the position will be.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. We have guides for more than 20 modules and sensors with the ESP8266, you can check them below:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-guides-sensors-modules\/\">ESP8266 NodeMCU: 21 Free Guides for Sensors and Modules<\/a><\/li>\n<\/ul>\n\n\n\n<p>If you want to learn more about the ESP8266, check out our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\" title=\"\">Free ESP8266 Projects and Tutorials<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\" title=\"\">Home Automation Using ESP8266<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to interface the NEO-6M GPS module with an ESP8266 NodeMCU board to get GPS data. You&#8217;ll learn how to get latitude, longitude, altitude, speed, and UTC time. The &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP8266 NodeMCU with NEO-6M GPS Module (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-neo-6m-gps-module-arduino\/#more-160875\" aria-label=\"Read more about ESP8266 NodeMCU with NEO-6M GPS Module (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":160880,"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":[214,265,246,240,300,264],"tags":[],"class_list":["post-160875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266","category-esp8266-project","category-esp8266-arduino-ide","category-esp8266-projects","category-0-esp8266","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/ESP8266-NEO-6M-GPS-Module-Arduino-IDE.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/160875","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=160875"}],"version-history":[{"count":11,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/160875\/revisions"}],"predecessor-version":[{"id":168258,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/160875\/revisions\/168258"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/160880"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=160875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=160875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=160875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}