rtc on STM32F407VET6 Black Board ??

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
bellad
Posts: 75
Joined: Tue May 14, 2019 1:47 pm

rtc on STM32F407VET6 Black Board ??

Post by bellad » Thu May 28, 2020 2:23 pm

hello,
i try of setup init RTC with :

Code: Select all

import machine
rtc=machine.RTC()
rtc.init((2014, 5, 1, 4, 13, 0, 0, 0))
TypeError: function takes 1 positional arguments but 2 were given
what is the right way to do it?

thank you

User avatar
dhylands
Posts: 3385
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: rtc on STM32F407VET6 Black Board ??

Post by dhylands » Thu May 28, 2020 5:00 pm

Unfortunately, it really depends on the board you're using.

Here's rshell's code which runs on most boards. You can pick the one you're using and just use that:
https://github.com/dhylands/rshell/blob ... #L951-L985

User avatar
jcw
Posts: 35
Joined: Sat Dec 21, 2019 12:08 pm
Location: CET/CEST

Re: rtc on STM32F407VET6 Black Board ??

Post by jcw » Fri May 29, 2020 3:23 pm

Yes, it looks like you need datetime iso init, here's a very similar board:

Code: Select all

$ picocom -q -b115200 /dev/cu.usbmodem3167336E34362
MicroPython v1.12-464-gcae77daf0-dirty on 2020-05-24; VCC-GND STM32F407ZG with STM32F407ZG
Type "help()" for more information.
>>> import machine
>>> rtc=machine.RTC()
>>> rtc.datetime()
(2015, 1, 1, 4, 0, 0, 0, 255)
>>> rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
>>> rtc.datetime()
(2014, 5, 1, 4, 13, 0, 3, 255)
>>>
Note that many API details can be inferred interactively:

Code: Select all

>>> dir(rtc)
['__class__', 'calibration', 'datetime', 'info', 'init', 'wakeup']
>>> rtc.datetime(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object 'int' isn't a tuple or list
>>> rtc.datetime((1,2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: requested length 8 but object has length 2
>>>

bellad
Posts: 75
Joined: Tue May 14, 2019 1:47 pm

Re: rtc on STM32F407VET6 Black Board ??

Post by bellad » Tue Jun 02, 2020 1:35 pm

ok , thank you
but not enough memory to my prog ,
how to go back , remove micropython ?

bellad
Posts: 75
Joined: Tue May 14, 2019 1:47 pm

Re: rtc on STM32F407VET6 Black Board ??

Post by bellad » Thu Jun 04, 2020 9:45 am

grrrr...

>>> rtc.datetime((2020,6,4,11,43,0,0,0))
year, month , day ,hour,minute
>>> rtc.datetime()
(2021, 6, 4, 3, 3, 0, 1, 40)

oups , year , month , day , weekday , hour , minute ,
(2020,6,4,4,11,0,0,0,0)
good

bellad
Posts: 75
Joined: Tue May 14, 2019 1:47 pm

Re: rtc on STM32F407VET6 Black Board ??

Post by bellad » Thu Jun 04, 2020 12:21 pm

now the rtc init is good , i have put battery , but the rtc does not run on battery
exp:
with power : rtc.datetime()
(2020, 6, 4, 4, 14, 1, 32, 184)
no power on battery during 10mn
with power ( after 10mn )
rtc.datetime()
(2020, 6, 4, 4, 14, 1, 32, 184)

no change !!

Post Reply