Skip to content

Commit

Permalink
Attempt to set sys clock using GPS at early boot (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephHewitt authored Oct 5, 2024
1 parent 230bcef commit 9475d27
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions A/A.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,34 @@ void setup() {
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);

Serial.println("Attempting GPS date/time sync..");

Serial2.begin(gps_baud_rate,SERIAL_8N1,16,17);

for (int x = 0; x < 3000; x++){
int c_count = 0;
while (Serial2.available()){
c_count++;
if (c_count > 128){
break;
}
char c = Serial2.read();
if (nmea.process(c)){
if (nmea.isValid()){
lastgps = millis();
gps_time_sync();
}
}
}
if (dt_string_from_gps() != ""){
break;
}
delay(1);
}
gps_time_sync();
Serial.print("Date/time is now: ");
Serial.println(dt_string_from_gps());

while (!filewriter){
filewriter = SD.open("/test.txt", FILE_APPEND);
if (!filewriter){
Expand Down Expand Up @@ -2387,8 +2415,6 @@ void setup() {
b_side_hash.concat(b_side_hash_full.charAt(x));
}

Serial2.begin(gps_baud_rate,SERIAL_8N1,16,17);

Serial.print("This device: ");
Serial.println(device_type_string());

Expand Down

0 comments on commit 9475d27

Please sign in to comment.