GPS Clock Time Adjusted to Timezone and Daylight Saving Time

Introduction: GPS Clock Time Adjusted to Timezone and Daylight Saving Time

About: I like to combine electronics like Arduino's, ESP8266 etc with 3D designing and 3D printing.

In this instructable I share with you my gathering of useful components in Arduino code.

If you have a GPS receiver, why not use the time of the GPS satellites displayed in the time of your timezone.

Inspired by https://www.instructables.com/id/Adjusting-GPS-Dat...

Step 1: Components and Assemblation

Components

I used the following components, readily available from Aliexpress, eBay or Amazon

Arduino nano 5v, 168P

GPS receiver: GY-NEO6MV2

LCD screen with I2C connection

Breadboard

Jumper cables

Connections

Arduino:

GND to GND of LCD and GPS

5V to VCC of LCD and GPS

A4 to SDA of LCD (I2C bus)

A5 to SCL of LCD (I2C bus)

8 to TX of GPS (8 is RX as AltSoftwareSerial defined)

9 to RX of GPS (9 = TX as AltSoftwareSerial defined)

(in the photo a used other software serial pins in the standard library)

Step 2: Coding

I used the following libraries:

Timezone.h to adjust the time to daylight savings time

TinyGPS++ to decode the GPS data

AltSoftSerial.h for the software serial connection with the GPS module (works better than SoftwareSerial, as seen in the unwanted 'blinks' of the LCD screen, while using that standard).

EDIT: NewLiquidCrystal (NOT: LiquidCrystal_I2C.h) for the LCD screen I used.

These libraries can be downloaded from Github.

My code is published on my Github.

1 Person Made This Project!

Recommendations

  • Fix It Speed Challenge

    Fix It Speed Challenge
  • Photography Challenge

    Photography Challenge
  • Anything Goes Contest 2021

    Anything Goes Contest 2021

22 Comments

0
Samarei
Samarei

Question 10 months ago

Does it require a fix to get the time or is one satellite enough? Because TinyGPS++ doesn't seem to support $GPZDA which "is sent as soon as time is received from a satellite" (without needing a fix).

0
Wim3d
Wim3d

Answer 10 months ago

I have not tried that. I think it does not only depend on the TinyGPS++ library, but also on the GPS module. The module I used seems to start to send data when there is a fix. Maybe you can find a module which sends the time when receiving data from 1 satellite only, but then you need to interpret the data.

0
Samarei
Samarei

Reply 10 months ago

Thanks for the reply!
On this video, at 2:50, the data seems to be sent before the GPS fix at 3:30:


Does yours work indoors even when a phone in GPS only mode with wifi disabled can't get a fix?

0
Wim3d
Wim3d

Reply 10 months ago

I checked it. The module indeed communicates the time before there is a GPS-fix. Instead of waiting for the satellite-value to be > 0, for a clock it is better to wait for 'gps.time.isValid()'. I changed the code in my Github.

0
Samarei
Samarei

Reply 10 months ago

Wow, great! Thanks, that was fast!
Did you check if you're able to get a signal further away form the window?
PS: you missed the comment "wait for a GPS fix to know the UTC time"

0
Wim3d
Wim3d

Reply 10 months ago

Thanks for reviewing the code.
Yes the device is much more sensitive and gets a time faster and futher away from windows. I did not examine my entire house.

0
Samarei
Samarei

Reply 10 months ago

You're welcome. ;)
Nice!
I was checking the code of TinyGPS++ and noticed that the date isn't always set when the time is set. The date is set with $GPRMC but not with $GPGGA.
So you may want to double check you can still get the date with one satellite (by just using gps.date.isValid() instead of gps.time.isValid()), otherwise $GPZDA will have to be used.

0
Wim3d
Wim3d

Reply 10 months ago

In my code, the arduino waits when the number of satellites is equal to zero. The number of satellites is > 0 when there is a fix and the number of satellites then is 4 or 5. I have not tried to get the time without a fix.
If I look at the video, apparently it is possible. If it is helpful for you I can try for my GPS module.
When using the uBlox sofware you can see that the GPS module sends data, even when there is no fix.
I live in a concrete house. My GPS module only works close to a large window or on the top floor, since the roof is not made of concrete.

0
Samarei
Samarei

Reply 10 months ago

Indeed, it would be interesting to try. You'll probably be able to get the time away from the window since only one satellite signal is needed.
The code from the video is the DeviceExample example file.
You can just replace gps.satellites.value() != 0 by gps.time.isValid()

0
Wim3d
Wim3d

Reply 10 months ago

Indeed, this is the way I found out simultaneously and changed the code.

0
RudyardB
RudyardB

1 year ago on Step 2

HELLO TAKES ME OUT OF THIS ERROR LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

0
RudyardB
RudyardB

Reply 1 year ago

ALREADY WORKED THIS WAS THE ERROR, WHAT I MISS IS FINDING TIMEZONE FOR CENTRAL MEXICO CONGRATULATIONS YOU ARE A TITAN
error.png
0
Wim3d
Wim3d

Reply 1 year ago

Thanks.
Suggestion: you can easily find I2C devices and their address by using a I2C scanner program on your Arduino.
For the timezone: please try this part of the code.
//CDT – Central Daylight Time / Central Daylight Saving Time (Daylight Saving Time) -300 = -5 hours from UTC in daylight saving time (summer).
TimeChangeRule CDT = {"CDT", Last, Sun, Mar, 2, -300};
//CST – Central Standard Time / Central Time (Standard Time) -360 = -6 hours from UTC in normal time (winter).
TimeChangeRule CST = {"CST ", Last, Sun, Oct, 3, -360};
Timezone CE(CDT, CST);

0
Wim3d
Wim3d

Reply 1 year ago

Hello. Can you give me more Information concerning your error or problems?

0
RudyardB
RudyardB

Reply 1 year ago

Hola al momento de compilar me muestra este error:
LiquidCrystal_I2C lcd (0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVO); // Establecer la dirección LCD I2C
y no lo puedo subir a la placa arduino

0
RudyardB
RudyardB

1 year ago

ESTE ES PA PANTALLA DE EROR

gps.png
0
Wim3d
Wim3d

Reply 1 year ago

It seems that 'POSITIVE' is not defined (see the information in the red bar on your screen). I'm not sure where that's done, I guess in the Arduino board definitions.
I see that you use Arduin IDE 1.6.11. I suggest you updrade the Arduino IDE to the latest version (I use 1.8.9). If that does not work, try to update the libraries used. Good luck, let me know if you succeed or need any further help.

0
RudyardB
RudyardB

Reply 1 year ago

HELLO AND UPDATE TO THE LATEST VERSION AND LIBRARIES AND I HAVE THE SAME ERROR I WILL SEND YOU WHAT COMES IN THE RED LETTERS
Arduino:1.8.12 (Windows 8.1), Tarjeta:"Arduino Nano, ATmega328P"
GPS-clock-daylight-LCD:11:53: error: 'POSITIVE' was not declared in this scope
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
^~~~~~~~
C:\Users\RUDYARD\Desktop\GPS-clock-daylight-LCD\GPS-clock-daylight-LCD.ino: In function 'void setup()':
GPS-clock-daylight-LCD:31:18: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'
lcd.begin(16, 2); // initialize the lcd for 16 chars 2 lines, turn on backlight
^
In file included from C:\Users\RUDYARD\Desktop\GPS-clock-daylight-LCD\GPS-clock-daylight-LCD.ino:9:0:
C:\Users\RUDYARD\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate: void LiquidCrystal_I2C::begin()
void begin();
^~~~~
C:\Users\RUDYARD\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate expects 0 arguments, 2 provided
Se encontraron varias bibliotecas para "Wire.h"
Usado: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
No usado: C:\Users\RUDYARD\Documents\Arduino\libraries\Wire
Se encontraron varias bibliotecas para "TinyGPS++.h"
Usado: C:\Users\RUDYARD\Documents\Arduino\libraries\TinyGPSPlus-0.95
No usado: C:\Users\RUDYARD\Documents\Arduino\libraries\TinyGPSPlus-1.0.2b
exit status 1
'POSITIVE' was not declared in this scope
Este informe podría contener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.


0
RudyardB
RudyardB

Reply 1 year ago

HELLO FRIEND I DID EVERYTHING AND THE ERROR CONTINUES