Real time with no RTC - Funhouse

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Shaunsail
 
Posts: 14
Joined: Tue Sep 07, 2021 11:14 am

Real time with no RTC - Funhouse

Post by Shaunsail »

I can get date functions I need from datetime but the clock starts from power on so not so useful.
I can get UTC from a web call, but I don’t know how to apply it, i.e .use it instead of datetime. Not that it would work in my application where I am looking for seconds until next minute. My internet is not great!
I have seen code to manually set time on RTC.
I wrote a clunky method to get the delta of seconds between the two (seconds and minutes) and add the correction to the datetime value each time I called it.
What I am looking for is a method to update the datetime epoc value (without a RTC) after power up using the UTC. Is there such a thing?

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: Real time with no RTC - Funhouse

Post by dastels »

You could add an I2C RTC breakout using the STEMMA-QT connector: https://www.adafruit.com/product/5188 and https://www.adafruit.com/product/4399.

Dave

User avatar
Shaunsail
 
Posts: 14
Joined: Tue Sep 07, 2021 11:14 am

Re: Real time with no RTC - Funhouse

Post by Shaunsail »

I appreciate that I can add a RTC, my question was if I had access to NTP could I set the local datetime (Rather than time since power on) to a new value (with out RTC hardware).
Could I run the RTC module without hardware and use the function to manually set datetime?

If the Funhouse and other internet enable boards cant use NTP, then may be the next enhancement will include a RTC as it is useful to know the current DTM.

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: Real time with no RTC - Funhouse

Post by dastels »

However you get the current time, either from a hardware RTC or via a time service, you can set the system datetime from it. That will no doubt drift over time so you'll want to resync it regularly. Daily is probably fine. The RTC module without hardware doesn't make sense to me. the module is for interfacing with the hardware.

Dave

User avatar
Shaunsail
 
Posts: 14
Joined: Tue Sep 07, 2021 11:14 am

Re: Real time with no RTC - Funhouse

Post by Shaunsail »

Could you please tell me the code/syntax to set date time to a new value, I have not been able to find anything.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Real time with no RTC - Funhouse

Post by adafruit2 »


User avatar
Shaunsail
 
Posts: 14
Joined: Tue Sep 07, 2021 11:14 am

Re: Real time with no RTC - Funhouse

Post by Shaunsail »

Thank.
This works like my attempt. I calculated a delta between internet time and time since power on. Then add the delta to the time since power on when I needed it. I repeated this every 12 hours. Works ok for seconds. I also repeated this for minute and hour.
What I would like to do it offset time since power on so that I could use all the date time functions as is.
Since RTC has a function to add an offset I was hoping that there may be a way to add an offset with out the physical RTC.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”