We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Is Omega Onion2S capable of keeping track of real time



  • Hello,

    Is it possible to set the time on the omega2s, and it keeps track of the actual time?

    For example at the prompt i can type "date" and it gives me some random date, if i set the actual date and time, will it be able to keep the actual real-time and date from then on, until i turn off the power of course.

    Thanks



  • @nsmith *nix systems (including Omega) use NTP (Network Time Protocol) daemon to check and update the date and time from Inernet based NTP servers. If you are referring to a very accurate RTC in microcontroller parlance, Omega2 doesn't have an RTC built in but if this is your requirement you can add an external RTC.



  • @crispyoz Thanks for the information. But no it doesnt need to be extremely accurate, just be able to keep track of the time once i set it either by using command line or in code.

    Also it wont be connected to any external internet servers, so it cant update the time using that. I just want it to keep a rough estimate of the time using just the Omega2S by itself with no additional hardware or external servers.

    For example if i set it to 1AM, and then check the time 1 hr later it should say its 2AM (plus or minus 1 minute or so) would be fine.

    Can it do that now without modification?



  • @nsmith If your device doesn't have access to an external time source, then it really has no way of of nkowing how long it has been switched off.

    You don't necessarily need internet access to connect to an NTP server, most corporate networks provide them internally.

    If your device has no network acccess, then you're going to need something to keep track of time when your Omega is switched off then you'll need a time source to correct the Omega time when it restarts. Just google for RTC and you'll find a pile of designs to incoruporate into your design. As an alterntive solution, the device boots up and runs a script to connect to wifi, updates the time from NTP server then shuts down the wifi. A bit of a hack.



  • @crispyoz It only needs to keep track of time when its switched ON. If its switched off and then back on, then it doesnt need to know the time for my application, it only needs to keep track of time if i set the time while it stays on, if its turned off, then it no longer matters.



  • @nsmith I'll explain it like this. If I switich on the device and manually set the date and time to July 2nd, 2022 11:22:30 and leave the device running, it will keep the correct time with no need for any network/internet access, so at 15:25;12 on July 2nd 2022 I check the time and find the date and time to be correct. Then I switch the device off.

    On July 2nd 15:55:12 I switch the device back on. What will the date and time be? The answer is not as you might expect, it is not July 2nd 15:55:12. This is because the device stores the date and time in volatile RAM, so when the power is removed this is lost. When the device starts up it attempts to correct the date and time using a script /etc/init.d/sysfixtime which looks for the latest timestamp on files in /etc, of course if none of these files have changed in months then this doesn't help much. You could run a cron job that touches a file in /etc every X number of minutes/hours, but again if your device is switched off for day you'll still lose a day on the clock. Also touching files in /etc too frequently is not a great idea as it increases wear on the RAM.

    If your requirement is to simply track the duration of something regardless of whether the date and time are correct you can still do this. For example when your app starts up it might check the date and time (even if it is not correct), then later it could check date & time again and calculate the time difference between these two checks, just not the actual date and time.

    I hope that helps.


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.