How to set rtc time

RenJian
Posts: 3
Joined: Fri Nov 17, 2017 2:06 am

How to set rtc time

Postby RenJian » Fri Nov 17, 2017 6:17 am

Hi,

I can find "rtc_time_get" to get the current time, but How can I reset the rtc time? have any apis?

thanks very much!

ESP_Sprite
Posts: 1227
Joined: Thu Nov 26, 2015 4:08 am

Re: How to set rtc time

Postby ESP_Sprite » Sat Nov 18, 2017 1:34 pm

If I recall correctly, hardware doesn't support setting the RTC time. Suggest either using the 'standard' time APIs (which will automatically use a RTC delta instead of the absolute RTC time) or calculating the difference in actual RTC time and what you want it to be yourself and subtracting that from RTC time readings.

RenJian
Posts: 3
Joined: Fri Nov 17, 2017 2:06 am

Re: How to set rtc time

Postby RenJian » Tue Nov 21, 2017 6:26 am

Hi,
Thanks for reply.
I find three rtc apis: get_time_since_boot/get_boot_time/set_boot_time.
if I want to set the rtc time, Can I just set boot time with "set_boot_time" api? and Getting the rtc time use "rtc_time = get_time_since_boot + get_boot_time"?

ESP_igrr
Posts: 870
Joined: Tue Dec 01, 2015 8:37 am

Re: How to set rtc time

Postby ESP_igrr » Wed Nov 22, 2017 4:51 am

I think these functions are internal/static. The suggested approach is to use gettimeofday/settimeofday functions.

Who is online

Users browsing this forum: Google [Bot] and 7 guests