Hi, I recently downloaded and installed the Seeed Arduino RTC library for use with the arduino MKR gsm 1400 board in the Arduino IDE. However the examples for this Library do not compile. Specifically, in the rtc_samd21 example i get the error:
rtc_samd21:4:1: error: ‘RTC_SAMD21’ does not name a type;
The Seeed_Arduino_RTC library example compiles (and works) for the Seeed XIAO, but, as you have observed, doesn’t compile for the Arduino MKR GSM 1400 board. (It also doesn’t compile for an Arduino Zero, which is another SAMD21 board.)
On the other hand the Arduino RTCZero library example compiles OK for both the XIAO and the Arduino MKR GSM 1400 boards. (Also compiles and works for my Arduino Zero board.)
Bottom line: Much of the code in the Seeed_Arduino_RTC library appears to be copied from the Arduino RTCZero library, but the Seeed guys seem to have screwed the pooch for some SAMD21 boards. (There is an #ifdef directive at the beginning of RTC_SAMD21.cpp that may be the root of the problem, but I don’t have the time, stamina, or inspiration to investigate. Don’t really care, since there is an alternative that works for me.)
Use the Arduino Libraries Manager to install the RTCZero library and try its example(s). Let us know how it works.
Yes i have been using the RTCZero library for a while now and it works fine however i found that when using this library with the MKR GSM 1400 specifically while also using the ArduinoLowPower library for SAMD boards, which also uses the RTCZero library, i was getting some sort of conflict that i have not yet been able to resolve.
An example of the odd behavior is from a logger project using the MKR GSM 1400 board where i wanted to implement some sleep modes with the ArduinoLowPower library. I use the RTCZero library to set time and date functions however when i use the LOWPOwerLibrary (also uses RTCZero lib) with timed wakeup, the date (for example) gets reset to 0-1-1, time is similarly affected. This indicates some type of conflict between the usage methods. I tried to get around this by renaming the RTCZero object as _RTC:
/* Create an rtc object */
whereas in the ArduinoLowPower lib it is:
But this failed to fix the problem so i thought i would try a different RTC library which looks like it is not going to work.
If you have any thoughts on this they would be much appreciated.
I’m not sure I can help you, but let me see if I can understand your problem.
There is a hardware RTC. One and only one. You have created an RTCzero object somewhere in the project. You initialize the Date/Time, somehow, and use that in your logger.
Now, when you go into deep sleep, the only thing running is the hardware RTC, and the low-power library resets the hardware RTC date/time to zero before sleeping.
That means that the time-of-day information in the hardware RTC will have to be re-initialized when it wakes up.
I can’t see where having another, different (software) RTC object can possibly help.
Don’t know whether the following could meet your requirements, but, maybe, if the low-power mode has the ability to maintain some RAM contents while powered down, then…
Store Date/Time from the RTCzero object just before going into sleep. Upon awakening, set the hardware RTC and the RTCzero object with a new date and time obtained by adding the sleep time to the previously stored values.
If you can’t do this, then you have to re-initialize the RTC, somehow, with current Date/Time every time upon re-awakening. Probably not practical, but I don’t know exactly what you are expecting.
Update: I ran a test on my Arduino Zero board using the ArduinoLowPower.h library.
This initializes the hardware RTC but does not rewrite the hardware RTC during sleep functions (or anywhere else).
You simply have to re-initialize the RTCZero object in setup() and set date and time to make it go. (At least it works for me.)
The only problem is that the RTCZero object is in the private: section of the LowPower object definition.
From a comment in my test program:
* This requires the following modification of
* In the ArduinoLowPowerClass definition, move the declaration
* of the RTCZero object from the private: section to the public: section.
* Something like this, starting at line 87
void attachAdcInterrupt(uint32_t pin, voidFuncPtr callback, adc_interrupt mode, uint16_t lo, uint16_t hi);
RTCZero rtc; // davekw7x: Moved from private: to public:
void setAlarmIn(uint32_t millis);
//RTCZero rtc; // davekw7x: Moved from private: to public:
friend void ADC_Handler();
I have attached the project and some output. This little program makes an LED blink briefly then goes to sleep for a couple of seconds and wakes up again. Each time through the loop it prints out a loop count value and the current RTC Date/Time values.