Do you need GPS time on your desk? This article will show you how to use a GPS module to get time, date and your location displayed on an LCD with an Arduino.




The development of the Global Positioning System, or GPS, started in the early 1970's. Each country (Russia, US, China, etc) has its own system, but most of the GPS units around the world are use the US system.

Each satellite for each system has an atomic clock, which is continously monitored and set by NORAD every single day:

"Conceptually, the receiver measures the TOAs (according to its own clock) of four satellite signals. From the TOAs and the TOTs, the receiver forms four time of flight (TOF) values, which are (given the speed of light) approximately equivalent to receiver-satellite range differences. The receiver then computes its three-dimensional position and clock deviation from the four TOFs." (Wikipedia)

$$\text{Note: TOA = Time of arrival,  TOT = Time of transmission}$$

The most inexpensive GPS receivers have about 20 meters accuracy for most places on Earth. Here we'll be learning how to learn our own GPS clock using Arduino.



My GPS module has 6 pins: GND, Vin, Tx, Rx & GND. The 6th pin is NC. GND is connected to GND, Vin to Vin, TX is connected to Arduino pin 10, and the Rx pin is not connected to anything since I am not sending any messages to the GPS module. My module is transmitting satellite data using RS-232 with 4800 bps, which is received on pin 10.

This is the module, front and back.

The module is sending what is known as NMEA-sentences. Here you can see an example of one NMEA sentence and the explanation of that sentence (excerpt from datasheet):


All this data is received by the Arduino Mega on pin 10. The TinyGPS library is reading the GPGGA sentence and the GPRMC sentence. (See the datasheet for details about GPRMC.)


The Arduino is not in the schematic, so please follow the connections.



When power is applied, the GPS module takes some time to get a valid fix on the satellites. When a fixed position is made, the module sends the NMEA sentences to the Arduino. The TinyGPS library has one function to get the date and time from the GPRMC sentence. It is called crack_datetime(), and it takes seven variables: year, month, day, hour, minute, seconds, and hundredths. A function call looks like this:

gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);

Calling this function gives you the right values in the variables as long as everything with the hardware is ok.

To get our position, you call the function f_get_position(). This function takes two variables, latitude and longitude. To call this function you write this in your code:

gps.f_get_position(&latitude, &longitude);

The sketch in the link shows how both functions works.



Here are all the files you'll need:


  Source Code Sketch     TinyGPS Library     Datasheet  


In this article, I have shown you how to get the time, date, and location from a GPS module, then display it all on an LCD. Now you know where you are!


Pictures & Video

In the pictures and video, I have added an offset to the latitude and longitude for my privacy. The room I am working in is in the basement and has four concrete walls. To get better reception, I had to solder a cable between the GPS module and the connections header. Then I placed the GPS in the window.





  • brownrj 2015-12-18

    Can other GPS modules be used? Would the Tiny GPS Library be applicable?

  • shirley11 2016-01-20

    wow   it’s amazing!! Great !!

  • jerinkumar 2016-02-15

    thank you

  • F5GMU 2016-03-24

    Problerm to download source code sketch. Only PDF file in zip.
    Thanks for a solution.
    Best regards.

    • Jens Christoffersen 2016-03-27

      Looks like there has been a mix with the names of the link buttons. The Datasheet-button links to the sketch. Weird. Thanks, I’ll try to fix it.

  • rwolfe9 2016-04-08

    I have loaded the sketch and tried to run, displays GPS Clock and quits.  I found that there were some brackets missing in the void loop/end, TinyGPS errors, etc.  Are there any revisions for the code?

  • Bprice15 2016-04-11

    I Have an adafruit gps breakout and Its TX pin is hooked up to the 10 pin on the arduino mega, the RX pin is not hooked up to anything. The welcome message GPS clock comes up but nothing else does. what would you suggest I try to do?

    • Jens Christoffersen 2016-04-12

      After the welcome message, the software waits for input on pin 10. Are you sure your GPS module has a valid position?

  • nsayer 2017-05-12

    You’re not using the PPS? It’s not going to be very accurate that way. You essentially have no way of knowing when the NMEA sentences happen relative to the GPS second.

    • Jens Christoffersen 2017-05-25

      This clock is not mission critical. A second behind or a second ahead does not matter.

  • asifbhoy 2017-05-14

    Can we use it for showing milliseconds too?