TinyCircuits Forum

TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started by: etSequent1a on February 16, 2021, 02:58:26 AM

Title: Arduino IDE not compiling Real-Time Clock TinyShield Arduino sketch
Post by: etSequent1a on February 16, 2021, 02:58:26 AM
I downloaded the Real-Time Clock TinyShield Arduino sketch from this site ( RTC_TinyShield_example.zip ) and tried to run it on my TinyZero board + Real-Time Clock TinyShield. I'm using an Arduino IDE ver. 1.8.13 and so far have not been able to compile the sketch as downloaded from this site.  I am getting the following error message:

RTC_TinyShield_example:20:10: fatal error: avr/power.h: No such file or directory
 #include <avr/power.h>
compilation terminated.

On the include line:

20 #include <avr/power.h>

Even when I verified the file power.h is included with the downloaded sketch in the specified "avr" sub folder.

Is there a compatibility issue in newer versions of the Arduino IDE? should I make a change to the code of the sketch in order to make it work or maybe the settings of the Arduino IDE?

This is frustrating. I would appreciate if someone could come up with a solution. I'll provide any information needed. Thanks in advance.
Title: Re: Arduino IDE not compiling Real-Time Clock TinyShield Arduino sketch
Post by: lennevia on February 16, 2021, 01:50:49 PM
Hello there,

The avr error message you are getting is due to the RTC TinyShield example being specific to avr processors like the one included on the TinyDuino.

Fortunately, the TinyZero has an onboard RTC from the SAMD21 processor and does not need the RTC TinyShield to tell time.

We have been meaning to publish a more general RTCZero library example tutorial with our products using the SAMD21 processor (TinyZero, TinyScreen+, RobotZero, WirelingZero), but the only current published tutorial is the extended TinyScreen+ one that includes more about sleep mode and interrupts (very popular topic): https://tinycircuits.com/blogs/learn/tinyscreen-external-interrupt-sleep-mode

On the bright side, we have the program ready to go for testing. I attached a zip file of the program that you can use with the TinyZero to work with the onboard RTC. You will just need to download that program and install the RTCZero library: https://www.arduino.cc/reference/en/libraries/rtczero/

Let me know how the program works for you!


Title: Re: Arduino IDE not compiling Real-Time Clock TinyShield Arduino sketch
Post by: etSequent1a on February 17, 2021, 10:57:46 AM
Thank you very much for your informative reply, I have downloaded the appropriate libs and successfully ran the sketch. ;D 8)

I would not have figured out the reason for the error for myself. So thank you again.

I would like to point out that the Real-Time Clock TinyShield Tutorial page on your site ( https://learn.tinycircuits.com/Sensors/Real-Time-Clock_TinyShield_Tutorial/ (https://learn.tinycircuits.com/Sensors/Real-Time-Clock_TinyShield_Tutorial/) ), where I downloaded the Real-Time Clock TinyShield Arduino Sketch, Specifically states the appropriate hardware for the sketch as TinyDuino OR TinyZero. You might want to revise that to indicate the sketch is only intended for avr architecture boards like TinyDuino.

As an aside, can I still use the RTC Shield as a real-time clock, even though I have an onboard RTC on the SAMD21? if so, what libraries would I need to do so?

Also, since the TinyZero board, unlike the TinyDuino, has no Coin cell battery support, is it possible to use the RTC Shield's coin cell to power the TinyZero board on standby mode?

Thank you again for your reply.
Title: Re: Arduino IDE not compiling Real-Time Clock TinyShield Arduino sketch
Post by: lennevia on February 18, 2021, 02:13:49 PM
Looks like we made an oopsie there on the tutorial page - sorry about that! I'll get that fixed sometime today.

I looked around for a library for the DS1339 RTC chip that was compatible with the SAMD21 processor but didn't have much luck. Arduino has a list of different libraries for RTC's, but since the SAMD21 has a built-in RTC there isn't much support. It's possible I may have missed something though, so you can take a look for yourself: https://www.arduino.cc/reference/en/libraries/category/timing/

The battery on the RTC board is connected to the RTC chip and is used when there isn't another power source - so unfortunately it's only suited to power the DS1339 chip and won't be useful for the TinyZero RTC. If you want to return the RTC TinyShield since we had a mistake in the tutorial, you can contact info@tinycircuits.com with your order number and we can solve that.

To power the onboard RTC, you should be able to use a Lithium battery with the processor in sleep mode. The Arduino documentation found on their page (https://www.arduino.cc/en/Reference/RTC) clarifies the details: "To keep the time and the RTC running it is necessary to keep the board powered. A button-sized lithium battery or any battery in the 3V range, connected through a diode to the 3.3V pin, is enough to keep RTC alive if the CPU is put in sleep mode before the standard USB or VIN power is disconnected." For the TinyZero, you just need to plug in a charged-up battery and use sleep mode.

I hope that helps!