help,can't init the RTC!

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
41536172@qq.com
Posts: 11
Joined: Sun May 08, 2016 3:41 pm

help,can't init the RTC!

Post by 41536172@qq.com » Tue Aug 16, 2016 8:43 am

>>>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

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: help,can't init the RTC!

Post by deshipu » Tue Aug 16, 2016 10:22 am

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)

41536172@qq.com
Posts: 11
Joined: Sun May 08, 2016 3:41 pm

Re: help,can't init the RTC!

Post by 41536172@qq.com » Tue Aug 16, 2016 10:34 am

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)

41536172@qq.com
Posts: 11
Joined: Sun May 08, 2016 3:41 pm

Re: help,can't init the RTC!

Post by 41536172@qq.com » Tue Aug 16, 2016 10:39 am

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)

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: help,can't init the RTC!

Post by deshipu » Tue Aug 16, 2016 10:45 am

"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.

udmicpy
Posts: 13
Joined: Tue Aug 15, 2017 3:47 pm

Re: help,can't init the RTC!

Post by udmicpy » Sat Aug 26, 2017 1:48 pm

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

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: help,can't init the RTC!

Post by pythoncoder » Sun Aug 27, 2017 7:44 am

I suggest you look at ntptime.py in esp8266/modules.
Peter Hinch
Index to my micropython libraries.

mkn
Posts: 1
Joined: Sun Aug 09, 2020 1:19 pm

Re: help,can't init the RTC!

Post by mkn » Sun Aug 09, 2020 1:25 pm

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?

Post Reply