{"id":167032,"date":"2025-04-09T14:27:39","date_gmt":"2025-04-09T14:27:39","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=167032"},"modified":"2025-04-09T14:27:41","modified_gmt":"2025-04-09T14:27:41","slug":"esp8266-nodemcu-neo-m8n-gps-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-neo-m8n-gps-arduino\/","title":{"rendered":"ESP8266 NodeMCU with NEO-M8N GPS Module (Arduino IDE)"},"content":{"rendered":"\n<p>Learn to interface the NEO-M8N GPS Module with the ESP8266 NodeMCU board programmed with Arduino IDE to get GPS data: latitude, longitude, altitude, UTC time, number of visible satellites, and more.<\/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\/2025\/01\/ESP8266-M8N-GPS-Module.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NodeMCU with NEO-M8N GPS Module Arduino IDE\" class=\"wp-image-167049\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-M8N-GPS-Module.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-M8N-GPS-Module.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-M8N-GPS-Module.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-M8N-GPS-Module.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-M8N-GPS-Module.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\u2019ll learn how to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wire the NEO-M8N 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<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<p>We&#8217;ll cover the following subjects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#intro-neom8n\" title=\"\">Introducing the NEO-M8N GPS Module<\/a><\/li>\n\n\n\n<li><a href=\"#esp8266-m8n-wiring\" title=\"\">Wiring the NEO-M8N GPS Module to the ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"#get-gps-data\" title=\"\">ESP8266 with the NEO-M8N GPS Module \u2013 Getting GPS Data<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"intro-neom8n\">Introducing the NEO-M8N GPS Module<\/h2>\n\n\n\n<p>The NEO-M8N GPS module is one of the most popular GPS receivers used with microcontrollers in navigation and tracking projects. It can get data about latitude, longitude, altitude, and time.<\/p>\n\n\n\n<p>It supports multiple satellite systems, including GPS, Galileo, GLONASS, and BeiDou. It offers better satellite tracking than the <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-neo-6m-gps-module-arduino\/\" title=\"\">NEO-6M<\/a>, making it more reliable in challenging conditions.<\/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\/2025\/01\/M8N-GPS-Module.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"NEO-M8N-GPS-Module\" class=\"wp-image-166757\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/M8N-GPS-Module.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/M8N-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>According to the datasheet, it has a horizontal position accuracy of 2.5 to 4 meters and quick startup times (1 second for hot start, 26\u201357 seconds for cold start\u2014expect longer times if you&#8217;re close to buildings).<\/p>\n\n\n\n<p>The module includes a backup battery, built-in EEPROM, and an LED indicator that blinks when a position fix is achieved.<\/p>\n\n\n\n<p>This module typically comes with a ceramic GPS antenna. 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\" 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-M8N GPS Module communicates with a microcontroller using Serial communication protocol, and 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\">Where to buy?<\/h3>\n\n\n\n<p>You can check our Maker Advisor Tools page to compare the NEO-M8N GPS receiver module price in different stores:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/neo-m8n-gps-module\/\" target=\"_blank\" rel=\"noopener\" title=\"\">NEO-M8N GPS Receiver Module<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266 Board<\/a>\u00a0\u2013 read\u00a0<a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP8266 development boards<\/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<h2 class=\"wp-block-heading\" id=\"esp8266-m8n-wiring\">Wiring the NEO-M8N GPS Module to the ESP8266 NodeMCU<\/h2>\n\n\n\n<p>To communicate with the NEO-6M GPS module, we\u2019ll use software serial, so you can use any available GPIOs. We\u2019ll 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\/2025\/01\/ESP8266-NEO-M8N-GPS-Circuit_fritzing.png?resize=855%2C536&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wiring the NEO-M8N GPS Module to the ESP8266 NodeMCU circuit diagram\" class=\"wp-image-167047\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-NEO-M8N-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\/2025\/01\/ESP8266-NEO-M8N-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\/2025\/01\/ESP8266-NEO-M8N-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 class=\"rntbox rntclgreen\">Recommended reading: <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-pinout-reference-gpios\/\" title=\"\">ESP8266 Pinout Reference: Which GPIO pins should you use?<\/a><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>NEO-6M GPS Module<\/strong><\/td><td><strong>ESP8266 NodeMCU<\/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\" id=\"test-neo-m8n-esp32-raw-data\">Installing the TinyGPSPlus Library<\/h2>\n\n\n\n<p>We\u2019ll program the ESP8266 NodeMCU using Arduino IDE. Make sure you have the ESP8266 boards installed by following this guide:\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/installing-esp8266-nodemcu-arduino-ide-2-0\/\">Installing ESP8266 Board in Arduino IDE 2 (Windows, Mac OS X, Linux)<\/a>.<\/p>\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>&gt; I<strong>nclude Library<\/strong> &gt; <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\">ESP8266 NodeMCU with the NEO-M8N GPS Module &#8211; Getting GPS Data<\/h2>\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\/2025\/01\/ESP8266-NEO-M8N-GPS-Module-Tutorial.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 with the NEO-M8N GPS Module - Getting GPS Data\" class=\"wp-image-167052\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-NEO-M8N-GPS-Module-Tutorial.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-NEO-M8N-GPS-Module-Tutorial.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 <span class=\"rnthl rntliteral\">TinyGPSPlus<\/span> library. We&#8217;ll get date, time, speed, altitude, number of visible satellites, and HDOP (a measurement of how precise 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-m8n-gps-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\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_M8N_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 ESP8266 board. 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 class=\"rntbox rntcred\">Note: you may need to wait a few seconds or minutes until the module can get 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=\"738\" height=\"377\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-Get-GPS-Data-M8N-TinyGPS.png?resize=738%2C377&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 Get GPS Data from NEO M8N\" class=\"wp-image-167039\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-Get-GPS-Data-M8N-TinyGPS.png?w=738&amp;quality=100&amp;strip=all&amp;ssl=1 738w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-Get-GPS-Data-M8N-TinyGPS.png?resize=300%2C153&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/figure><\/div>\n\n\n<p>You&#8217;ll get data on the Serial Monitor about your current location, speed, altitude, number of visible satellites HDOP, and time.<\/p>\n\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<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this guide, you learned how to use the NEO-M8N GPS module with the ESP8266 and how to get information about location, time, altitude, speed, number of satellites, and more.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this guide useful. We have guides for other modules you may find useful:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-ds1307-real-time-clock-rtc-arduino\/\">ESP8266 NodeMCU: Guide for DS1307 Real Time Clock (RTC) Module (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-0-96-inch-oled-display-with-arduino-ide\/\">ESP8266 0.96 inch <strong>OLED Display<\/strong> with Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-neo-6m-gps-module-arduino\/\" title=\"\">ESP8266 NodeMCU with <strong>NEO-6M GPS Module<\/strong> (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-guides-sensors-modules\/\">ESP8266 NodeMCU: 20+ Free Guides for Sensors and Modules<\/a><\/li>\n<\/ul>\n\n\n\n<p>If you&#8217;d like to learn more about the ESP8266, make sure to check out our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\" title=\"\">Home Automation Using ESP8266 (4th Edition)<\/a><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\" title=\"\">All our ESP8266 Projects and Guides<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn to interface the NEO-M8N GPS Module with the ESP8266 NodeMCU board programmed with Arduino IDE to get GPS data: latitude, longitude, altitude, UTC time, number of visible satellites, and &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP8266 NodeMCU with NEO-M8N GPS Module (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-neo-m8n-gps-arduino\/#more-167032\" aria-label=\"Read more about ESP8266 NodeMCU with NEO-M8N GPS Module (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":167049,"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":[265,214,246,300,240,264],"tags":[],"class_list":["post-167032","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266-project","category-esp8266","category-esp8266-arduino-ide","category-0-esp8266","category-esp8266-projects","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP8266-M8N-GPS-Module.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\/167032","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=167032"}],"version-history":[{"count":7,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/167032\/revisions"}],"predecessor-version":[{"id":168763,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/167032\/revisions\/168763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/167049"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=167032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=167032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=167032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}