smz / Arduino-RTCtime

A time.h compliant library that makes using the DS1307 and DS3231 Real Time Clock modules really simple.
10 stars 8 forks source link

Example does not compile with ESP8266 for Arduino #7

Closed RudyFiero closed 6 years ago

RudyFiero commented 6 years ago

You have listed that the library Supports esp8266. Maybe it does but I can't get your example to compile. Some minor problems that I have dealt with, some dependencies that are not part of the ESP8266-Arduino platform.

In RTCtimeUtils.h I have had to include #include

// ------> I M P O R T A N T ! <------ // We can set our Time Zone and initialize the library with it // Initialization performed later, using the standard set_zone() function.

set_zone() is does not seem to be a standard function under ESP8266. So I commented it out in order to try and get further in the compile.

RTCtime_Example:197: error: 'isotime' was not declared in this scope

       strcpy(utc_timestamp, isotime(&utc_tm));

Another AVR dependency. After commented out all of those lines.

error: there are no arguments to 'mk_gmtime' that depend on a template parameter, so a declaration of 'mk_gmtime' must be available [-fpermissive]

       return mk_gmtime(&now);
                                              ^

And that is as far as I can get. I am not a programmer just a hacker.

smz commented 6 years ago

Hello @RudyFiero and thanks for raising this issue!

I didn't personally made any test with the esp8266, but others confirmed that my library was working with it.

Unhappily I don't have an esp8266 myself to test with, but I'll look into this and let you know as soon as possible.

Regards,

Sergio

smz commented 6 years ago

I just noticed that all the errors you are reporting may be explained if the time.h library is misssing: please check the following:

Before the errors you cited, you should have had an error regarding the missing time.h...

RudyFiero commented 6 years ago

I'm using Arduino 1.8.5 I do have time.h, but there are different time files for the ESP8266 since it is not an AVR processor. https://github.com/esp8266/Arduino/blob/master/tools/sdk/libc/xtensa-lx106-elf/include/sys/time.h https://github.com/esp8266/Arduino/blob/master/cores/esp8266/time.c

I had looked at this a week ago. I am finally getting back to it. I was hoping to get something to test with the change to daylight savings time tonight. Not a big deal if I miss it. I have other code I am testing for the time change. There were recent changes to the ESP8266 that made external time libraries redundant.

The ESP8266-Arduino has standard time handling functions. Time zone and daylight savings support. There isn't much done with real time clocks since most applications for the chip includes internet connections and that is what is used to get the current time. While I want my devices to use internet time I also want them to work standalone and that is why I'm including a real RTC.

From the Makuna wiki - Instead of using this library, you can use the modified version of this library from here GitHub/Smz/Arduino-RTCtime. You can find it in the library manager as "RTCtime by smz". This is very useful when you need to use a library that already uses the standard C time API

Sounds good, just what I want. And I do think your library does what I need. Get and set time for the DS3231. I think the problems I listed are just problems with the example and not problems with the library itself.

I think that SetTimeUX() and GetTimeUX() are all I need. I am going to try and work with that and incorporate it into something I have.

One thing I want to comment on and I realize it is too late to matter. The library name. It is the same as the Makuna name. I have to remove the Makuna library so I don't have it conflicting with your version. And I have some programs that use that one and if I continue with this one I have to again do a swap. Of course the real problem is the simple Arduino environment. So in the future I would recommend that when you make a derivative library that you call is something different.

smz commented 6 years ago

Hi Rudy!

Everything is clear: your (ESP8266) time.h is completely different from mine (AVR), and the ESP8266 one doesn't seems to have much of the Std C stuff (if any) and thus the example couldn't correctly compile!

So, I think my library can work in the ESP8266, but it can't be put to good use with the Std C libarary functions, which are essentially missing from the ESP8266 time.h implementation.

But... have you checked the @PaulStoffregen time.h implementation at https://github.com/PaulStoffregen/Time ? I'm unsure if that can be complied for the ESP8266 and since it uses the standard Unix epoch (1970-01-01) instead of mine (2000-01-01) you should use the GetTimeUX() and SetTimeUX() functions from my library when interfacing with that.

About the library name... you're right: I should have changed the names of the RtcDS1307.h and RtcDS3231.h files, but I'm afraid it's too late now... You can, anyway, change the names yourself (like, e.g. smzRtcDS3231.h) and then #include those file names. For next version I'll see if I can do something about that...

Keep me informed of how things are going, please...

smz commented 6 years ago

[deleted personal stuff between me and @RudyFiero]

RudyFiero commented 6 years ago

[deleted personal stuff between me and @RudyFiero]

smz commented 6 years ago

[deleted personal stuff between me and @RudyFiero]

About this issue, I'm leaving it open until I'll have at least documented the problem... OK?

Thanks again!

smz commented 6 years ago

Have I understood correctly that the ESP8266 time.h uses the Unix epoch (1970-01-01) and not the AVR epoch (2000-01-01)?

smz commented 6 years ago

I have updated the README.md Can you please give a look at it and see if it is OK?

RudyFiero commented 6 years ago

Have I understood correctly that the ESP8266 time.h uses the Unix epoch (1970-01-01) and not the AVR epoch (2000-01-01)?

Yes that is correct. From what I can tell Unix is a guide for the ESP8266 framework.

I have read the notes you added and I don't see any problem with it.

smz commented 6 years ago

Perfect!

Is it OK for you to close this issue?

[deleted personal stuff between me and @RudyFiero]

smz commented 6 years ago

Thanks @RudyFiero for your help!

smz commented 6 years ago

Conversation locked: please open a new issue if you need...