We will guide to develop Arduino based 7 segment gps clock which will show EDT time. Accurate time is provided via synchronized clocks with the global positioning system (GPS). These clocks are ubiquitous and frequently found at bus stops, train stations, and airports. These are also frequently employed in the military.
Here, we present a GPS clock built on the Arduino Uno R3, a microcontroller board based on the AVR ATmega328 that has 14 digital input/output (I/O) pins and six analog input pins. The microcontroller contains 1kB of EEPROM, 2kB of RAM, and 32kB of ISP flash memory. The board supports serial communication using SPI, I2C, and UART.
Arduino GPS based Clock’s Circuit and Its working:
The GPS clock’s Arduino circuit and block diagram are displayed in Figures 1 and 2, respectively. The SIM28M GPS receiver module (GPS1), an Arduino Uno board (BOARD1), a GPS antenna (ANT.1), a 9V DC power supply adapter, and a few jumpers for header connections are also used in the circuit.
Here, we tried to extract the GPS time and date from a GPS-provided string ($GPRMC). There are roughly 70 characters in this string. The Arduino manages every procedure and receives GPS output signals, as illustrated in Fig. 2.
Following receipt of the GPS output, the Arduino reads all of the strings and stores them in an array or string within the Arduino program. Once the necessary string has been stored, Arduino retrieves the time and date from the string and transmits it to LCD1 for display.
Pins 5, 4, 3, and 2 of the Arduino are directly linked to data pins D4 through D7 of LCD1, accordingly. Pins 11 and 12 of the Arduino are linked to control pins EN and RS of LCD1, respectively. The Arduino board’s Rx pin is directly connected to the Tx pin of the GPS receiver. Keep in mind that the GPS and Arduino ground pins need to be attached to one another.
The GPS module in this instance operates at a baud rate of 9600bps. The Arduino sketch’s class
Serial.begin(9600)
function is used to set the Arduino to operate at a baud rate of 9600bps.
SIM28M GPS receiver module (GPS1) – GPS output:
As seen in Fig. 3, the Arduino’s serial monitor displays the GPS receiver output. Use the same connections as previously described, but take the ATmega328 microcontroller off of the Arduino board to obtain this GPS data. Then, to inspect the GPS output format, launch the Arduino IDE and choose the Serial Monitor option.
You just need to use $GPRMC String. out of the numerous strings displayed in this window. Here, the date appears after the ninth comma, while the time in 24-hour format follows the first comma. This $GPRMC string is processed by an Arduino software to extract the date and time, which is then shown on LCD1.
Software:
The Arduino Uno’s internal memory contains a software program that controls circuit operation. The Arduino programming language is used to create the software (gpsindia.ino). The application is compiled and uploaded using the Arduino IDE 1.6.4.
Choose the appropriate COM port in the Arduino IDE after connecting the Arduino board to the PC. Put the software or sketch together. Upload the sketch after choosing the appropriate board from the Arduino IDE’s Tools�Board menu. Programming in this project does not require external header files.
Code Arduino based gps clock:
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
char str[70];
char *test="$GPRMC";
int temp,i;
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" GPS ");
lcd.setCursor(0,1);
lcd.print(" Digital Clock ");
delay(300);
}
void loop()
{
serial1Event();
if (temp)
{
lcd.clear();
int str_lenth=i;
int x=0,comma=0;
String UTC_hour="";
String UTC_minut="";
String UTC_second="";
String UTC_date="";
String UTC_month="";
String UTC_year="";
String str1="";
while(x<str_lenth) { if(str[x]==',') comma++; if(comma==1) { x++; UTC_hour+=str[x++]; UTC_hour+=str[x++]; UTC_minut+=str[x++]; UTC_minut+=str[x++]; UTC_second+=str[x++]; UTC_second+=str[x]; comma=2; } if(comma==10) { x++; UTC_date+=str[x++]; UTC_date+=str[x++]; UTC_month+=str[x++]; UTC_month+=str[x++]; UTC_year+=str[x++]; UTC_year+=str[x]; } x++; } int UTC_hourDec=UTC_hour.toInt(); int UTC_minutDec=UTC_minut.toInt(); int Second=UTC_second.toInt(); int Date=UTC_date.toInt(); int Month=UTC_month.toInt(); int Year=UTC_year.toInt(); int Hour=UTC_hourDec+5; if(Hour>23)
{
Hour-=24;
Date+=1;
}
int Minut=UTC_minutDec+30;
if(Minut>59)
{
Minut-=60;
Hour+=1;
}
// UTC_ind_zone_time
lcd.clear();
lcd.print("Date: ");
lcd.print(Date);
lcd.print("/");
lcd.print(Month);
lcd.print("/");
lcd.print("20");
lcd.print(Year);
lcd.setCursor(0,1);
lcd.print("Time: ");
lcd.print(Hour);
lcd.print(":");
lcd.print(Minut);
lcd.print(":");
lcd.print(Second);
// delay(100);
temp=0;
// j=0;
i=0;
x=0;
str_lenth=0;
// k=0;
}
// delay(1000);
}
void serial1Event()
{
while(1)
{
while (Serial.available()) //checking serial data from GPS
{
char inChar = (char)Serial.read();
str[i]= inChar; //store data from GPS into str[]
i++;
if (i < 7) { if(str[i-1] != test[i-1]) //checking for $GPRMC sentence { i=0; } } if(i>65)
{
temp=1;
break;
}
}
if(temp)
break;
}
}
Construction and testing:
It is not necessary to construct the circuit on a PCB. Use external header jumpers to connect the Arduino Uno, LCD1, and SIM28M GPS receiver module to complete the circuit. Attach a 9V power supply adapter to the Arduino and SIM28M GPS receiver module, respectively. Connect the GPS1 module to ANT.1 as well. Locate the LCD1 unit in a convenient spot.
In Fig. 4, the author's prototype is displayed.
Download the Project file for above GPS based Clock built for LCD:
Click download the SIM28M GPS receiver module GPS-Arduino-Clock-LCD.ino
Converting timezone from Indian timezone to EDT timezone:
To convert the timezone from Indian Standard Time (IST, UTC+5:30) to Eastern Daylight Time (EDT, UTC-4:00), you need to adjust the hour and minute calculations. Here's the simple change you need to make:
Change the timezone offset
Replace the following lines in the code:
Multiplexing 7 Segment displays with Arduino and Shift Registers
Temperature Displayed on 4 Digit 7 segment using Arduino