Page 1 of 1

help,can't init the RTC!

Posted: Tue Aug 16, 2016 8:43 am
by 41536172@qq.com
>>>import machine
>>>rtc=machine.RTC()
>>>rtc.init((2014, 5, 1, 4, 13, 0, 0, 0))
Traceback (most recent call last):
File "<stdin>, line 1, in <module>
AttributeError: ‘RTC’ object has no attribute 'init'

but i did this according here: http://docs.micropython.org/en/latest/e ... e.RTC.html

Re: help,can't init the RTC!

Posted: Tue Aug 16, 2016 10:22 am
by deshipu
The documentation is wrong. You should use the "datetime" method.
Also, the tuple is actually (year, month, day, weekday, hour, minute, second, millisecond).

Code: Select all

>>>import machine
>>>rtc=machine.RTC()
>>>rtc.datetime((2014, 5, 1, 0, 4, 13, 0, 0))
>>>rtc.datetime()
(2014, 5, 1, 0, 4, 13, 0, 0)

Re: help,can't init the RTC!

Posted: Tue Aug 16, 2016 10:34 am
by 41536172@qq.com
thank you very much! And i want to study about the RTC and TIMER, how many timers are there in 8266? and where can i find the documentation? the offical documentation is too brief i think.

deshipu wrote:The documentation is wrong. You should use the "datetime" method.
Also, the tuple is actually (year, month, day, weekday, hour, minute, second, millisecond).

Code: Select all

>>>import machine
>>>rtc=machine.RTC()
>>>rtc.datetime((2014, 5, 1, 0, 4, 13, 0, 0))
>>>rtc.datetime()
(2014, 5, 1, 0, 4, 13, 0, 0)

Re: help,can't init the RTC!

Posted: Tue Aug 16, 2016 10:39 am
by 41536172@qq.com
What is "weekday" mean?
deshipu wrote:The documentation is wrong. You should use the "datetime" method.
Also, the tuple is actually (year, month, day, weekday, hour, minute, second, millisecond).

Code: Select all

>>>import machine
>>>rtc=machine.RTC()
>>>rtc.datetime((2014, 5, 1, 0, 4, 13, 0, 0))
>>>rtc.datetime()
(2014, 5, 1, 0, 4, 13, 0, 0)

Re: help,can't init the RTC!

Posted: Tue Aug 16, 2016 10:45 am
by deshipu
"Weekday" is the day of the week. I think 0 is Sunday, 1 is Monday, etc. You can just put 0 in there every time, it will be calculated correctly.

If something is not described in the documentation, then your only other option is to look into the source code.

Re: help,can't init the RTC!

Posted: Sat Aug 26, 2017 1:48 pm
by udmicpy
Hello all together,

I had today (one year later) the same problem.
Wouldn't it be fine if the MicroPython documentation could be hold more up to date?
And in which source code should we take a look? In the c source of the github project?
https://github.com/micropython/micropyt ... hine_rtc.c

Thanks a lot in advance.

Best regards, Uwe

Re: help,can't init the RTC!

Posted: Sun Aug 27, 2017 7:44 am
by pythoncoder
I suggest you look at ntptime.py in esp8266/modules.

Re: help,can't init the RTC!

Posted: Sun Aug 09, 2020 1:25 pm
by mkn
Am I correct in assuming that the main documentation is for PyBoard (or some other) only and other boards have branches that may have several differences in the implementation?