Page 1 of 1

RTC or Day timer

Posted: 18 May 2018 14:02
by kjetilhansen
Hello :)


I want to include a timer in my project to make something happen once a day. I have read the RTC in these microcontrollers are not great. But I belive that problem disappears if you include a 16 GHz crystal?

I then need the crystal and two caps. Is it correct that they will be connected on pin 5 and 6 on the z-uno? That is the external clock pins..


Am I missing anything here?

Re: RTC or Day timer

Posted: 18 May 2018 15:23
by petergebruers
What datasheet are you looking at? The Z-Uno is based on a ZM5101 and according to the datasheet it has a 32 MHz Xtal based oscillator. (integrated).. But no RTC. So it has the accuracy of a XTAL but it has no hardware to support date/time. You seem to think it does not have an internal XTAL, would require 16 MHz and has an RTC but it is not accurate? I probably misunderstand what you are asking.

https://www.silabs.com/documents/login/ ... 2625-9.pdf

I have not tried to do what you ask... maybe someone else did. If it is "mains powered" you can use millis() function to time stuff. If it is battery powered, I think you'll have to add RTC hardware, because the low power state does not allow you to do accurate timing.

What exactly do you want to do every 24h? When exactly, at 00:00 for instance? What kind of accuracy do you want?

Re: RTC or Day timer

Posted: 18 May 2018 15:40
by kjetilhansen
I usually try to use standalone chips, and I have a sender and a receiver now. ATMEGA328 and at the receiver I use the z-uno and HC-12 modules between.

I read that the ATMEGA chip does not have a good clock, so it will miss "steps" every day... I do not need any precise measure of time. I just want a signal to a bell 2-3 times a day, so would be great to have a way to maybe have it so every 12 hours or so it turns a output on.

I read something about millis() function, but that will be an awful length of MS to get to 12 hours :P And this does not need ms precision

Re: RTC or Day timer

Posted: 18 May 2018 15:49
by petergebruers
So you are not talking about the Z-Uno.. .Anyway, the millis() counter is 32 bit on arduino and the likes, so you have it for free, and it can time differences up to about 50 days if I remember correctly. Google is your friend. Basically, in setup() you set a variable to millis() + (hours to time *3600000). Then in loop you check If millis > that variable. Do whatever you want and calculate the next value... Many Z-Uno and Arduino sketches use this concept.

Re: RTC or Day timer

Posted: 18 May 2018 19:30
by kjetilhansen
That was actually quite smart. I have never thought about that. Converting millis to hours and then use hours instead of an very long line of ms!