Make a GPS Clock With Arduino

December 09, 2015 by Jens Christoffersen

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.

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:


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.


Give this project a try for yourself! Get the BOM.

  • B
    brownrj December 18, 2015

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

    Like. Reply
  • shirley11 January 20, 2016

    wow   it’s amazing!! Great !!

    Like. Reply
  • J
    jerinkumar February 15, 2016

    thank you

    Like. Reply
  • F
    F5GMU March 24, 2016

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

    Like. Reply
    • J
      Jens Christoffersen March 27, 2016
      Hi. 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.
      Like. Reply
  • R
    rwolfe9 April 08, 2016

    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?

    Like. Reply
  • B
    Bprice15 April 11, 2016

    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?

    Like. Reply
    • J
      Jens Christoffersen April 12, 2016
      After the welcome message, the software waits for input on pin 10. Are you sure your GPS module has a valid position?
      Like. Reply
  • nsayer May 12, 2017

    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.

    Like. Reply
  • A
    asifbhoy May 14, 2017

    Can we use it for showing milliseconds too?

    Like. Reply