yaboPP电子
Project

Make a GPS Clock With Arduino

December 09, 2015byJens 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.

Requirements

Introduction

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:

“从概念上讲,接收者措施加强(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.

Hardware

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.

Software

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 calledcrack_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 functionf_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);

链接的草图显示了我们两个功能rks.

Downloads

Here are all the files you'll need:

Conclusion

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.

18 Comments
  • B
    brownrj December 18, 2015

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

    Like. Reply
  • shirley11 January 20, 2016

    wow it’s amazing!! Great !!

    Like. Reply