{"id":160957,"date":"2024-09-12T13:06:51","date_gmt":"2024-09-12T13:06:51","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=160957"},"modified":"2025-01-20T15:09:32","modified_gmt":"2025-01-20T15:09:32","slug":"raspberry-pi-pico-neo-6m-micropython","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-neo-6m-micropython\/","title":{"rendered":"Raspberry Pi Pico: NEO-6M GPS Module &#8211; Get Location and Time (MicroPython)"},"content":{"rendered":"\n<p>Learn how to interface the NEO-6M GPS module with the Raspberry Pi Pico to get GPS data: latitude, longitude, altitude, date, and time. We&#8217;ll show you how to connect the module to the Pico and establish a serial communication to get sensor data. We&#8217;ll program the Raspberry Pi Pico board using MicroPython firmware.<\/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\/Raspberry-Pi-Pico-NEO-6M-GPS-Module.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico with NEO-6M GPS Module: Get Location and Time\" class=\"wp-image-160962\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-GPS-Module.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-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\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-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\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-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\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-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 class=\"rntbox rntclgreen\"><strong>New to the Raspberry Pi Pico?<\/strong> Check out our eBook: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-micropython-ebook\/\" title=\"\">Learn Raspberry Pi Pico with MicroPython<\/a>.<\/p>\n\n\n\n<p><strong>Table of Contents<\/strong><\/p>\n\n\n\n<p>Throughout this guide, we&#8217;ll cover the following topics:<\/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-rpi-pico\" title=\"\">Wiring the NEO-6M GPS Module to the Raspberry Pi Pico<\/a><\/li>\n\n\n\n<li><a href=\"#test-neo-6m-rpi-pico-raw-data\" title=\"\">Getting Raw GPS Data &#8211; Testing the NEO-6M GPS Module with the Raspberry Pi Pico (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"#micropygps-module\" title=\"\">Uploading the micropyGPS Module<\/a><\/li>\n\n\n\n<li><a href=\"#rpi-pico-neo-6m-gps-data-micropygps\" title=\"\">Raspberry Pi Pico with NEO-6M: Getting GPS Data with MicroPython<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites \u2013 MicroPython Firmware<\/h2>\n\n\n\n<p>To follow this tutorial you need MicroPython firmware installed in your Raspberry Pi Pico board. You also need an IDE to write and upload the code to your board.<\/p>\n\n\n\n<p>The recommended MicroPython IDE for the Raspberry Pi Pico is Thonny IDE. Follow the next tutorial to learn how to install Thonny IDE, flash MicroPython firmware, and upload code to the board.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-raspberry-pi-pico-w\/#install-thonny-ide\">Programming Raspberry Pi Pico using MicroPython<\/a><\/li>\n<\/ul>\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-rpi-pico\">Wiring the NEO-6M GPS Module to the Raspberry Pi Pico<\/h2>\n\n\n\n<p>To get data from the NEO-6M GPS module, we need to establish a serial communication. The Raspberry Pi Pico has the following options for UART pins:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>UART Interface<\/strong><\/td><td><strong>TX GPIOs<\/strong><\/td><td><strong>RX GPIOs<\/strong><\/td><\/tr><tr><td><strong>UART0<\/strong><\/td><td>GPIO0, GPIO12, GPIO16<\/td><td>GPIO1, GPIO13, GPIO17<\/td><\/tr><tr><td><strong>UART1<\/strong><\/td><td>GPIO4, GPIO8<\/td><td>GPIO5, GPIO9<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>We&#8217;ll use <strong>UART 1 and GPIO 4 (TX) and GPIO 5 (RX)<\/strong>.<\/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=\"990\" height=\"628\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-GPS_bb.png?resize=990%2C628&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wiring NEO-6M GPS Module to the Raspberry Pi Pico\" class=\"wp-image-160960\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-GPS_bb.png?w=990&amp;quality=100&amp;strip=all&amp;ssl=1 990w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-GPS_bb.png?resize=300%2C190&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-GPS_bb.png?resize=768%2C487&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 990px) 100vw, 990px\" \/><\/figure><\/div>\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>NEO-6M GPS Module<\/strong><\/td><td><strong>Raspberry Pi Pico<\/strong><\/td><\/tr><tr><td>VCC<\/td><td><span class=\"rnthl rntcred\">3V3<\/span><\/td><\/tr><tr><td>RX<\/td><td>TX (<span class=\"rnthl rntcyellow\">GPIO 4<\/span>) (Pin 6)<\/td><\/tr><tr><td>TX<\/td><td>RX (<span class=\"rnthl rntcgreen\">GPIO 5<\/span>) (Pin 7)<\/td><\/tr><tr><td>GND<\/td><td><span class=\"rnthl rntcblack\">GND<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Related article:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-pinout-gpios\/\">Raspberry Pi Pico and Pico W Pinout Guide: GPIOs Explained<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"test-neo-6m-rpi-pico-raw-data\">Getting Raw GPS Data &#8211; Testing the NEO-6M GPS Module with the Raspberry Pi Pico (MicroPython)<\/h2>\n\n\n\n<p>To get raw GPS data you just need to start a serial communication with the GPS module and read the available data.<\/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\/Raspberry-Pi-Pico-with-NEO-6M-GPS-Module.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico with NEO-6M GPS Module\" class=\"wp-image-160969\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-with-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\/Raspberry-Pi-Pico-with-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>The following code establishes a serial communication with the GPS module and reads the available data.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n# Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-neo-6m-micropython\/\n\nimport machine\nfrom time import sleep\n\n# Define the UART pins and create a UART object\ngps_serial = machine.UART(1, baudrate=9600, tx=4, rx=5)\n\nwhile True:\n    if gps_serial.any():\n        line = gps_serial.readline()  # Read a complete line from the UART\n        if line:\n            line = line.decode('utf-8')\n            print(line.strip())\n    sleep(0.5)\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/MicroPython\/NEO_6M_GPS_Raw_Data.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Testing the Code<\/h3>\n\n\n\n<p>After establishing a connection with the board using Thonny IDE, run the previous code.<\/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\u2014this might take a few minutes on the first run.<\/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-LED-Blinking-Position-Fix.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"NEO-6M GPS Module Blue LED Blinking\" class=\"wp-image-160972\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/NEO-6M-GPS-Module-LED-Blinking-Position-Fix.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-LED-Blinking-Position-Fix.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 shell will display NMEA sentences with GPS data.<\/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=\"775\" height=\"451\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-Raw-GPS-Data.png?resize=775%2C451&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico with NEO-6M GPS Read Raw Data (Micropython)\" class=\"wp-image-160966\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-Raw-GPS-Data.png?w=775&amp;quality=100&amp;strip=all&amp;ssl=1 775w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-Raw-GPS-Data.png?resize=300%2C175&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-Raw-GPS-Data.png?resize=768%2C447&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 775px) 100vw, 775px\" \/><\/figure><\/div>\n\n\n<p>Each line you get in 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\" id=\"NMEA-sentences\">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>$GPRMC<\/strong>,110827.00,A,4107.32485,N,00831.79799,W,0.888,30.44,180724,,,A*4B<br><strong>$GPVTG<\/strong>,30.44,T,,M,0.888,N,1.644,K,A*01<br><strong>$GPGGA<\/strong>,110827.00,41XX.32485,N,00831.79799,W,1,07,0.99,123.1,M,50.1,M,,*48<br><strong>$GPGSA<\/strong>,A,3,03,32,22,08,04,14,17,,,,,,2.25,0.99,2.02*0A<br><strong>$GPGSV<\/strong>,3,1,11,3,11,22,26,296,29,27,01,142,,32,17,042,23*48<br><strong>$GPGLL<\/strong>,4107.32485,N,00831.79799,W,110827.00,A,A*7F<\/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 <strong>GP <\/strong>after the <strong>$<\/strong> indicates it is a GPS position.&nbsp;The <strong>$GPGGA<\/strong> is the basic GPS NMEA message, that provides 3D location and accuracy data. <\/p>\n\n\n\n<p>In the following sentence:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>$GPGGA<\/strong>,110827.00,41XX.32485,N,008XX.XXXXX,W,1,07,0.99,123.1,M,50.1,M,,*48<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>110827<\/strong>&nbsp;\u2013 represents the time at which the fix location was taken, 11:08:27 UTC<\/li>\n\n\n\n<li><strong>41XX.32845,N<\/strong>&nbsp;\u2013 latitude 41 deg XX.32845,N<\/li>\n\n\n\n<li><strong>00831.79799,W<\/strong>&nbsp;\u2013 Longitude 008 deg XX.XXXXX\u2032 W<\/li>\n\n\n\n<li><strong>1<\/strong>&nbsp;\u2013 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>07<\/strong>&nbsp;\u2013 number of satellites being tracked<\/li>\n\n\n\n<li><strong>0.99<\/strong>&nbsp;\u2013 Horizontal dilution of position (less than one is ideal)<\/li>\n\n\n\n<li><strong>123.1, M<\/strong>&nbsp;\u2013 Altitude, in meters above the sea level<\/li>\n\n\n\n<li><strong>50.1, M<\/strong>&nbsp;\u2013&nbsp;Height of geoid (mean sea level) above WGS84 ellipsoid<\/li>\n\n\n\n<li>empty field \u2013&nbsp;time in seconds since last DGPS update<\/li>\n\n\n\n<li>empty field \u2013&nbsp;DGPS station ID number<\/li>\n\n\n\n<li><strong>*4<\/strong>8&nbsp;\u2013 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>&nbsp;\u2013&nbsp;GPS DOP and active satellites<\/li>\n\n\n\n<li><strong>$GPGSV<\/strong>&nbsp;\u2013&nbsp;Detailed GPS satellite information<\/li>\n\n\n\n<li><strong>$GPGLL<\/strong>&nbsp;\u2013&nbsp;Geographic Latitude and Longitude<\/li>\n\n\n\n<li><strong>$GPRMC<\/strong>&nbsp;\u2013&nbsp;Essential GPS pvt (position, velocity, time) data<\/li>\n\n\n\n<li><strong>$GPVTG<\/strong>&nbsp;\u2013&nbsp;Velocity made good<\/li>\n<\/ul>\n\n\n\n<p>You can use this <a href=\"https:\/\/swairlearn.bluecover.pt\/nmea_analyser\" target=\"_blank\" rel=\"noopener\" title=\"\">Online NME Analyser <\/a>and paste your sentences there to interpret the GPS data.<\/p>\n\n\n\n<p>However, the easiest way to get and interpret the GPS data you want is to parse your NMEA sentences directly in the code. For that, we&#8217;ll use the <a href=\"https:\/\/github.com\/inmcm\/micropyGPS\/tree\/master\" target=\"_blank\" rel=\"noopener\" title=\"\">micropyGPS module<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"micropygps-module\">Uploading the micropyGPS Module<\/h2>\n\n\n\n<p>To parse the NMEA sentences from the GPS module and get GPS data easily, we&#8217;ll use the <a href=\"https:\/\/github.com\/inmcm\/micropyGPS\/tree\/master\" target=\"_blank\" rel=\"noopener\" title=\"\">micropyGPS module<\/a>. This library isn\u2019t part of the standard MicroPython library by default. So, you need to upload the following file to your Raspberry Pi Pico board (save it with the name micropyGPS.py).<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\">&quot;&quot;&quot;\n# MicropyGPS - a GPS NMEA sentence parser for Micropython\/Python 3.X\n# Copyright (c) 2017 Michael Calvin McCoy (calvin.mccoy@protonmail.com)\n# The MIT License (MIT) - see LICENSE file\n&quot;&quot;&quot;\n\n# TODO:\n# Time Since First Fix\n# Distance\/Time to Target\n# More Helper Functions\n# Dynamically limit sentences types to parse\n\nfrom math import floor, modf\n\n# Import utime or time for fix time handling\ntry:\n    # Assume running on MicroPython\n    import utime\nexcept ImportError:\n    # Otherwise default to time module for non-embedded implementations\n    # Should still support millisecond resolution.\n    import time\n\n\nclass MicropyGPS(object):\n    &quot;&quot;&quot;GPS NMEA Sentence Parser. Creates object that stores all relevant GPS data and statistics.\n    Parses sentences one character at a time using update(). &quot;&quot;&quot;\n\n    # Max Number of Characters a valid sentence can be (based on GGA sentence)\n    SENTENCE_LIMIT = 90\n    __HEMISPHERES = ('N', 'S', 'E', 'W')\n    __NO_FIX = 1\n    __FIX_2D = 2\n    __FIX_3D = 3\n    __DIRECTIONS = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W',\n                    'WNW', 'NW', 'NNW')\n    __MONTHS = ('January', 'February', 'March', 'April', 'May',\n                'June', 'July', 'August', 'September', 'October',\n                'November', 'December')\n\n    def __init__(self, local_offset=0, location_formatting='ddm'):\n        &quot;&quot;&quot;\n        Setup GPS Object Status Flags, Internal Data Registers, etc\n            local_offset (int): Timzone Difference to UTC\n            location_formatting (str): Style For Presenting Longitude\/Latitude:\n                                       Decimal Degree Minute (ddm) - 40\u00b0 26.767\u2032 N\n                                       Degrees Minutes Seconds (dms) - 40\u00b0 26\u2032 46\u2033 N\n                                       Decimal Degrees (dd) - 40.446\u00b0 N\n        &quot;&quot;&quot;\n\n        #####################\n        # Object Status Flags\n        self.sentence_active = False\n        self.active_segment = 0\n        self.process_crc = False\n        self.gps_segments = []\n        self.crc_xor = 0\n        self.char_count = 0\n        self.fix_time = 0\n\n        #####################\n        # Sentence Statistics\n        self.crc_fails = 0\n        self.clean_sentences = 0\n        self.parsed_sentences = 0\n\n        #####################\n        # Logging Related\n        self.log_handle = None\n        self.log_en = False\n\n        #####################\n        # Data From Sentences\n        # Time\n        self.timestamp = [0, 0, 0.0]\n        self.date = [0, 0, 0]\n        self.local_offset = local_offset\n\n        # Position\/Motion\n        self._latitude = [0, 0.0, 'N']\n        self._longitude = [0, 0.0, 'W']\n        self.coord_format = location_formatting\n        self.speed = [0.0, 0.0, 0.0]\n        self.course = 0.0\n        self.altitude = 0.0\n        self.geoid_height = 0.0\n\n        # GPS Info\n        self.satellites_in_view = 0\n        self.satellites_in_use = 0\n        self.satellites_used = []\n        self.last_sv_sentence = 0\n        self.total_sv_sentences = 0\n        self.satellite_data = dict()\n        self.hdop = 0.0\n        self.pdop = 0.0\n        self.vdop = 0.0\n        self.valid = False\n        self.fix_stat = 0\n        self.fix_type = 1\n\n    ########################################\n    # Coordinates Translation Functions\n    ########################################\n    @property\n    def latitude(self):\n        &quot;&quot;&quot;Format Latitude Data Correctly&quot;&quot;&quot;\n        if self.coord_format == 'dd':\n            decimal_degrees = self._latitude[0] + (self._latitude[1] \/ 60)\n            return [decimal_degrees, self._latitude[2]]\n        elif self.coord_format == 'dms':\n            minute_parts = modf(self._latitude[1])\n            seconds = round(minute_parts[0] * 60)\n            return [self._latitude[0], int(minute_parts[1]), seconds, self._latitude[2]]\n        else:\n            return self._latitude\n\n    @property\n    def longitude(self):\n        &quot;&quot;&quot;Format Longitude Data Correctly&quot;&quot;&quot;\n        if self.coord_format == 'dd':\n            decimal_degrees = self._longitude[0] + (self._longitude[1] \/ 60)\n            return [decimal_degrees, self._longitude[2]]\n        elif self.coord_format == 'dms':\n            minute_parts = modf(self._longitude[1])\n            seconds = round(minute_parts[0] * 60)\n            return [self._longitude[0], int(minute_parts[1]), seconds, self._longitude[2]]\n        else:\n            return self._longitude\n\n    ########################################\n    # Logging Related Functions\n    ########################################\n    def start_logging(self, target_file, mode=&quot;append&quot;):\n        &quot;&quot;&quot;\n        Create GPS data log object\n        &quot;&quot;&quot;\n        # Set Write Mode Overwrite or Append\n        mode_code = 'w' if mode == 'new' else 'a'\n\n        try:\n            self.log_handle = open(target_file, mode_code)\n        except AttributeError:\n            print(&quot;Invalid FileName&quot;)\n            return False\n\n        self.log_en = True\n        return True\n\n    def stop_logging(self):\n        &quot;&quot;&quot;\n        Closes the log file handler and disables further logging\n        &quot;&quot;&quot;\n        try:\n            self.log_handle.close()\n        except AttributeError:\n            print(&quot;Invalid Handle&quot;)\n            return False\n\n        self.log_en = False\n        return True\n\n    def write_log(self, log_string):\n        &quot;&quot;&quot;Attempts to write the last valid NMEA sentence character to the active file handler\n        &quot;&quot;&quot;\n        try:\n            self.log_handle.write(log_string)\n        except TypeError:\n            return False\n        return True\n\n    ########################################\n    # Sentence Parsers\n    ########################################\n    def gprmc(self):\n        &quot;&quot;&quot;Parse Recommended Minimum Specific GPS\/Transit data (RMC)Sentence.\n        Updates UTC timestamp, latitude, longitude, Course, Speed, Date, and fix status\n        &quot;&quot;&quot;\n\n        # UTC Timestamp\n        try:\n            utc_string = self.gps_segments[1]\n\n            if utc_string:  # Possible timestamp found\n                hours = (int(utc_string[0:2]) + self.local_offset) % 24\n                minutes = int(utc_string[2:4])\n                seconds = float(utc_string[4:])\n                self.timestamp = [hours, minutes, seconds]\n            else:  # No Time stamp yet\n                self.timestamp = [0, 0, 0.0]\n\n        except ValueError:  # Bad Timestamp value present\n            return False\n\n        # Date stamp\n        try:\n            date_string = self.gps_segments[9]\n\n            # Date string printer function assumes to be year &gt;=2000,\n            # date_string() must be supplied with the correct century argument to display correctly\n            if date_string:  # Possible date stamp found\n                day = int(date_string[0:2])\n                month = int(date_string[2:4])\n                year = int(date_string[4:6])\n                self.date = (day, month, year)\n            else:  # No Date stamp yet\n                self.date = (0, 0, 0)\n\n        except ValueError:  # Bad Date stamp value present\n            return False\n\n        # Check Receiver Data Valid Flag\n        if self.gps_segments[2] == 'A':  # Data from Receiver is Valid\/Has Fix\n\n            # Longitude \/ Latitude\n            try:\n                # Latitude\n                l_string = self.gps_segments[3]\n                lat_degs = int(l_string[0:2])\n                lat_mins = float(l_string[2:])\n                lat_hemi = self.gps_segments[4]\n\n                # Longitude\n                l_string = self.gps_segments[5]\n                lon_degs = int(l_string[0:3])\n                lon_mins = float(l_string[3:])\n                lon_hemi = self.gps_segments[6]\n            except ValueError:\n                return False\n\n            if lat_hemi not in self.__HEMISPHERES:\n                return False\n\n            if lon_hemi not in self.__HEMISPHERES:\n                return False\n\n            # Speed\n            try:\n                spd_knt = float(self.gps_segments[7])\n            except ValueError:\n                return False\n\n            # Course\n            try:\n                if self.gps_segments[8]:\n                    course = float(self.gps_segments[8])\n                else:\n                    course = 0.0\n            except ValueError:\n                return False\n\n            # TODO - Add Magnetic Variation\n\n            # Update Object Data\n            self._latitude = [lat_degs, lat_mins, lat_hemi]\n            self._longitude = [lon_degs, lon_mins, lon_hemi]\n            # Include mph and hm\/h\n            self.speed = [spd_knt, spd_knt * 1.151, spd_knt * 1.852]\n            self.course = course\n            self.valid = True\n\n            # Update Last Fix Time\n            self.new_fix_time()\n\n        else:  # Clear Position Data if Sentence is 'Invalid'\n            self._latitude = [0, 0.0, 'N']\n            self._longitude = [0, 0.0, 'W']\n            self.speed = [0.0, 0.0, 0.0]\n            self.course = 0.0\n            self.valid = False\n\n        return True\n\n    def gpgll(self):\n        &quot;&quot;&quot;Parse Geographic Latitude and Longitude (GLL)Sentence. Updates UTC timestamp, latitude,\n        longitude, and fix status&quot;&quot;&quot;\n\n        # UTC Timestamp\n        try:\n            utc_string = self.gps_segments[5]\n\n            if utc_string:  # Possible timestamp found\n                hours = (int(utc_string[0:2]) + self.local_offset) % 24\n                minutes = int(utc_string[2:4])\n                seconds = float(utc_string[4:])\n                self.timestamp = [hours, minutes, seconds]\n            else:  # No Time stamp yet\n                self.timestamp = [0, 0, 0.0]\n\n        except ValueError:  # Bad Timestamp value present\n            return False\n\n        # Check Receiver Data Valid Flag\n        if self.gps_segments[6] == 'A':  # Data from Receiver is Valid\/Has Fix\n\n            # Longitude \/ Latitude\n            try:\n                # Latitude\n                l_string = self.gps_segments[1]\n                lat_degs = int(l_string[0:2])\n                lat_mins = float(l_string[2:])\n                lat_hemi = self.gps_segments[2]\n\n                # Longitude\n                l_string = self.gps_segments[3]\n                lon_degs = int(l_string[0:3])\n                lon_mins = float(l_string[3:])\n                lon_hemi = self.gps_segments[4]\n            except ValueError:\n                return False\n\n            if lat_hemi not in self.__HEMISPHERES:\n                return False\n\n            if lon_hemi not in self.__HEMISPHERES:\n                return False\n\n            # Update Object Data\n            self._latitude = [lat_degs, lat_mins, lat_hemi]\n            self._longitude = [lon_degs, lon_mins, lon_hemi]\n            self.valid = True\n\n            # Update Last Fix Time\n            self.new_fix_time()\n\n        else:  # Clear Position Data if Sentence is 'Invalid'\n            self._latitude = [0, 0.0, 'N']\n            self._longitude = [0, 0.0, 'W']\n            self.valid = False\n\n        return True\n\n    def gpvtg(self):\n        &quot;&quot;&quot;Parse Track Made Good and Ground Speed (VTG) Sentence. Updates speed and course&quot;&quot;&quot;\n        try:\n            course = float(self.gps_segments[1]) if self.gps_segments[1] else 0.0\n            spd_knt = float(self.gps_segments[5]) if self.gps_segments[5] else 0.0\n        except ValueError:\n            return False\n\n        # Include mph and km\/h\n        self.speed = (spd_knt, spd_knt * 1.151, spd_knt * 1.852)\n        self.course = course\n        return True\n\n    def gpgga(self):\n        &quot;&quot;&quot;Parse Global Positioning System Fix Data (GGA) Sentence. Updates UTC timestamp, latitude, longitude,\n        fix status, satellites in use, Horizontal Dilution of Precision (HDOP), altitude, geoid height and fix status&quot;&quot;&quot;\n\n        try:\n            # UTC Timestamp\n            utc_string = self.gps_segments[1]\n\n            # Skip timestamp if receiver doesn't have on yet\n            if utc_string:\n                hours = (int(utc_string[0:2]) + self.local_offset) % 24\n                minutes = int(utc_string[2:4])\n                seconds = float(utc_string[4:])\n            else:\n                hours = 0\n                minutes = 0\n                seconds = 0.0\n\n            # Number of Satellites in Use\n            satellites_in_use = int(self.gps_segments[7])\n\n            # Get Fix Status\n            fix_stat = int(self.gps_segments[6])\n\n        except (ValueError, IndexError):\n            return False\n\n        try:\n            # Horizontal Dilution of Precision\n            hdop = float(self.gps_segments[8])\n        except (ValueError, IndexError):\n            hdop = 0.0\n\n        # Process Location and Speed Data if Fix is GOOD\n        if fix_stat:\n\n            # Longitude \/ Latitude\n            try:\n                # Latitude\n                l_string = self.gps_segments[2]\n                lat_degs = int(l_string[0:2])\n                lat_mins = float(l_string[2:])\n                lat_hemi = self.gps_segments[3]\n\n                # Longitude\n                l_string = self.gps_segments[4]\n                lon_degs = int(l_string[0:3])\n                lon_mins = float(l_string[3:])\n                lon_hemi = self.gps_segments[5]\n            except ValueError:\n                return False\n\n            if lat_hemi not in self.__HEMISPHERES:\n                return False\n\n            if lon_hemi not in self.__HEMISPHERES:\n                return False\n\n            # Altitude \/ Height Above Geoid\n            try:\n                altitude = float(self.gps_segments[9])\n                geoid_height = float(self.gps_segments[11])\n            except ValueError:\n                altitude = 0\n                geoid_height = 0\n\n            # Update Object Data\n            self._latitude = [lat_degs, lat_mins, lat_hemi]\n            self._longitude = [lon_degs, lon_mins, lon_hemi]\n            self.altitude = altitude\n            self.geoid_height = geoid_height\n\n        # Update Object Data\n        self.timestamp = [hours, minutes, seconds]\n        self.satellites_in_use = satellites_in_use\n        self.hdop = hdop\n        self.fix_stat = fix_stat\n\n        # If Fix is GOOD, update fix timestamp\n        if fix_stat:\n            self.new_fix_time()\n\n        return True\n\n    def gpgsa(self):\n        &quot;&quot;&quot;Parse GNSS DOP and Active Satellites (GSA) sentence. Updates GPS fix type, list of satellites used in\n        fix calculation, Position Dilution of Precision (PDOP), Horizontal Dilution of Precision (HDOP), Vertical\n        Dilution of Precision, and fix status&quot;&quot;&quot;\n\n        # Fix Type (None,2D or 3D)\n        try:\n            fix_type = int(self.gps_segments[2])\n        except ValueError:\n            return False\n\n        # Read All (up to 12) Available PRN Satellite Numbers\n        sats_used = []\n        for sats in range(12):\n            sat_number_str = self.gps_segments[3 + sats]\n            if sat_number_str:\n                try:\n                    sat_number = int(sat_number_str)\n                    sats_used.append(sat_number)\n                except ValueError:\n                    return False\n            else:\n                break\n\n        # PDOP,HDOP,VDOP\n        try:\n            pdop = float(self.gps_segments[15])\n            hdop = float(self.gps_segments[16])\n            vdop = float(self.gps_segments[17])\n        except ValueError:\n            return False\n\n        # Update Object Data\n        self.fix_type = fix_type\n\n        # If Fix is GOOD, update fix timestamp\n        if fix_type &gt; self.__NO_FIX:\n            self.new_fix_time()\n\n        self.satellites_used = sats_used\n        self.hdop = hdop\n        self.vdop = vdop\n        self.pdop = pdop\n\n        return True\n\n    def gpgsv(self):\n        &quot;&quot;&quot;Parse Satellites in View (GSV) sentence. Updates number of SV Sentences,the number of the last SV sentence\n        parsed, and data on each satellite present in the sentence&quot;&quot;&quot;\n        try:\n            num_sv_sentences = int(self.gps_segments[1])\n            current_sv_sentence = int(self.gps_segments[2])\n            sats_in_view = int(self.gps_segments[3])\n        except ValueError:\n            return False\n\n        # Create a blank dict to store all the satellite data from this sentence in:\n        # satellite PRN is key, tuple containing telemetry is value\n        satellite_dict = dict()\n\n        # Calculate  Number of Satelites to pull data for and thus how many segment positions to read\n        if num_sv_sentences == current_sv_sentence:\n            # Last sentence may have 1-4 satellites; 5 - 20 positions\n            sat_segment_limit = (sats_in_view - ((num_sv_sentences - 1) * 4)) * 5\n        else:\n            sat_segment_limit = 20  # Non-last sentences have 4 satellites and thus read up to position 20\n\n        # Try to recover data for up to 4 satellites in sentence\n        for sats in range(4, sat_segment_limit, 4):\n\n            # If a PRN is present, grab satellite data\n            if self.gps_segments[sats]:\n                try:\n                    sat_id = int(self.gps_segments[sats])\n                except (ValueError,IndexError):\n                    return False\n\n                try:  # elevation can be null (no value) when not tracking\n                    elevation = int(self.gps_segments[sats+1])\n                except (ValueError,IndexError):\n                    elevation = None\n\n                try:  # azimuth can be null (no value) when not tracking\n                    azimuth = int(self.gps_segments[sats+2])\n                except (ValueError,IndexError):\n                    azimuth = None\n\n                try:  # SNR can be null (no value) when not tracking\n                    snr = int(self.gps_segments[sats+3])\n                except (ValueError,IndexError):\n                    snr = None\n            # If no PRN is found, then the sentence has no more satellites to read\n            else:\n                break\n\n            # Add Satellite Data to Sentence Dict\n            satellite_dict[sat_id] = (elevation, azimuth, snr)\n\n        # Update Object Data\n        self.total_sv_sentences = num_sv_sentences\n        self.last_sv_sentence = current_sv_sentence\n        self.satellites_in_view = sats_in_view\n\n        # For a new set of sentences, we either clear out the existing sat data or\n        # update it as additional SV sentences are parsed\n        if current_sv_sentence == 1:\n            self.satellite_data = satellite_dict\n        else:\n            self.satellite_data.update(satellite_dict)\n\n        return True\n\n    ##########################################\n    # Data Stream Handler Functions\n    ##########################################\n\n    def new_sentence(self):\n        &quot;&quot;&quot;Adjust Object Flags in Preparation for a New Sentence&quot;&quot;&quot;\n        self.gps_segments = ['']\n        self.active_segment = 0\n        self.crc_xor = 0\n        self.sentence_active = True\n        self.process_crc = True\n        self.char_count = 0\n\n    def update(self, new_char):\n        &quot;&quot;&quot;Process a new input char and updates GPS object if necessary based on special characters ('$', ',', '*')\n        Function builds a list of received string that are validate by CRC prior to parsing by the  appropriate\n        sentence function. Returns sentence type on successful parse, None otherwise&quot;&quot;&quot;\n\n        valid_sentence = False\n\n        # Validate new_char is a printable char\n        ascii_char = ord(new_char)\n\n        if 10 &lt;= ascii_char &lt;= 126:\n            self.char_count += 1\n\n            # Write Character to log file if enabled\n            if self.log_en:\n                self.write_log(new_char)\n\n            # Check if a new string is starting ($)\n            if new_char == '$':\n                self.new_sentence()\n                return None\n\n            elif self.sentence_active:\n\n                # Check if sentence is ending (*)\n                if new_char == '*':\n                    self.process_crc = False\n                    self.active_segment += 1\n                    self.gps_segments.append('')\n                    return None\n\n                # Check if a section is ended (,), Create a new substring to feed\n                # characters to\n                elif new_char == ',':\n                    self.active_segment += 1\n                    self.gps_segments.append('')\n\n                # Store All Other printable character and check CRC when ready\n                else:\n                    self.gps_segments[self.active_segment] += new_char\n\n                    # When CRC input is disabled, sentence is nearly complete\n                    if not self.process_crc:\n\n                        if len(self.gps_segments[self.active_segment]) == 2:\n                            try:\n                                final_crc = int(self.gps_segments[self.active_segment], 16)\n                                if self.crc_xor == final_crc:\n                                    valid_sentence = True\n                                else:\n                                    self.crc_fails += 1\n                            except ValueError:\n                                pass  # CRC Value was deformed and could not have been correct\n\n                # Update CRC\n                if self.process_crc:\n                    self.crc_xor ^= ascii_char\n\n                # If a Valid Sentence Was received and it's a supported sentence, then parse it!!\n                if valid_sentence:\n                    self.clean_sentences += 1  # Increment clean sentences received\n                    self.sentence_active = False  # Clear Active Processing Flag\n\n                    if self.gps_segments[0] in self.supported_sentences:\n\n                        # parse the Sentence Based on the message type, return True if parse is clean\n                        if self.supported_sentences[self.gps_segments[0]](self):\n\n                            # Let host know that the GPS object was updated by returning parsed sentence type\n                            self.parsed_sentences += 1\n                            return self.gps_segments[0]\n\n                # Check that the sentence buffer isn't filling up with Garage waiting for the sentence to complete\n                if self.char_count &gt; self.SENTENCE_LIMIT:\n                    self.sentence_active = False\n\n        # Tell Host no new sentence was parsed\n        return None\n\n    def new_fix_time(self):\n        &quot;&quot;&quot;Updates a high resolution counter with current time when fix is updated. Currently only triggered from\n        GGA, GSA and RMC sentences&quot;&quot;&quot;\n        try:\n            self.fix_time = utime.ticks_ms()\n        except NameError:\n            self.fix_time = time.time()\n\n    #########################################\n    # User Helper Functions\n    # These functions make working with the GPS object data easier\n    #########################################\n\n    def satellite_data_updated(self):\n        &quot;&quot;&quot;\n        Checks if the all the GSV sentences in a group have been read, making satellite data complete\n        :return: boolean\n        &quot;&quot;&quot;\n        if self.total_sv_sentences &gt; 0 and self.total_sv_sentences == self.last_sv_sentence:\n            return True\n        else:\n            return False\n\n    def unset_satellite_data_updated(self):\n        &quot;&quot;&quot;\n        Mark GSV sentences as read indicating the data has been used and future updates are fresh\n        &quot;&quot;&quot;\n        self.last_sv_sentence = 0\n\n    def satellites_visible(self):\n        &quot;&quot;&quot;\n        Returns a list of of the satellite PRNs currently visible to the receiver\n        :return: list\n        &quot;&quot;&quot;\n        return list(self.satellite_data.keys())\n\n    def time_since_fix(self):\n        &quot;&quot;&quot;Returns number of millisecond since the last sentence with a valid fix was parsed. Returns 0 if\n        no fix has been found&quot;&quot;&quot;\n\n        # Test if a Fix has been found\n        if self.fix_time == 0:\n            return -1\n\n        # Try calculating fix time using utime; if not running MicroPython\n        # time.time() returns a floating point value in secs\n        try:\n            current = utime.ticks_diff(utime.ticks_ms(), self.fix_time)\n        except NameError:\n            current = (time.time() - self.fix_time) * 1000  # ms\n\n        return current\n\n    def compass_direction(self):\n        &quot;&quot;&quot;\n        Determine a cardinal or inter-cardinal direction based on current course.\n        :return: string\n        &quot;&quot;&quot;\n        # Calculate the offset for a rotated compass\n        if self.course &gt;= 348.75:\n            offset_course = 360 - self.course\n        else:\n            offset_course = self.course + 11.25\n\n        # Each compass point is separated by 22.5 degrees, divide to find lookup value\n        dir_index = floor(offset_course \/ 22.5)\n\n        final_dir = self.__DIRECTIONS[dir_index]\n\n        return final_dir\n\n    def latitude_string(self):\n        &quot;&quot;&quot;\n        Create a readable string of the current latitude data\n        :return: string\n        &quot;&quot;&quot;\n        if self.coord_format == 'dd':\n            formatted_latitude = self.latitude\n            lat_string = str(formatted_latitude[0]) + '\u00b0 ' + str(self._latitude[2])\n        elif self.coord_format == 'dms':\n            formatted_latitude = self.latitude\n            lat_string = str(formatted_latitude[0]) + '\u00b0 ' + str(formatted_latitude[1]) + &quot;' &quot; + str(formatted_latitude[2]) + '&quot; ' + str(formatted_latitude[3])\n        else:\n            lat_string = str(self._latitude[0]) + '\u00b0 ' + str(self._latitude[1]) + &quot;' &quot; + str(self._latitude[2])\n        return lat_string\n\n    def longitude_string(self):\n        &quot;&quot;&quot;\n        Create a readable string of the current longitude data\n        :return: string\n        &quot;&quot;&quot;\n        if self.coord_format == 'dd':\n            formatted_longitude = self.longitude\n            lon_string = str(formatted_longitude[0]) + '\u00b0 ' + str(self._longitude[2])\n        elif self.coord_format == 'dms':\n            formatted_longitude = self.longitude\n            lon_string = str(formatted_longitude[0]) + '\u00b0 ' + str(formatted_longitude[1]) + &quot;' &quot; + str(formatted_longitude[2]) + '&quot; ' + str(formatted_longitude[3])\n        else:\n            lon_string = str(self._longitude[0]) + '\u00b0 ' + str(self._longitude[1]) + &quot;' &quot; + str(self._longitude[2])\n        return lon_string\n\n    def speed_string(self, unit='kph'):\n        &quot;&quot;&quot;\n        Creates a readable string of the current speed data in one of three units\n        :param unit: string of 'kph','mph, or 'knot'\n        :return:\n        &quot;&quot;&quot;\n        if unit == 'mph':\n            speed_string = str(self.speed[1]) + ' mph'\n\n        elif unit == 'knot':\n            if self.speed[0] == 1:\n                unit_str = ' knot'\n            else:\n                unit_str = ' knots'\n            speed_string = str(self.speed[0]) + unit_str\n\n        else:\n            speed_string = str(self.speed[2]) + ' km\/h'\n\n        return speed_string\n\n    def date_string(self, formatting='s_mdy', century='20'):\n        &quot;&quot;&quot;\n        Creates a readable string of the current date.\n        Can select between long format: Januray 1st, 2014\n        or two short formats:\n        11\/01\/2014 (MM\/DD\/YYYY)\n        01\/11\/2014 (DD\/MM\/YYYY)\n        :param formatting: string 's_mdy', 's_dmy', or 'long'\n        :param century: int delineating the century the GPS data is from (19 for 19XX, 20 for 20XX)\n        :return: date_string  string with long or short format date\n        &quot;&quot;&quot;\n\n        # Long Format Januray 1st, 2014\n        if formatting == 'long':\n            # Retrieve Month string from private set\n            month = self.__MONTHS[self.date[1] - 1]\n\n            # Determine Date Suffix\n            if self.date[0] in (1, 21, 31):\n                suffix = 'st'\n            elif self.date[0] in (2, 22):\n                suffix = 'nd'\n            elif self.date[0] == (3, 23):\n                suffix = 'rd'\n            else:\n                suffix = 'th'\n\n            day = str(self.date[0]) + suffix  # Create Day String\n\n            year = century + str(self.date[2])  # Create Year String\n\n            date_string = month + ' ' + day + ', ' + year  # Put it all together\n\n        else:\n            # Add leading zeros to day string if necessary\n            if self.date[0] &lt; 10:\n                day = '0' + str(self.date[0])\n            else:\n                day = str(self.date[0])\n\n            # Add leading zeros to month string if necessary\n            if self.date[1] &lt; 10:\n                month = '0' + str(self.date[1])\n            else:\n                month = str(self.date[1])\n\n            # Add leading zeros to year string if necessary\n            if self.date[2] &lt; 10:\n                year = '0' + str(self.date[2])\n            else:\n                year = str(self.date[2])\n\n            # Build final string based on desired formatting\n            if formatting == 's_dmy':\n                date_string = day + '\/' + month + '\/' + year\n\n            else:  # Default date format\n                date_string = month + '\/' + day + '\/' + year\n\n        return date_string\n\n    # All the currently supported NMEA sentences\n    supported_sentences = {'GPRMC': gprmc, 'GLRMC': gprmc,\n                           'GPGGA': gpgga, 'GLGGA': gpgga,\n                           'GPVTG': gpvtg, 'GLVTG': gpvtg,\n                           'GPGSA': gpgsa, 'GLGSA': gpgsa,\n                           'GPGSV': gpgsv, 'GLGSV': gpgsv,\n                           'GPGLL': gpgll, 'GLGLL': gpgll,\n                           'GNGGA': gpgga, 'GNRMC': gprmc,\n                           'GNVTG': gpvtg, 'GNGLL': gpgll,\n                           'GNGSA': gpgsa,\n                          }\n\nif __name__ == &quot;__main__&quot;:\n    pass\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/MicroPython\/micropyGPS.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>These are the general instructions to upload the micropyGPS library to your board:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First, make sure your board is running MicroPython firmware\u2014check the\u00a0<a href=\"#prerequisites\" title=\"Prerequisites section\">Prerequisites section<\/a>.<\/li>\n\n\n\n<li>Create a new file in your IDE with the name&nbsp;micropyGPS.py&nbsp;and paste the previous code there. Save that file.<\/li>\n\n\n\n<li>Establish a serial communication with your board using your IDE.<\/li>\n\n\n\n<li>Upload the&nbsp;micropyGPS.py&nbsp;file to your board. In Thonny IDE, go to <strong>File <\/strong>&gt; <strong>Save as&#8230;<\/strong> and select <strong>MicroPython Device<\/strong>\/<strong>Raspberry Pi Pico<\/strong>.<\/li>\n\n\n\n<li>At this point, the library should have been successfully uploaded to your board. Now, you can use the library functionalities in your code by importing the library <span class=\"rnthl rntliteral\">import micropyGPS<\/span>.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rpi-pico-neo-6m-gps-data-micropygps\">Raspberry Pi Pico with NEO-6M: Getting GPS Data with MicroPython<\/h2>\n\n\n\n<p>The micropyGPS library makes it easier to get GPS data in a format that is easy to understand.<\/p>\n\n\n\n<p>The following code shows how to use the library to get GPS data like latitude, longitude, altitude, date and time, number of visible satellites and HDOP (a measurement of how precise the signal is).<\/p>\n\n\n\n<p><strong>After importing the micropyGPS library <\/strong>to your board, you can run the following code.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n# Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-neo-6m-micropython\/\n\nfrom machine import UART, Pin\nfrom time import sleep\nfrom micropyGPS import MicropyGPS\n\n# Instantiate the micropyGPS object\nmy_gps = MicropyGPS()\n\n# Define the UART pins and create a UART object\ngps_serial = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))\n\nwhile True:\n    try:\n        while gps_serial.any():\n            data = gps_serial.read()\n            for byte in data:\n                stat = my_gps.update(chr(byte))\n                if stat is not None:\n                    # Print parsed GPS data\n                    print('UTC Timestamp:', my_gps.timestamp)\n                    print('Date:', my_gps.date_string('long'))\n                    print('Latitude:', my_gps.latitude_string())\n                    print('Longitude:', my_gps.longitude_string())\n                    print('Altitude:', my_gps.altitude)\n                    print('Satellites in use:', my_gps.satellites_in_use)\n                    print('Horizontal Dilution of Precision:', my_gps.hdop)\n                    print()\n            \n    except Exception as e:\n        print(f&quot;An error occurred: {e}&quot;)\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/MicroPython\/NEO_6M_GPS_Basic.py\" 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>Continue reading to learn how the code works, or skip to the <a href=\"#demonstration\" title=\"\">demonstration section<\/a>.<\/p>\n\n\n\n<p>First, import the required modules, including the <span class=\"rnthl rntliteral\">MicropyGPS<\/span> class from the <span class=\"rnthl rntliteral\">micropyGPS<\/span> module you imported previously.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from machine import UART, Pin\nfrom time import sleep\nfrom micropyGPS import MicropyGPS<\/code><\/pre>\n\n\n\n<p>Create an instance of the <span class=\"rnthl rntliteral\">MicropyGPS<\/span> class called <span class=\"rnthl rntliteral\">my_gps<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Instantiate the micropyGPS object\nmy_gps = MicropyGPS()<\/code><\/pre>\n\n\n\n<p>Then, initialize a <span class=\"rnthl rntliteral\">UART<\/span> instance for serial communication with the module. We&#8217;re using UART 1 and GPIO 4 for TX and GPIO 5 for RX. We also define the baud rate for the GPS module (the NEO-6M uses 9600).<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>gps_serial = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))<\/code><\/pre>\n\n\n\n<p>Then, we create an infinite loop to continuously read GPS data.<\/p>\n\n\n\n<p>We check if there is new data available to read. If there is, we read the data and pass it to the <span class=\"rnthl rntliteral\">my_gps<\/span> instance using the <span class=\"rnthl rntliteral\">update()<\/span> method. <\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>while gps_serial.any():\n    data = gps_serial.read()\n    for byte in data:\n        stat = my_gps.update(chr(byte))<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">update()<\/span> method returns valid GPS sentences or <span class=\"rnthl rntliteral\">None<\/span> if that&#8217;s not the case. So, we check if we have valid data before proceeding.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>if stat is not None:<\/code><\/pre>\n\n\n\n<p>Then, we can access the GPS data by using the <span class=\"rnthl rntliteral\">micropyGPS<\/span> methods on the <span class=\"rnthl rntliteral\">my_gps<\/span> object that should contain the data gathered from the GPS module.<\/p>\n\n\n\n<p>The following lines show how to get time, date, latitude, longitude, altitude, number of satellites used, and HDOP.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Print parsed GPS data\nprint('UTC Timestamp:', my_gps.timestamp)\nprint('Date:', my_gps.date_string('long'))\nprint('Latitude:', my_gps.latitude_string())\nprint('Longitude:', my_gps.longitude_string())\nprint('Altitude:', my_gps.altitude)\nprint('Satellites in use:', my_gps.satellites_in_use)\nprint('Horizontal Dilution of Precision:', my_gps.hdop)\nprint()<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">micropyGPS<\/span> library supports other methods to get more GPS data and in different formats. We recommend you take a look at the <a href=\"https:\/\/github.com\/inmcm\/micropyGPS\/tree\/master?tab=readme-ov-file#micropygps\" target=\"_blank\" rel=\"noopener\" title=\"\">documentation <\/a>and see all the available options.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"demonstration\">Demonstration<\/h3>\n\n\n\n<p>After uploading the <span class=\"rnthl rntliteral\">micropyGPS<\/span> module to your board, you can run this previous code to get GPS data.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"114\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/12\/thonny-ide-run-button.png?resize=470%2C114&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Run code Thonny IDE\" class=\"wp-image-144594\" style=\"width:470px;height:auto\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/12\/thonny-ide-run-button.png?w=470&amp;quality=100&amp;strip=all&amp;ssl=1 470w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/12\/thonny-ide-run-button.png?resize=300%2C73&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/figure><\/div>\n\n\n<p>Make sure you place your board or antenna next to a window, or preferably outside so that it can get data from satellites. You may need to wait a few minutes until it gets a position fix and can send valid data. The NEO-6M GPS module&#8217;s blue LED will start blinking when it&#8217;s ready.<\/p>\n\n\n\n<p>In the MicroPython shell, you should get information about your current location, date and time in UTC, number of satellites, and HDOP. The higher the number of satellites and the lower the HDOP the better.<\/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=\"763\" height=\"433\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-GPS-Data-Thonny-IDE.png?resize=763%2C433&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico with NEO-6M Get GPS data with MicroPython Demonstration\" class=\"wp-image-160964\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-GPS-Data-Thonny-IDE.png?w=763&amp;quality=100&amp;strip=all&amp;ssl=1 763w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-Get-GPS-Data-Thonny-IDE.png?resize=300%2C170&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 763px) 100vw, 763px\" \/><\/figure><\/div>\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 Raspberry Pi Pico using MicroPython. You learned how to get your current location and date and time.<\/p>\n\n\n\n<p>Now, you can take this project further and display the data on an OLED display or LCD. You can check the following tutorials to learn how to use these displays with the Raspberry Pi Pico:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ssd1306-oled-micropython\/\">Raspberry Pi Pico: SSD1306 OLED Display (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-i2c-lcd-display-micropython\/\">Raspberry Pi Pico with I2C LCD Display (MicroPython)<\/a><\/li>\n<\/ul>\n\n\n\n<p>We hope you find this guide useful. If you want to learn more about the Raspberry Pi Pico, make sure to take a look at our eBook:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-micropython-ebook\/\" title=\"\"><strong>Learn Raspberry Pi Pico\/PicoW with MicroPython (eBook)<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi-pico\/\" title=\"\">Free Raspberry Pi Pico projects and tutorials<\/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 the Raspberry Pi Pico to get GPS data: latitude, longitude, altitude, date, and time. We&#8217;ll show you how to connect the &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi Pico: NEO-6M GPS Module &#8211; Get Location and Time (MicroPython)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-neo-6m-micropython\/#more-160957\" aria-label=\"Read more about Raspberry Pi Pico: NEO-6M GPS Module &#8211; Get Location and Time (MicroPython)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":160962,"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":[324,326],"tags":[],"class_list":["post-160957","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi-pico","category-raspberry-pi-pico-micropython"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-NEO-6M-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\/160957","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=160957"}],"version-history":[{"count":11,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/160957\/revisions"}],"predecessor-version":[{"id":166795,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/160957\/revisions\/166795"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/160962"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=160957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=160957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=160957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}