Skip to content

Commit 8e36d35

Browse files
committed
Restructure Example24 and add notes about ZED_F9P
1 parent 5a4c448 commit 8e36d35

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

examples/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
This example shows how to query a u-blox module for the current time and date as Unix Epoch uint32_t type to avoid time.h dependency.
99
We also turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic dramatically.
1010
11+
Note: this example works best on modules like the ZED_F9P. Modules like the ZOE_M8Q do not support confirmedTime.
12+
1113
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
1214
1315
Feel like supporting open source hardware?
@@ -29,8 +31,6 @@ SFE_UBLOX_GNSS myGNSS;
2931

3032

3133
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
32-
33-
uint32_t us; //microseconds returned by getUnixEpoch()
3434

3535
void setup()
3636
{
@@ -48,6 +48,9 @@ void setup()
4848
;
4949
}
5050

51+
// Uncomment the next line if you need to completely reset your module
52+
//myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts
53+
5154
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
5255
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
5356

@@ -63,11 +66,15 @@ void loop()
6366
{
6467
lastTime = millis(); //Update the timer
6568

66-
byte SIV = myGNSS.getSIV();
67-
Serial.print(F(" SIV: "));
68-
Serial.print(SIV);
69+
// getUnixEpoch marks the PVT data as stale so you will get Unix time and PVT time on alternate seconds
70+
71+
uint32_t us; //microseconds returned by getUnixEpoch()
72+
uint32_t epoch = myGNSS.getUnixEpoch(us);
73+
Serial.print("Unix Epoch: ");
74+
Serial.print(epoch, DEC);
75+
Serial.print(" micros: ");
76+
Serial.println(us, DEC);
6977

70-
Serial.print(" ");
7178
Serial.print(myGNSS.getYear());
7279
Serial.print("-");
7380
Serial.print(myGNSS.getMonth());
@@ -79,10 +86,6 @@ void loop()
7986
Serial.print(myGNSS.getMinute());
8087
Serial.print(":");
8188
Serial.print(myGNSS.getSecond());
82-
Serial.print(" getUnixEpoch(micros): ");
83-
Serial.print(myGNSS.getUnixEpoch(us));
84-
Serial.print(" micros: ");
85-
Serial.print(us, DEC);
8689

8790
Serial.print(" Time is ");
8891
if (myGNSS.getTimeValid() == false)
@@ -98,6 +101,8 @@ void loop()
98101
}
99102
Serial.print("confirmed");
100103

101-
Serial.println();
104+
byte SIV = myGNSS.getSIV();
105+
Serial.print(F(" SIV: "));
106+
Serial.println(SIV);
102107
}
103-
}
108+
}

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8984,7 +8984,7 @@ uint32_t SFE_UBLOX_GNSS::getUnixEpoch(uint32_t& microsecond, uint16_t maxWait)
89848984
packetUBXNAVPVT->data.sec);
89858985
int32_t us = packetUBXNAVPVT->data.nano / 1000;
89868986
microsecond = (uint32_t)us;
8987-
// ajust t if nano is negative
8987+
// adjust t if nano is negative
89888988
if(us < 0) {
89898989
microsecond = (uint32_t)(us + 1000000);
89908990
t--;

0 commit comments

Comments
 (0)