Arduino GPS real time clock with NEO-6M module

There are different ways to build an Arduino based real time clock, one of the ways is using a real time clock chip (like: DS1302, DS1307, DS3231 …) and another way is by using a GPS module. The GPS based clock receives time from satellites and automatically sets its time. This topic shows how to build an Arduino GPS clock with NEO-6M GPS module where time and date are displayed on 16×2 LCD screen.

Related Projects:
Last time I made a simple interfacing of Arduino with NEO-6M GPS module in order to get position, time, date and speed, project page link is below:
Interfacing Arduino with NEO-6M GPS module
Arduino GPS clock with local time using NEO-6M module

and the links below shows how to build a real time clock using Arduino and RTC chips:
Arduino real time clock with DS1307
Arduino and DS3231 real time clock

Hardware Required:
To build this project the following components are needed:

  • Arduino (or compatible) board
  • NEO-6M GPS module
  • 16×2 LCD screen
  • 10k ohm variable resistor (or potentiometer)
  • 330 ohm resistor
  • Breadboard
  • Jumper wires

Arduino GPS clock with U-Blox NEO-6M GPS module

Arduino GPS real time clock with NEO-6M module circuit:
Project circuit diagram is shown below.

Arduino GPS real time clock with NEO-6M and LCD

NEO-6M GPS module has 4 pins where:
NEO-6M GPS board GND pin goes to Arduino GND
TX pin goes to Arduino digital pin 9
RX pin is not connected
VCC pin goes to Arduino 5V pin (can be connected to 3.3V pin)

The 1602 LCD screen is used to display the real time clock time and date where:
RS —> Arduino digital pin 2
E  —> Arduino digital pin 3
D4 —> Arduino digital pin 4
D5 —> Arduino digital pin 5
D6 —> Arduino digital pin 6
D7 —> Arduino digital pin 7
VSS, RW, D0, D1, D2, D3 and K are connected to Arduino GND (ground)
VEE to the variable resistor (or potentiometer) output
VDD to Arduino 5V and A to Arduino 5V through 330 ohm resistor

VEE pin is used to control the contrast of the LCD. A (anode) and K (cathode) are the back light LED pins.

Arduino GPS clock code:
The Arduino code below uses TinyGPS++ library, it can be downloaded from the link below. After downloading the library, unzip the folder and add it to Arduino libraries folder (for example: C:\Program Files\Arduino\libraries). You should rename the folder “TinyGPSPlus”.
TinyGPS++ Library  —  direct link

Full Arduino code is below.

The following video shows how a hardware circuit should work (UTC time):

24 thoughts on “Arduino GPS real time clock with NEO-6M module”

  1. Same basic code, but for 8×2 display. It shows hh:mm:ss dd/mm’yy

    // Arduino GPS real time clock with NEO-6M GPS module

    #include // Include TinyGPS++ library
    #include // Include software serial library
    #include // Include LCD library

    TinyGPSPlus gps;

    #define S_RX 9 // Define software serial RX pin
    #define S_TX 8 // Define software serial TX pin

    SoftwareSerial SoftSerial(S_RX, S_TX); // Configure SoftSerial library

    // LCD module connections (RS, E, D4, D5, D6, D7)
    LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

    byte last_second;
    char Time[] = “00:00:00”;
    char Date[] = “00/00’00”;

    void setup(void) {
    SoftSerial.begin(9600);

    // set up the LCD’s number of columns and rows
    lcd.begin(8, 2);

    lcd.setCursor(0, 0);
    lcd.print(Time); // Display time
    lcd.setCursor(0, 1);
    lcd.print(Date); // Display calendar
    }

    void loop() {

    while (SoftSerial.available() > 0) {

    if (gps.encode(SoftSerial.read())) {

    if (gps.time.isValid()) {
    Time[0] = gps.time.hour() / 10 + 48;
    Time[1] = gps.time.hour() % 10 + 50;
    Time[3] = gps.time.minute() / 10 + 48;
    Time[4] = gps.time.minute() % 10 + 48;
    Time[6] = gps.time.second() / 10 + 48;
    Time[7] = gps.time.second() % 10 + 48;
    }

    if (gps.date.isValid()) {
    Date[0] = gps.date.day() / 10 + 48;
    Date[1] = gps.date.day() % 10 + 48;
    Date[3] = gps.date.month() / 10 + 48;
    Date[4] = gps.date.month() % 10 + 48;
    Date[6] =(gps.date.year() / 10) % 10 + 48;
    Date[7] = gps.date.year() % 10 + 48;
    }

    if(last_second != gps.time.second()) {
    last_second = gps.time.second();
    lcd.setCursor(0, 0);
    lcd.print(Time); // Display time
    lcd.setCursor(0, 1);
    lcd.print(Date); // Display calendar
    }

    }

    }

    }

  2. محمد جمعة

    I did everytging the same as in the video but when i run the code it doesnt show anything on the LCD-Display.

  3. I plan to build a drone this summer and am learning to use this GPS module, thanks for the sketch and diagrams. It worked first time, now I have moved the date to the first line before the time (shorter year and no seconds to make room) and now my bottom line is blank. I plan to put the lat/long coords there. Thanks again.

    1. Only mistakes .VSS, RW, D0, D1, D2, D3 and K errors themselves are connected to the Arduino GND (ground). D0, D1, D2, D3 They cannot be connected to GND ground! Because the LCD display may be damaged!

  4. I have tried to load the sketch but on uploading it errors on line 39 “expected identifier before “if”
    any ideas on this

  5. Thank you very much for this awesme tutorial !

    Unfortunately my “extension” failed completely. Any help is appreciated.

    // update number of satellites
    if (gps.satellites.isValid())
    {
    NumberSat = gps.satellites.value() ;
    }

  6. Thank You. Works perfectly for me with a’ GoouuuTech’ clone GPS receiver. This even gives me a 1PPS output, which is very useful for synchronising other clocks.

  7. I need a little help
    I’m working on a project for a local church.
    It is necessary to ring the bells every day at 7 am and 7 pm.
    The bells are connected with relay.
    What I need to add to code to turn on the relay at 7 am and 7 pm.

      1. Yes, I’m doing this in the 16×2 display sketch; I changed the Time Zone as follows:
        from: #define time_offset 3600
        to: #define time_offset -7200 (Brazil -3) but nothing is changing on the display.

          1. I want to adapt the code “Arduino GPS clock with local time using NEO-6M module” in the sketch “Arduino GPS real time clock with NEO-6M module” for the Display 16×2 because I need to change the Timezone in Display 16×2.

  8. Your wiring diagram shows connection from the GPS to the Arduino on Digital pin 9 but your text description says “TX pin goes to Arduino digital pin 4 “. The code is written for pin 9 so I guess it’s just a typo.

    1. No need for an internet connection.
      The Arduino is getting the time from the GPS unit.

      It is reading the data from the GPS unit (line 37) through a serial connection (connected to pins 8 and 9) then extracting the time and date from that GPS data (lines 39 thru 55).

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top