Hi all,
I checked few of its examples, and didn‘t see how to change the time zone .
Thanks
Adam
What time zone is reported now? What time zone do you want to change it to?
Thanks.
this code below got right location data, but the time output is 7 hours later as my local time.
my time zone is: Eastern Standard Time
how to fxi?
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
Serial.println(F("DeviceExample.ino"));
Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(","));
Serial.print(gps.location.lng(), 6);
}
else
{
Serial.print(F("INVALID"));
}
Serial.print(F(" Date/Time: "));
if (gps.date.isValid())
{
Serial.print(gps.date.month());
Serial.print(F("/"));
Serial.print(gps.date.day());
Serial.print(F("/"));
Serial.print(gps.date.year());
}
else
{
Serial.print(F("INVALID"));
}
Serial.print(F(" "));
if (gps.time.isValid())
{
if (gps.time.hour() < 10) Serial.print(F("0"));
Serial.print(gps.time.hour());
Serial.print(F(":"));
if (gps.time.minute() < 10) Serial.print(F("0"));
Serial.print(gps.time.minute());
Serial.print(F(":"));
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(F("."));
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.print(gps.time.centisecond());
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}
That seems odd since USA EST is UTC - 05:00.
I suggest that you print the NMEA sentences received from the GPS on to the Serial Monitor. You can then read the time directly from the $GPRMC Sentences.
Are you sure a GPS receiver will have a "time zone"?
I guess: it will provide UTC (Universal Time).
You have to "correct" the time from GPS for your location.
The satellite does not know where you are located.
I am so sure that time from GPS is always in UTC (not for any time zone).
That's the point. But OP reported time stamps 7 hours ahead of USA EST when while UTC is only 5 hours ahead of that time zone. So, first thing is print the raw NMEA sentences and confirm UTC is being reported. Next figure out while library is apparently reporting UTC + 02:00.
Why it is odd?
EST is UTC minus 5:00 - CORRECT.
UTC to EST
UTC is former "Greenwich time". +/-0 hrs is in Europe, in London.
All other time zones are ahead (e.g. China, all in the east), or behind (all in the west).
EST is US Atlantic coast, and it is west of Greenwhich, so behind, therefore minus 5 hours.
Nothing odd, just the earth rotation might be odd for you. LOL
Good point: but where should the 7 hr come from?
Potentially not from the satellite.
If you use a library in SW and this converts the time received from satellite, in combination with your location info, maybe this goes wrong.
7 hr difference could also be caused by wrong "assumptions" about "Daylight Saving Time".
Try to find how to read UTC from GPS.
Do not trust a LIB where also the location is taken into account, to convert into a local time zone.
And if: make sure you have a right local time reference, e.g. Daylight Saving Time on/off.
It's odd because OP is reporting a 7 hour time difference not 5.
Thanks.
the GPS is always in UTC.
the TinyGPS support a kind of offset, TinyGPS ++ don't? or i didn't find out yet.
It is odd what the used SW does.
The 7 hr cannot come from GPS, it must be inside the SW.
I have not seen such a function in the TinyGPS++ library. See the available functions here;
http://arduiniana.org/libraries/tinygpsplus/
And a GPS may, or may not, be putting out actual UTC. The time can be a few seconds out, but that is mostly not important.
Indeed. There's something else going on. Guess I'm old-school. I'd go back to the source data and confirm that raw the $GPRMC sentences are being correctly received. Then, trace the data flow through the library and see how it's time variable is set. But, of course, @shanren has his own "unique" debugging techniques.
True, I think it's about 19 seconds. I believe this is because GPS time stays in synch with an international atomic clock, not UTC. Anyway it's irrelevant in this case.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.