Timezone library for MKR Series?

Hi all,

I have a MKR WiFi 1010, I would like to adjust the built in RTC to run on my local time after querying an NTP for the current time (in UTC). I have found two libraries, but unfortunately they don’t work with the MKR WiFi 1010.

This library only works with AVR architecture boards, not SAMD. Upon trying to upload the code it puts my
Arduino into a weird state where I need to double tap reset to get it back (using Desktop IDE only, online IDE doesn’t work).

The ezTime library requires the use of EEPROM and seeing that the MKR Wifi 1010 doesn’t have EEPROM, I see that there is a library to simulate EEPROMs for boards that have none, arduino nvm? But this still doesn’t work, as Flash.h isn’t found (see attached error log from online IDE).

Anyone have any ideas? Is there a library that I don’t know of or a way to get ezTime to compile correctly and work?

error log.txt (3.17 KB)

mnl1121:
GitHub - JChristensen/Timezone: Arduino library to facilitate time zone conversions and automatic daylight saving (summer) time adjustments.
This library only works with AVR architecture boards, not SAMD. Upon trying to upload the code it puts my
Arduino into a weird state where I need to double tap reset to get it back

This is very strange because both of those libraries should work on any architecture. I know that you'll get a warning from the Timezone library that it's only for AVR, but that's just because the author doesn't want to provide technical support for people using the library with other architectures. There are a couple of functions in the Timezone library that use EEPROM, which your MKR WiFi 1010 doesn't have, but those functions are only compiled when you have an AVR-based board selected so they can't cause any harm (unless you wanted to use them, in which case compilation would just fail).

Which sketch are you running when this happens?

mnl1121:
using Desktop IDE only, online IDE doesn't work

Would you mind providing some more details about the problem with the online IDE? Perhaps I can help you with that.

I use the Jack Christensen library on an ESP8266, no issues.

I appreciate the responses, I'm rather confused, as I just tried again and it's working this time. Uploading one of the examples doesn't lock up my arduino anymore.

pert:
Which sketch are you running when this happens?

I was using one of the example sketches.

pert:
Would you mind providing some more details about the problem with the online IDE? Perhaps I can help you with that.

Before when I was first trying the library out. Upon uploading one of the example sketches (the clock example I believe) my arduino wouldn't do anything. Nothing would output to the serial monitor. My computer wouldn't recognize that it was plugged in anymore. Double tapping the reset button would reconnect it to my computer, but I would then no longer be able to upload any new sketches. Any sketch I'd try and upload it would compile and then show busy as it was uploading, but never finish. This happened even for basic sketches like BareMinimum and Blink, it would just never finish after compiling. To fix, I'd need to quit out of the Arduino Create plugin and load up the desktop IDE. I'd then compile and upload a blink sketch and it would work. I wish I had saved the output, but it would take a little longer than normal and then say something about CPU reset and that would finish uploading.

mnl1121:
I'm rather confused, as I just tried again and it's working this time. Uploading one of the examples doesn't lock up my arduino anymore.

That is strange, but I guess we can't complain too much about a problem mysteriously solving itself. Hopefully it will stay solved. If not, we can investigate further (I would need to know which example sketch to test).

mnl1121:
Before when I was first trying the library out. Upon uploading one of the example sketches (the clock example I believe) my arduino wouldn't do anything. Nothing would output to the serial monitor. My computer wouldn't recognize that it was plugged in anymore. Double tapping the reset button would reconnect it to my computer, but I would then no longer be able to upload any new sketches. Any sketch I'd try and upload it would compile and then show busy as it was uploading, but never finish. This happened even for basic sketches like BareMinimum and Blink, it would just never finish after compiling. To fix, I'd need to quit out of the Arduino Create plugin and load up the desktop IDE. I'd then compile and upload a blink sketch and it would work. I wish I had saved the output, but it would take a little longer than normal and then say something about CPU reset and that would finish uploading.

Thanks for the information. My MKR WiFi 1010 is "indisposed" at the moment, but I just tried uploading with my MKR1000 and MKR WAN 1300 using the Arduino Web Editor without problems. The Arduino Web Editor does occasionally have a glitch that gets fixed quickly by the development team. So it may be this was only a temporary problem that has since been resolved and that's why I can't reproduce it.

Thanks pert, much appreciated for the help. I wouldn’t have tried again without your comment actually. Agreed I don’t complain much when things start to work, tis the life of a programmer shrugs.

I’m running into a new problem, I’ve pretty far along with my code now that I’ve been able to implement the timezone library so thanks! However my code compiles and runs great on the online IDE, but not on the desktop IDE. I’m trying to test how my program reacts to losing connection to WiFi and my MQTT server and being that the serial monitor cuts out when I reboot my router (to simulate losing connection), I’d like to test using the desktop IDE. I have all the same libraries installed (it seems). Any ideas? The problem starts when it tries to compile the RTCZero library. The first bit starts below. Full log file is attached.

C:\Users\mnl11\Documents\Arduino\libraries\RTCZero\src\RTCZero.cpp: In member function ‘uint32_t RTCZero::getEpoch()’:

C:\Users\mnl11\Documents\Arduino\libraries\RTCZero\src\RTCZero.cpp:378:13: error: aggregate ‘RTCZero::getEpoch()::tm tm’ has incomplete type and cannot be defined

struct tm tm;

arduino log file.txt (35.9 KB)

Figured out what the issue was RTCZero and Time libraries have a conflict. Delete/move/rename Time.h and it'll work. Time.h just includes TimeLib.h. TimeLib.h replaces Time.h, but Time.h is still kept for legacy versions of the Arduino IDE.