Go Down

Topic: [SOLVED] Timezone library in combination with Arduino and GPS shield with NEO (Read 340 times) previous topic - next topic

JevanHa

Hi JChristensen.
I hopefully tried to solve my DST problem with your Timezone library. To get more knowledge about it, I first tested the examples and refreshed the complete Time library from github.com before I Started.
But whatever I try or search the library, I will not get without compiling errors with my Arduino and GPS shield. What am I doing wrong ?

I have tried it with the included Timezone examples Clock.ino and this are the errors I have got:
 line 33 'setTime' was not declared in this scope
 line 39 'now' was not declared in this scope
 line 54 'tmElements_t' was not declared in this scope

Then I tried the same with WorldClock.ino on serveral lines starting from line 41  'dowSunday' was not declared in this scope and also the same error lines with setTime() & utc=now().

No problems found with HardwareRTC.ino. But WriteRules.ino reported a error at
 Timezone\Timezone.cpp:183:57: error: 'SECS_PER_DAY' was not declared in this scope
     t += (7 * (w - 1) + (r.dow - weekday(t) + 7) % 7) * SECS_PER_DAY;
Please help this Newbe :)
Kind regards
Jan
Nederlands Forum   http://arduino.cc/forum/index.php/board,77.0.html

-dev

Post your code in code tags,

Code: [Select]
...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).

JevanHa

Hello /Dev
The complete library comes from the github website https://github.com/JChristensen/Timezone.
The first thing I do is trying how it works by compiling the example files. But with this one I got to many errors.
I deleted all the Blanc lines with no information.

Kind regards
Jan
Nederlands Forum   http://arduino.cc/forum/index.php/board,77.0.html

JevanHa

Kind regards
Jan
Nederlands Forum   http://arduino.cc/forum/index.php/board,77.0.html

-dev

Here are the error messages, for our convenience:

Code: [Select]
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.

JevanHa

In a other website dicussion I found the solution of this problem. There is only one library missing.
 #include <DS1307RTC.h>   //http://www.arduino.cc/playground/Code/Time. Now I have only some warning errors. For now this is not so important for me because I only will study how the DST functions from Jack Christensen are working.
Thanks for your help.
I have a other small question about one or more of my settings. When I am typing words I see at almost every word a red golf line under it. Is that some spelling checker ?
Kind regards
Jan
Nederlands Forum   http://arduino.cc/forum/index.php/board,77.0.html

-dev

Quote
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.

JevanHa

Good morning,
Maybe (I am shure about it) there is something not yet correct setted in my personal forum settings because almost ervery words is stil underlined with the red golfline. Till now not so important. And when I am not shure about the spelling of a word I use Google translate (sorry :) ).

One of the first things what I do on a new computer (a Notebook is als a computer :) ) is moving my whole personal user environment to a other partition, mostly /D: or a other drive, als the D:/ directory.  What I could not move is the hidden directory 'AppData' but that directory is not my problem but Windows. You read that I am talking about directories almost never about folders.

In the beginning after the first time download and installing the Arduino IDE I placed al my new libraries and sketches in the Arduino default directory. But I mentioned some backup problems with very long directory and file names and the new Windows Arduino installer also deleted all my files. So after installing I have to resore them from my daily backup.  I give meaningful names to my projects and applications. So I moved the library and sketch files and build my own directory structure on the root of Drive D:/. Arduino will find my files because I told him in the preferences file ( D:/Arduino ) where to find it. When Arduino comes with a new IDE version there is not any problem for me to download and run the new Windows exe installer file.

I have read before (some month a go) about your nice working NeoGPS library. But ............. your library programming style is to high in level for me. I'm actually a computer hardware engineer who later became as a system administrator (on Digital mid and mainframes) for getting to the software. What I self called I am switched over from the back to the front side of the Computer systems. 

I learn the C and C++ language by reading it and the level you program your library is at this moment to high for me. Please keep it that way.

I also live in Europe, precisely in the Netherlands. That is CET. 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 and then of course I will also use it.  ;-)

And my last problem is the presentation way of the coordinates. As a Geocacher 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. With TinyGPSplus, made by Mikal Hart, I have the possibility to create a Custom object that extract the raw info from the NMEAstream. 
Kind regards
Jan
Nederlands Forum   http://arduino.cc/forum/index.php/board,77.0.html

-dev

Quote
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.  ;)  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).

Quote
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:

Code: [Select]
  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:

Quote
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:

Code: [Select]
#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.

JevanHa

Hello /dev,

What a very nice and informative reply you give my on my extensive post on this forum. For which I thank you very much. To morrow in the morning I will try them all and let you know about my experiences. And may be I need some answers too. :)

Just about the mess you think is on my user Pc's I can tell that there not any mess at all. When you work with my Pc's or Notebooks and also the many one of my friends you will not notice any differences.
As I told you earlier I come from the Mainframe environment and there it is absolute vorbidden to install the users environment on the same drive or partition as the operating system. Your website call sign suggests you come from a Unix environment. And also in Unix the is a separation between OS and the User environments.

And till now I only had advantages over it myself. When Windows crashed and need to be restored from the backup or rebuild from the original installing CD's or whatever.

Once in a month I made a Full System Image backups of all my Raid 1 configured disc drive's and during the week I made a daily differential backup from my user environment and some specified other files such as the Arduino directories. During restoring from these backups I Never had to look at my own or other users environment because I did it at the only right way there is. Moving the files from drive C to drive ..... any one you like what is available and not copy and delete. You can check my registry settings and see with yourself the are setted in the right way.

Ok enough about this and lets go work with the information I get today from you.
Thanks again for all the effort you take for me.
Kind regards
Jan
Nederlands Forum   http://arduino.cc/forum/index.php/board,77.0.html

Go Up