[SOLVED] Timezone library in combination with Arduino and GPS shield with NEO

(deleted)

Post your code in code tags,

...so it looks like this...

or attach it if it's too big.

Do the same thing for the error messages (copy and paste from the build window).

(deleted)

Timezone compilation error with Clock.ino.txt (3.54 KB)

(deleted)

WorldClock.ino (5.36 KB)

Here are the error messages, for our convenience:

D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino: In function 'void setup()':
Clock:32: error: 'setTime' was not declared in this scope
     setTime(myTZ.toUTC(compileTime()));
                                      ^
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino: In function 'void loop()':
Clock:39: error: 'now' was not declared in this scope
     utc = now();
               ^
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino:40:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     printTime(utc, "UTC");
                         ^
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino: In function 'time_t compileTime()':
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino:51:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     char *compDate = __DATE__, *compTime = __TIME__, *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
 ^
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino:51:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino:51:64: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     char *compDate = __DATE__, *compTime = __TIME__, *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
                                                                ^
Clock:54: error: 'tmElements_t' was not declared in this scope
     tmElements_t tm;
     ^
Clock:60: error: expected unqualified-id before '.' token
     tm.Month = ((m - months) / 3 + 1);
       ^
Clock:62: error: expected unqualified-id before '.' token
     tm.Day = atoi(compDate + 4);
       ^
Clock:63: error: expected unqualified-id before '.' token
     tm.Year = atoi(compDate + 7) - 1970;
       ^
Clock:64: error: expected unqualified-id before '.' token
     tm.Hour = atoi(compTime);
       ^
Clock:65: error: expected unqualified-id before '.' token
     tm.Minute = atoi(compTime + 3);
       ^
Clock:66: error: expected unqualified-id before '.' token
     tm.Second = atoi(compTime + 6);
       ^
Clock:67: error: expected primary-expression before ')' token
     t = makeTime(tm);
                    ^
Clock:67: error: 'makeTime' was not declared in this scope
D:\Arduino\Libraries\Timezone\examples\Clock\Clock.ino: In function 'void printTime(time_t, char*)':
Clock:74: error: 'hour' was not declared in this scope
     sPrintI00(hour(t));
                     ^
Clock:75: error: 'minute' was not declared in this scope
     sPrintDigits(minute(t));
                          ^
Clock:76: error: 'second' was not declared in this scope
     sPrintDigits(second(t));
                          ^
Clock:78: error: 'weekday' was not declared in this scope
     Serial.print(dayShortStr(weekday(t)));
                                       ^
Clock:78: error: 'dayShortStr' was not declared in this scope
     Serial.print(dayShortStr(weekday(t)));
                                        ^
Clock:80: error: 'day' was not declared in this scope
     sPrintI00(day(t));
                    ^
Clock:82: error: 'month' was not declared in this scope
     Serial.print(monthShortStr(month(t)));
                                       ^
Clock:82: error: 'monthShortStr' was not declared in this scope
     Serial.print(monthShortStr(month(t)));
                                        ^
Clock:84: error: 'year' was not declared in this scope
     Serial.print(year(t));
                        ^
exit status 1
'setTime' was not declared in this scope

I just pasted your error messages into the post editor, selected all of them, then pressed the "<>" code button in the upper left. It puts [code] at the beginning of the selection and [/code] at the end (you can type that in if you want).

It looks like it did not find the Time.H file for the Time library.

The error messages say that the Timezone library was installed in "D:\Arduino\Libraries". Do you have "D:\Arduino\Libraries\Time\Time.h" and TimeLib.h? I assume that you have all of your personal sketches (not library examples) in "D:\Arduino\sketch_dir" directories.

Do you have a "C:\Users\you\My Documents\Arduino" directory, too?

Can you build the Time examples?

Turn on "Show Verbose Output during: compilation", and copy/paste the error messages again.

The example builds ok for me, so there is some problem with the directories or file locations.

(deleted)

When I am typing words I see at almost every word a red golf line under it.

Yes. When you complete the word and type a space, it should disappear if it's spelled correctly. If it's a filename or some acronym, it may remain "flagged".

You may be interested in the timezone technique in an example program from my NeoGPS library: NMEAtimezone.ino. It also accommodates Daylight Saving Time in the US. NeoGPS is smaller, faster and more accurate than other GPS libraries.

(deleted)

there is something not yet correct in my personal forum settings because almost every words is still underlined with the red golfline underline [or squiggle].

That's definitely a red flag, LOL. That tells me that the spelling dictionary is not being found by the spell checker. For a browser window, that's serious.

Normally, you can't move directories after installation. And there are special ways to move Windows' user directories away from the default location. If I may use a technical term, you are messed up. :wink: I'm not sure how you should recover, except to

  • do a backup of your user data files (things you have created, not downloaded files),
  • delete the user account,
  • uninstall the IDE,
  • delete any remaining user or IDE directories (uninstall may not have worked),
  • recreate the user account,
  • move the user directories (Documents, Pictures, etc.) in "the special way",
  • re-install the IDE,
  • restore user data files to the special location, and
  • re-download libraries (manually or with the IDE Library Manager).

Our change over month is the LAST sunday of March and the time change at 2 midnight from UTC+1 to UTC +2 and backover also the last sunday in October with the time change UTC +1. Please give me a example how to do it with your library

Here ya' go:

  if (fix.valid.time && fix.valid.date) {
    NeoGPS::clock_t seconds = fix.dateTime;

    //  USA Daylight Savings Time rule (calculated once per reset and year!)
    static NeoGPS::time_t  changeover;
    static NeoGPS::clock_t springForward, fallBack;

    if ((springForward == 0) || (changeover.year != fix.dateTime.year)) {
      changeover.year    = fix.dateTime.year;
      changeover.month   = 3; // March
      changeover.date    = 31; // the latest LAST Sunday
      changeover.hours   = 2;
      changeover.minutes = 0;
      changeover.seconds = 0;
      changeover.set_day();
      // Step back to the LAST Sunday, if day != SUNDAY
      changeover.date -= (changeover.day - NeoGPS::time_t::SUNDAY);
      springForward = (NeoGPS::clock_t) changeover;

      changeover.month   = 10; // October
      changeover.date    = 31; // latest LAST Sunday
      changeover.hours   = 2 - 1; // to account for the "apparent" DST +1
      changeover.set_day();
      // Step back to the LAST Sunday, if day != SUNDAY
      changeover.date -= (changeover.day - NeoGPS::time_t::SUNDAY);
      fallBack = (NeoGPS::clock_t) changeover;
    }

    // Set these values to the offset of your timezone from GMT
    static const int32_t zone_hours           = +1L; // CET
    static const int32_t zone_minutes         =  0L; // usually zero
    static const NeoGPS::clock_t zone_offset  =
                      zone_hours   * NeoGPS::SECONDS_PER_HOUR +
                      zone_minutes * NeoGPS::SECONDS_PER_MINUTE;

    seconds += zone_offset;

    if ((springForward <= seconds) && (seconds < fallBack))
      seconds += NeoGPS::SECONDS_PER_HOUR;

    NeoGPS::time_t localTime( seconds );

And your last question:

we use coordinates in the WGS84 datum notation . For example N(orth or South)52(1 space) 04.123 minutes and E(ast or West)004(also 1 space) 05.678 minutes. NDD mm.mmm EDDD mm.mmm.

Actually, WGS84 nor any other datum has anything to do with the format of the latitude and longitude values. All GPS devices I've ever seen report the lat/lng in the WGS84 datum, in the NMEA format DDDMM.mmmm,c, where "c" is 'N', 'E', 'S' or 'W'.

NeoGPS doesn't know anything about datums (data?), but it does provide several output formats. Obviously it parses the NMEA DDDMM.mmmm,c, format. There are many possibilities, but NeoGPS makes it easy to print the parsed values in the following output formats:

  • DDD.dddddd (a floating-point degrees format), with
    Serial.print( fix.latitude(), 6 );
  • DDDddddddd (a scaled integer degrees format), with
    Serial.print( fix.latitudeL() );
  • DDDMM.mmmm (the NMEA degrees & minutes format), with
    fix.latitudeDMS.printDDDMMmmmm( Serial );

(Note: this uses the alternative latitudeDMS member.)

It's up to the programmer to write code for other formats, just like you had to write code to rearrange the NMEA format.

To print exactly what you want, you could do this:

#include <DMS.h>

void printDD_MMmmmm( DMS_t & dms, char hemisphere )
{
  Serial.print( hemisphere );
  Serial.print( dms.degrees );
  Serial.print( ' ' );

  if (dms.minutes < 10)
    Serial.print( '0' );

  float minutes = dms.minutes;
  minutes += (dms.seconds_whole * 1000.0 + dms.seconds_frac) / (60.0 * 1000.0);

  Serial.print( minutes, 4 );
}

void somewhere()
{
  printDD_MMmmmm( fix.latitudeDMS, fix.latitudeDMS.NS() );
  printDD_MMmmmm( fix.longitudeDMS, fix.longitudeDMS.EW() );

This code uses a DMS structure that has degrees, minutes, seconds and hemisphere "pieces" (aka "members"). You can access the DMS members for printing or calculations. If you want to try it, you must enable 2 extra items in the config files:

  • GPS_FIX_LOCATION_DMS in GPSfix_cfg.h, and
  • NMEAGPS_PARSING_SCRATCHPAD in NMEAGPS_cfg.h

NeoGPS is the only library that preserves the original NMEA accuracy in the parsed values. Most libraries allow you to write extra code to grab the raw NMEA characters. But using the float values is the surest way to lose 2 or 3 significant digits.

To perform distance or bearing calculations, you cannot use the original NMEA DDMM.mmmm form. All other libraries perform those calculations with float values. NeoGPS calculations are very accurate at small distances, which might be important (nice?) for geocaching applications.

This is similar to the timezone and DST calculations. You can't use the original DDMMYY hhmmss forms to do the offset. They must be parsed into values before they can be manipulated.

(deleted)