Contents

Interfacing NEO-8M GPS Module with Arduino

NEO-8M GPS Module Features

The GY-NEO-8M module is an advanced GPS module based on uBlox m8N that supports UART communication protocol with active antenna. You can interface this module easily with a microcontroller. This module has a rechargeable battery and can also be connected directly to a computer using a USB to TTL converter.

NEO-8M can receive information and then calculate the geographical position with very high accuracy and fast speed. In addition to supporting BeiDou, Galileo, GLONASS, GPS / QZSS, the module has an internal memory to save settings. NEO-8M is compatible with Arduino and can be used in any project

Tip

The on-board LED starts blinking when module is connecting to GPS satellites.

You can download the datasheet of this module here.

GY-NEO-8M GPS Module Pinout

This sensor has 4 pins:

  • VIN: Module power supply – 5 V
  • GND: Ground
  • RX: Receive data via serial protocol
  • TX: Sending data via serial protocol

You can see pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
NEO-8M GPS Module × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing GY-NEO-8M GPS Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to R305 module. Connect wires accordingly.

Step 2: Code

Install the following library on your Arduino.

https://github.com/mikalhart/TinyGPSPlus

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Upload the following code to your Arduino.

 /*   
modified on Sep 27, 2020
Modified by MohammedDamirchi from https://github.com/mikalhart/TinyGPSPlus
Home
*/ #include <TinyGPS++.h> #include <SoftwareSerial.h> /* This sample demonstrates TinyGPS++'s capacity for extracting custom fields from any NMEA sentence. TinyGPS++ has built-in facilities for extracting latitude, longitude, altitude, etc., from the $GPGLL and $GPRMC sentences. But with the TinyGPSCustom type, you can extract other NMEA fields, even from non-standard NMEA sentences. It requires the use of SoftwareSerial, and assumes that you have a 9600-baud serial GPS device hooked up on pins 4(RX) and 3(TX). */ static const int RXPin = 4, TXPin = 3; static const uint32_t GPSBaud = 9600; // The TinyGPS++ object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); /* By declaring TinyGPSCustom objects like this, we announce that we are interested in the 15th, 16th, and 17th fields in the $GPGSA sentence, respectively the PDOP (F("positional dilution of precision")), HDOP (F("horizontal...")), and VDOP (F("vertical...")). (Counting starts with the field immediately following the sentence name, i.e. $GPGSA. For more information on NMEA sentences, consult your GPS module's documentation and/or http://aprs.gids.nl/nmea/.) If your GPS module doesn't support the $GPGSA sentence, then you won't get any output from this program. */ TinyGPSCustom pdop(gps, "GNGLL", 1); // $GPGSA sentence, 15th element TinyGPSCustom hdop(gps, "GNGLL", 3); // $GPGSA sentence, 16th element void setup() { Serial.begin(115200); ss.begin(GPSBaud); Serial.println(F("UsingCustomFields.ino")); Serial.println(F("Demonstrating how to extract any NMEA field using TinyGPSCustom")); Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion()); Serial.println(F("by Mikal Hart")); Serial.println(); } void loop() { Serial.print(F(" LAT=")); Serial.print(atof(pdop.value())/100,7); Serial.print(F("\tLON=")); Serial.println(atof(hdop.value())/100,7); delay(100); while (ss.available() > 0) gps.encode(ss.read()); Serial.print(F(" Date/Time: ")); if (gps.date.isValid()) { Serial.print(gps.date.month()); Serial.print(F("/")); Serial.print(gps.date.day()); Serial.print(F("/")); Serial.print(gps.date.year()); } else { Serial.print(F("INVALID")); } Serial.print(F(" ")); if (gps.time.isValid()) { if (gps.time.hour() < 10) Serial.print(F("0")); Serial.print(gps.time.hour()); Serial.print(F(":")); if (gps.time.minute() < 10) Serial.print(F("0")); Serial.print(gps.time.minute()); Serial.print(F(":")); if (gps.time.second() < 10) Serial.print(F("0")); Serial.print(gps.time.second()); Serial.print(F(".")); if (gps.time.centisecond() < 10) Serial.print(F("0")); Serial.print(gps.time.centisecond()); } else { Serial.print(F("INVALID")); } Serial.println(); }

After uploading the code, you can see the output in the serial monitor.

Liked What You See?​
Get Updates And Learn From The Best​

Comments (22)

  • Marcin Reply

    Hi,
    In the NEO-8M GPS Module Datasheet you have included above, there is a information that this module power supply voltage is maximum of 3,6V
    So can we safety conenct it to 5V arduino pin?

    BR,
    Marcin

    June 2, 2021 at 8:42 am
    • Mehran Maleki Reply

      Hi,
      The datasheet is for the IC itself. But the module here comes with a voltage regulator, so you can safely connect it to the Arduino 5V pin.

      June 7, 2021 at 4:42 am
    • Ghedim Reply

      You cannot connect the UART pins (TX – Arduino) directly to the NEO-8M, the voltage regulator in the module is only for power supply. For the UART you need a simple voltage divider to 3.3V.

      August 31, 2021 at 2:31 pm
  • Fatemeh Reply

    How can I use this program on Arduino due? when I am using Arduino UNO everything is ok but when I use this program on Arduino due it doesn’t work. i use pins 8&9 as RX and TX

    February 2, 2022 at 8:49 am
    • Mehran Maleki Reply

      Hi.
      Unfortunately, the library used in this code is written especially for AVR based Arduino Boards and doesn’t work for the Arduino Due which is based on STM32.

      February 2, 2022 at 10:42 am
      • Didier Rousseau Reply

        Arduino Due is not using STM32, it uses Microchip SAM MCU.
        A32bits MCU powered at 3V3.

        November 10, 2024 at 10:21 am
  • Tursunboy Reply

    everything is fine but the data coming out on the serial monitor lon = 0.0000,
    lat = 0.0000,
    Date / Time: INVALID INVALID

    March 2, 2022 at 12:14 pm
    • Mehran Maleki Reply

      Hi.
      First, this module can only work outdoors since it needs to connect to the GPS network system to give valid results. Also, you need to wait for 5 to 10 minutes for the module to connect to the network.

      March 2, 2022 at 12:24 pm
  • Tursunboy Reply

    I waited 10 minutes outdoors but got such a result. What does it mean?

    UsingCustomFields.ino
    Demonstrating how to extract any NMEA field using TinyGPSCustom
    Testing TinyGPS++ library v. 1.0.2
    by Mikal Hart

    March 2, 2022 at 1:04 pm
    • Mehran Maleki Reply

      It probably means the module has been successfully connected to the network. What do you get for lon, lat, Date and Time?

      March 5, 2022 at 5:46 am
  • chandan Reply

    everything is fine but the data coming out on the serial monitor lon = 0.0000,
    lat = 0.0000,
    Date / Time: INVALID INVALID
    i am using arduino mega board and connected to 50 and 52 pins , 50-TX and 52-RX
    i placed to for 10 minutes , but also it is same.

    September 5, 2022 at 10:39 am
  • Bora Reply

    I’ve the same problem. The only change is that it is connected to 3.3V
    UsingCustomFields.ino
    Demonstrating how to extract any NMEA field using TinyGPSCustom
    Testing TinyGPS++ library v. 1.0.2
    by Mikal Hart
    Date/Time: INVALID INVALID
    LAT=0.0000000 LON=0.0000000
    And it goes like this…

    October 17, 2022 at 8:15 pm
  • Cristian Simpson Reply

    Hi, I only get:
    Demonstrating how to extract any NMEA field using TinyGPSCustom
    Testing TinyGPS++ library v. 1.0.2
    by Mikal Hart
    Date/Time: INVALID INVALID
    LAT=0.0000000 LON=0.0000000
    And it goes like this…

    but if I connect my NEO-6 Ubox work fine. The NEO-8 need some special code or anything ?

    regards.

    November 17, 2022 at 1:42 am
    • Ali Abdolmaleki Reply

      Hi Dear.
      according to your data logs from device , it seems connection is not correct.
      please first check your hardware and then check C code programming that should define Module pin correctly.
      you Don’t need any special change in your code for NEO-8.

      November 30, 2022 at 9:14 am
  • Paul D.Wilkie Reply

    How do I communicate to my NEO-M8N GPS via SPI with Arduino.

    I am using a M8N GPS from RaceDayQuads part # RDQ BN-880.

    Can you help with making this connection via Arduino & TinyGPS Plus?

    December 13, 2022 at 6:52 pm
    • Ali Abdolmaleki Reply

      Hi there
      NEO-M8N GPS does not have SPI interface
      so it just setup with UART Protocol.

      February 15, 2023 at 11:16 am
  • Axel Reply

    Hi friend,
    When I upload the code, I don’t see anything in the serial monitor.
    I can only see several characters with no sense in a same straight line.
    Something like this:
    ��������������؉��������������
    What can be wrong?

    March 6, 2023 at 7:23 pm
    • Ali Abdolmaleki Reply

      Hi dear
      did you set baudrate correctly?
      it should be 115200 in serial Monitor.

      March 7, 2023 at 8:37 am
  • war Reply

    hello, are the neo 6m,7m and 8m libraries different?

    May 22, 2023 at 6:04 pm
    • Mohammad Damirchi Reply

      Hi war,
      no, all of them use the same TinyGPS++ library.

      May 23, 2023 at 6:37 am
  • Suyi Reply

    Are there more examples, for example to get the accelerometer data?

    October 24, 2024 at 8:45 am
    • Mohammad Damirchi Reply

      Hi Suyi,
      First, use a USB-TTL converter to connect your GPS module to your PC.
      Then, download the U-Center program to test and verify each reported value using the app.
      You might need to activate certain settings in the app and save them.
      After configuring, the module should send you all the necessary values, which you can access using serial.read to retrieve the required data (the current library may not fully support this).

      October 28, 2024 at 5:40 am

Leave a Reply

Your email address will not be published. Required fields are marked *